From b014d746ea447bc03c9e05bb54f4b4a777f76e5d Mon Sep 17 00:00:00 2001 From: Matthew Fidler Date: Thu, 31 Mar 2016 00:07:13 -0500 Subject: [PATCH] Support multiple types of icons for color changes. These functions now support the xpm-bw type - mode-icons--generate-narrow - mode-icons--read-only-status - mode-icons--modified-construct - mode-icons--mode-line-eol-desc This is done by running `mode-icons-propertize-mode` --- mode-icons.el | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/mode-icons.el b/mode-icons.el index af8b38f..8958bef 100644 --- a/mode-icons.el +++ b/mode-icons.el @@ -342,17 +342,21 @@ the icon. FACE should be the face for rendering black and white xpm icons specified by type 'xpm-bw." - (or (gethash (list icon type (or face 'mode-line)) mode-icons-get-icon-display) - (puthash (list icon type (or face 'mode-line)) - (let ((icon-path (mode-icons-get-icon-file - (concat icon "." (or (and (eq type 'xpm-bw) "xpm") - (symbol-name type)))))) - (if (eq type 'xpm-bw) - (create-image (mode-icons-get-icon-display-xpm-bw-face icon-path face) - 'xpm t :ascent 'center - :face (or face 'mode-line)) - `(image :type ,(or (and (eq type 'jpg) 'jpeg) type) :file ,icon-path :ascent center))) - mode-icons-get-icon-display))) + (let ((face (or face + (and (mode-icons--selected-window-active) + 'mode-line) + 'mode-line-inactive))) + (or (gethash (list icon type face) mode-icons-get-icon-display) + (puthash (list icon type face) + (let ((icon-path (mode-icons-get-icon-file + (concat icon "." (or (and (eq type 'xpm-bw) "xpm") + (symbol-name type)))))) + (if (eq type 'xpm-bw) + (create-image (mode-icons-get-icon-display-xpm-bw-face icon-path face) + 'xpm t :ascent 'center + :face face) + `(image :type ,(or (and (eq type 'jpg) 'jpeg) type) :file ,icon-path :ascent center))) + mode-icons-get-icon-display)))) (defcustom mode-icons-minor-mode-base-text-properties '('help-echo nil @@ -525,7 +529,12 @@ FACE is the face to match when a xpm-bw image is used." (nth 1 icon-spec))) (put-text-property (point-min) (point-max) 'mode-icons-p icon-spec) (buffer-string))) - (t (propertize (format "%s" mode) 'display (mode-icons-get-icon-display (nth 1 icon-spec) (nth 2 icon-spec) face) + (t (propertize (format "%s" mode) 'display + (mode-icons-get-icon-display (nth 1 icon-spec) (nth 2 icon-spec) + (or face + (and (mode-icons--selected-window-active) + 'mode-line) + 'mode-line-inactive)) 'mode-icons-p icon-spec))))) (defvar mode-icons-get-icon-spec (make-hash-table :test 'equal)