Reset only once

Also make sure the minor modes are reset in the same buffer as the
major mode.
This commit is contained in:
Matthew Fidler 2016-04-06 09:52:18 -05:00
parent a059182cf3
commit 2ad7e8409e

View file

@ -462,16 +462,15 @@ specified by type 'xpm-bw."
:face face :icon icon)) :face face :icon icon))
(t (t
`(image :type ,(or (and (eq type 'jpg) 'jpeg) type) :file ,icon-path :ascent center :face ',face :icon ,icon))))) `(image :type ,(or (and (eq type 'jpg) 'jpeg) type) :file ,icon-path :ascent center :face ',face :icon ,icon)))))
((eq type 'emoji) ((and (eq type 'emoji) (setq tmp (mode-icons--get-emoji " " (list "" icon type) face)))
(setq tmp (mode-icons--get-emoji " " (list "" icon type) face))
(get-text-property 0 'display tmp)) (get-text-property 0 'display tmp))
((eq type 'ext) ;; Shouldn't get here... ;; Shouldn't get here...
(setq tmp (mode-icons--ext-available-p (list "" icon type))) ((and (eq type 'ext) (setq tmp (mode-icons--ext-available-p (list "" icon type))))
(when tmp (mode-icons-get-icon-display (concat "ext-" (downcase icon)) 'xpm-bw face))
(mode-icons-get-icon-display (concat "ext-" (downcase icon)) 'xpm-bw face)))
((and (image-type-available-p 'xpm) ((and (image-type-available-p 'xpm)
(setq tmp (mode-icons--get-font-xpm-file (list "" icon type))) (setq tmp (mode-icons--get-font-xpm-file (list "" icon type)))
(file-exists-p tmp)) (file-exists-p tmp))
(setq tmp )
(mode-icons-get-icon-display (mode-icons--get-font-xpm-file (list "" icon type) t) 'xpm-bw face)) (mode-icons-get-icon-display (mode-icons--get-font-xpm-file (list "" icon type) t) 'xpm-bw face))
(t nil)) (t nil))
mode-icons-get-icon-display)))) mode-icons-get-icon-display))))
@ -1668,19 +1667,19 @@ When ENABLE is non-nil, enable the changes to the mode line."
(setq mode-icons-get-icon-spec (make-hash-table :test 'equal) (setq mode-icons-get-icon-spec (make-hash-table :test 'equal)
mode-icons-get-icon-display (make-hash-table :test 'equal))) mode-icons-get-icon-display (make-hash-table :test 'equal)))
(defun mode-icons-reset-now ()
"Reset mode-icons icons."
(interactive)
(when (and mode-icons-mode (not (minibufferp)))
(mode-icons-set-current-mode-icon)
(mode-icons-set-minor-mode-icon)))
(defun mode-icons-reset () (defun mode-icons-reset ()
"Reset mode-icons icons." "Reset mode-icons icons."
(interactive) (interactive)
(mode-icons-reset-now) (when (and mode-icons-mode (not (minibufferp)))
;; Run twice, in case the mode turns on some minor-modes ;; Reset the major mode now.
(run-with-idle-timer 0.1 nil #'mode-icons-reset-now)) (mode-icons-set-current-mode-icon)
;; Reset the minor mode later, in case the mode turns on some
;; minor-modes.
(run-with-idle-timer
0.1 nil `(lambda()
;; Reset the minor mode icons
(with-current-buffer ,(current-buffer)
(mode-icons-set-minor-mode-icon))))))
;; (defadvice powerline-minor-modes (around mode-icons-advice (&optional face pad) activate) ;; (defadvice powerline-minor-modes (around mode-icons-advice (&optional face pad) activate)