mirror of
https://github.com/ryuslash/mode-icons.git
synced 2024-11-24 18:40:29 +01:00
Add icons for minor modes
This commit is contained in:
parent
34416c4643
commit
74702c8bc7
1 changed files with 30 additions and 1 deletions
|
@ -112,6 +112,31 @@ ICON-SPEC should be a specification from `mode-icons'."
|
|||
"Set the icon for the current major mode."
|
||||
(mode-icons-set-mode-icon mode-name))
|
||||
|
||||
(defvar mode-icons-set-minor-mode-icon-alist nil)
|
||||
|
||||
(defun mode-icons-set-minor-mode-icon-undo ()
|
||||
(let (minor)
|
||||
(dolist (mode mode-icons-set-minor-mode-icon-alist)
|
||||
(setq minor (assq (car mode) minor-mode-alist))
|
||||
(when minor
|
||||
(setcdr minor (cdr mode)))))
|
||||
(setq mode-icons-set-minor-mode-icon-alist nil))
|
||||
|
||||
(defun mode-icons-set-minor-mode-icon ()
|
||||
"Set the icon for the minor modes."
|
||||
(let (icon-spec mode-name minor)
|
||||
(dolist (mode minor-mode-alist)
|
||||
(unless (assq (car mode) mode-icons-set-minor-mode-icon-alist)
|
||||
(setq mode-name (format-mode-line mode)
|
||||
icon-spec (assoc mode-name mode-icons))
|
||||
(when icon-spec
|
||||
(setq minor (assq (car mode) minor-mode-alist))
|
||||
(when minor
|
||||
(or (assq (car mode) mode-icons-set-minor-mode-icon-alist)
|
||||
(push (copy-sequence minor) mode-icons-set-minor-mode-icon-alist))
|
||||
(setq mode-name (replace-regexp-in-string "^ " "" mode-name))
|
||||
(setcdr minor (list (concat " " (mode-icons-propertize-mode mode-name icon-spec))))))))))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode mode-icons-mode
|
||||
"Replace the name of the current major mode with an icon."
|
||||
|
@ -119,8 +144,12 @@ ICON-SPEC should be a specification from `mode-icons'."
|
|||
(if mode-icons-mode
|
||||
(progn
|
||||
(add-hook 'after-change-major-mode-hook 'mode-icons-set-current-mode-icon)
|
||||
(add-hook 'after-change-major-mode-hook 'mode-icons-set-minor-mode-icon)
|
||||
(mode-icons-set-minor-mode-icon)
|
||||
(mode-icons-set-current-mode-icon))
|
||||
(remove-hook 'after-change-major-mode-hook 'mode-icons-set-current-mode-icon)))
|
||||
(remove-hook 'after-change-major-mode-hook 'mode-icons-set-minor-mode-icon)
|
||||
(remove-hook 'after-change-major-mode-hook 'mode-icons-set-current-mode-icon)
|
||||
(mode-icons-set-minor-mode-icon-undo)))
|
||||
|
||||
(provide 'mode-icons)
|
||||
;;; mode-icons.el ends here
|
||||
|
|
Loading…
Reference in a new issue