From dfe725021833912ac02305fffc0a522121ce6846 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 19 Oct 2022 00:38:37 +0100 Subject: [PATCH] feat(editor): switch to fork of all-the-icons-completion --- core/siren-core-package-overrides.el | 3 +++ modules/editor/siren-all-the-icons.el | 36 ++++++++++++++++++++------- straight/versions/default.el | 2 +- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/core/siren-core-package-overrides.el b/core/siren-core-package-overrides.el index 3e221ed..b9454e5 100644 --- a/core/siren-core-package-overrides.el +++ b/core/siren-core-package-overrides.el @@ -8,6 +8,9 @@ (setq straight-recipe-overrides '((nil . ( + ;; Use fork with more features until PR is merged: https://github.com/iyefrat/all-the-icons-completion/pull/19 + (all-the-icons-completion :type git :flavor melpa :host github :repo "iyefrat/all-the-icons-completion" + :fork (:host github :repo "MintSoup/all-the-icons-completion")) ;; Override go-playground to use my fork, which has a fix for ;; uploading to go.dev/play. (go-playground :type git :host github :repo "grafov/go-playground" diff --git a/modules/editor/siren-all-the-icons.el b/modules/editor/siren-all-the-icons.el index f1c532e..54f1796 100644 --- a/modules/editor/siren-all-the-icons.el +++ b/modules/editor/siren-all-the-icons.el @@ -6,6 +6,8 @@ ;;; Code: +(require 'siren-marginalia) + ;; Required by all-the-icons (use-package memoize) @@ -27,15 +29,31 @@ (all-the-icons-completion-mode) :config - ;; Override default category lookup function. - (defun all-the-icons-completion-get-icon (cand cat) - "Return the icon for the candidate CAND of completion category CAT." - (cl-case cat - (file (all-the-icons-completion-get-file-icon cand)) - (project-file (all-the-icons-completion-get-file-icon cand)) - (buffer (all-the-icons-completion-get-buffer-icon cand)) - (project-buffer (all-the-icons-completion-get-buffer-icon cand)) - (t "")))) + ;; Using original all-the-icons-completion package. + (when (fboundp 'all-the-icons-completion-get-file-icon) + ;; Override default category lookup function to add support for + ;; project-buffer and project-file. + (defun all-the-icons-completion-get-icon (cand cat) + "Return the icon for the candidate CAND of completion category CAT." + (cl-case cat + (file (all-the-icons-completion-get-file-icon cand)) + (project-file (all-the-icons-completion-get-file-icon cand)) + (buffer (all-the-icons-completion-get-buffer-icon cand)) + (project-buffer (all-the-icons-completion-get-buffer-icon cand)) + (t "")))) + + ;; Using MintSoup's fork of all-the-icons-completion. + (when (not (fboundp 'all-the-icons-completion-get-file-icon)) + (require 'cl-generic) + + (cl-defmethod all-the-icons-completion-get-icon ((cand string) (cat (eql 'project-buffer))) + "Display project-buffer icon for CAND all-the-icons-completion." + (all-the-icons-completion-get-icon cand 'buffer)) + + ;; Add support for 'project-file category by treating it same as 'file. + (cl-defmethod all-the-icons-completion-get-icon ((cand string) (cat (eql 'project-file))) + "Display project-file icon for CAND all-the-icons-completion." + (all-the-icons-completion-get-icon cand 'file)))) (provide 'siren-all-the-icons) ;;; siren-all-the-icons.el ends here diff --git a/straight/versions/default.el b/straight/versions/default.el index bee8e8f..e342b6a 100644 --- a/straight/versions/default.el +++ b/straight/versions/default.el @@ -1,6 +1,6 @@ (("a.el" . "93e5ed8c495794d1ba3c04b43041b95ce01079b1") ("ace-window" . "77115afc1b0b9f633084cf7479c767988106c196") - ("all-the-icons-completion" . "286e2c064a1298be0d8d4100dc91d7a7a554d04a") + ("all-the-icons-completion" . "b8e3c4ceb862a3cbb771884c1e6b5d884356f141") ("all-the-icons-ibuffer" . "54c99aeb17989f684eb7bf3aa88b12adf7dd2d34") ("all-the-icons.el" . "51bf77da1ebc3c199dfc11f54c0dce67559f5f40") ("anzu" . "5abb37455ea44fa401d5f4c1bdc58adb2448db67")