From 428fd9a69262417efcbe16a4ff5184a55e11ae52 Mon Sep 17 00:00:00 2001 From: Mark Bestley <37385+bestlem@users.noreply.github.com> Date: Wed, 4 Aug 2021 13:49:08 +0100 Subject: [PATCH] Deal with missing font amily cover for bug https://github.com/domtronn/all-the-icons.el/issues/275 --- site-lisp/mwb/mwb-icons.el | 8 +++-- site-lisp/mwb/spaceline-mwb-segments.el | 39 ++++++++++++++++++------- site-lisp/mwb/spaceline-mwb.el | 3 +- 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/site-lisp/mwb/mwb-icons.el b/site-lisp/mwb/mwb-icons.el index 6de6924..d2b661b 100644 --- a/site-lisp/mwb/mwb-icons.el +++ b/site-lisp/mwb/mwb-icons.el @@ -147,8 +147,9 @@ ARGS is same as `all-the-icons-octicon' and others." (defun eyeliner/get-icon-family (set-name) "Return the family-name for a given iconset SET-NAME." - (--when-let (all-the-icons--family-name set-name) - (apply it '()))) + (if-let (it (all-the-icons--family-name set-name)) + (apply it '()) + (message "No family for %s" set-name))) (defun eyeliner/find-icon (icon-name) "Return a cons containing an icon and its family-name from ICON-NAME." @@ -163,7 +164,8 @@ ARGS is same as `all-the-icons-octicon' and others." "Execute BODY while binding icon and family from ICON-NAME." (declare (indent defun)) `(--when-let (eyeliner/find-icon ,icon-name) - (cl-destructuring-bind (icon . family) it ,@body))) + (cl-destructuring-bind (icon . family) it + ,@body))) (defun mwb-icon-get (icon-name) "Return a propertized icon from ICON-NAME." diff --git a/site-lisp/mwb/spaceline-mwb-segments.el b/site-lisp/mwb/spaceline-mwb-segments.el index c5899d3..e4198e9 100644 --- a/site-lisp/mwb/spaceline-mwb-segments.el +++ b/site-lisp/mwb/spaceline-mwb-segments.el @@ -54,16 +54,33 @@ (spaceline-define-segment mwb-mode-icon - "An `all-the-icons' segment indicating the current buffer's mode with an icon" - (let ((icon (all-the-icons-icon-for-mode major-mode))) - (unless (symbolp icon) - (propertize icon - 'help-echo (format "Major-mode: `%s'" major-mode) - 'mouse-face 'mode-line-highlight - 'local-map mode-line-major-mode-keymap - 'face `(;; :height ,(spaceline-all-the-icons--height 1.1) - :family ,(all-the-icons-icon-family-for-mode major-mode) - :inherit))))) + "An `all-the-icons' segment indicating the current buffer's mode with an icon. spaceline does not check for missing icon so try e" + (let ((icon-major (all-the-icons-icon-for-mode major-mode)) + (family-major (all-the-icons-icon-family-for-mode major-mode) )) + (if (and icon-major family-major) + (propertize icon-major + 'help-echo (format "Major-mode!: `%s'" major-mode) + 'display '(raise 0) + 'face `( + :height 0.9 + :family ,(all-the-icons-icon-family-for-mode major-mode) + :inherit)) + (eyeliner/with-icon "bars" + ;; (message "Bars Not found %s %s %s" major-mode icon family) + (propertize icon + 'help-echo (format "Major-modex: `%s'" major-mode) + 'display `(raise 0) + 'face `( + :height 0.9 + :family ,family + :inherit)))))) +;; (spaceline-define-segment mwb-mode-icon +;; "Use jp-modeline version so no fancy lookups." +;; (propertize " ☰ " +;; 'help-echo (format "Major-mode!: `%s'" major-mode) + +;; 'help-echo "Show major mode menu" +;; 'local-map mode-line-major-mode-keymap)) (spaceline-define-segment mwb-minor-modes @@ -82,7 +99,7 @@ mouse-1: Display minor modes menu" "A segment to indicate whether the current buffer is narrowed." (eyeliner/with-icon "filter" (propertize icon - 'family family + 'family ,family 'help-echo "mouse-1: Widen the current file" 'mouse-face mode-line-highlight 'local-map (spaceline-mwb--mouse-map 'mouse-1 'widen))) diff --git a/site-lisp/mwb/spaceline-mwb.el b/site-lisp/mwb/spaceline-mwb.el index bc4065f..fceec83 100644 --- a/site-lisp/mwb/spaceline-mwb.el +++ b/site-lisp/mwb/spaceline-mwb.el @@ -42,7 +42,6 @@ (require 'mwb-icons) (require 'minions) - (defmacro mwb-headline--keymap-duo-header (keymap) "Copy the mode-line KEYMAP to header-line." `(define-key ,keymap [header-line] @@ -88,7 +87,7 @@ ;; The actual buffer info (( - all-the-icons-mode-icon + ;; all-the-icons-mode-icon ((all-the-icons-buffer-path all-the-icons-buffer-id) :separator "")) :face default-face)