Allow a default Icon

- This is done by `mode-icons-use-default-icon'.
- This should fix Issue #34
This commit is contained in:
Matthew L. Fidler 2016-07-12 00:43:14 -05:00
parent 53ac2b364f
commit d02cbbddcb
2 changed files with 13 additions and 2 deletions

View file

@ -22,7 +22,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Powerline now recolors lines correctly by modified powerline-raw - Powerline now recolors lines correctly by modified powerline-raw
function. function.
- mode-icons now recolors font icons correctly when the font is - mode-icons now recolors font icons correctly when the font is
missing from the system. missing from the system
- mode-icons now allows for a default icon. This can be turned on
with the new option `mode-icons-use-default-icon`
## [0.4.0] ## [0.4.0]

View file

@ -240,6 +240,7 @@ This was stole/modified from `c-save-buffer-state'"
("\\`Image\\[png\\]\\'" "png" ext) ("\\`Image\\[png\\]\\'" "png" ext)
("\\` ?AI\\'" #xf03c FontAwesome) ("\\` ?AI\\'" #xf03c FontAwesome)
("\\` ?Isearch\\'" #xf002) ("\\` ?Isearch\\'" #xf002)
(default #xf059 FontAwesome)
;; Diminished modes ;; Diminished modes
("\\` ?\\(?:ElDoc\\|Anzu\\|SP\\|Guide\\|PgLn\\|Undo-Tree\\|Ergo.*\\|,\\|Isearch\\|Ind\\)\\'" nil nil)) ("\\` ?\\(?:ElDoc\\|Anzu\\|SP\\|Guide\\|PgLn\\|Undo-Tree\\|Ergo.*\\|,\\|Isearch\\|Ind\\)\\'" nil nil))
"Icons for major and minor modes. "Icons for major and minor modes.
@ -259,6 +260,7 @@ without the extension. And the third being the type of icon."
(const :tag "Apple" apple) (const :tag "Apple" apple)
(const :tag "Windows" win) (const :tag "Windows" win)
(const :tag "Unix" unix) (const :tag "Unix" unix)
(const :tag "Default Icon" default)
(function :tag "Enriched minor mode")) (function :tag "Enriched minor mode"))
(choice (choice
(string :tag "Icon Name") (string :tag "Icon Name")
@ -1250,6 +1252,11 @@ icon as well."
:type 'boolean :type 'boolean
:group 'mode-icons) :group 'mode-icons)
(defcustom mode-icons-use-default-icon nil
"Use the 'default icon when icon-name cannot be found."
:type 'boolean
:group 'mode-icons)
(defun mode-icons-get-mode-icon (mode &optional face active) (defun mode-icons-get-mode-icon (mode &optional face active)
"Get the icon for MODE, if there is one. "Get the icon for MODE, if there is one.
FACE represents the face used when the icon is a xpm-bw image. FACE represents the face used when the icon is a xpm-bw image.
@ -1258,6 +1265,8 @@ ACTIVE represents if the window is active."
(icon-spec (mode-icons-get-icon-spec mode-name)) (icon-spec (mode-icons-get-icon-spec mode-name))
(face (mode-icons--get-face face active)) (face (mode-icons--get-face face active))
ret) ret)
(when (and (not icon-spec) mode-icons-use-default-icon)
(setq icon-spec (mode-icons-get-icon-spec 'default)))
(if icon-spec (if icon-spec
(setq ret (setq ret
(if mode-icons-show-mode-name (if mode-icons-show-mode-name