Reverse mode-line-icons mode

This commit is contained in:
Matthew L. Fidler 2016-01-22 10:47:32 -06:00
parent 150f27878e
commit 220b53964f

View file

@ -129,9 +129,29 @@ ICON-SPEC should be a specification from `mode-icons'."
(mode-icons-propertize-mode mode-name icon-spec) (mode-icons-propertize-mode mode-name icon-spec)
mode-name))) mode-name)))
(defvar mode-icons-cached-mode-name nil
"Cached mode name to restore when disabling mode-icons.")
(defun mode-icons-set-mode-icon (mode) (defun mode-icons-set-mode-icon (mode)
"Set the icon for MODE." "Set the icon for MODE."
(setq mode-name (mode-icons-get-mode-icon mode))) (unless mode-icons-cached-mode-name
(set (make-local-variable 'mode-icons-cached-mode-name)
mode-name)
(setq mode-name (mode-icons-get-mode-icon mode))))
(defun mode-icons-major-mode-icons-undo ()
"Undo the mode-name changes"
(dolist (b (buffer-list))
(with-current-buffer b
(when mode-icons-cached-mode-name
(setq mode-name mode-icons-cached-mode-name
mode-icons-cached-mode-name nil)))))
(defun mode-icons-major-mode-icons ()
"Apply mode name changes on all buffers."
(dolist (b (buffer-list))
(with-current-buffer b
(mode-icons-set-current-mode-icon))))
(defun mode-icons-set-current-mode-icon () (defun mode-icons-set-current-mode-icon ()
"Set the icon for the current major mode." "Set the icon for the current major mode."
@ -177,10 +197,11 @@ ICON-SPEC should be a specification from `mode-icons'."
(add-hook 'after-change-major-mode-hook 'mode-icons-set-current-mode-icon) (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) (add-hook 'after-change-major-mode-hook 'mode-icons-set-minor-mode-icon)
(mode-icons-set-minor-mode-icon) (mode-icons-set-minor-mode-icon)
(mode-icons-set-current-mode-icon)) (mode-icons-major-mode-icons))
(remove-hook 'after-change-major-mode-hook 'mode-icons-set-minor-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) (remove-hook 'after-change-major-mode-hook 'mode-icons-set-current-mode-icon)
(mode-icons-set-minor-mode-icon-undo))) (mode-icons-set-minor-mode-icon-undo)
(mode-icons-major-mode-icons-undo)))
(provide 'mode-icons) (provide 'mode-icons)
;;; mode-icons.el ends here ;;; mode-icons.el ends here