Skip to content

Commit

Permalink
Deal with missing font amily
Browse files Browse the repository at this point in the history
  • Loading branch information
bestlem committed Aug 4, 2021
1 parent feb402c commit 428fd9a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
8 changes: 5 additions & 3 deletions site-lisp/mwb/mwb-icons.el
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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."
Expand Down
39 changes: 28 additions & 11 deletions site-lisp/mwb/spaceline-mwb-segments.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)))
Expand Down
3 changes: 1 addition & 2 deletions site-lisp/mwb/spaceline-mwb.el
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 428fd9a

Please sign in to comment.