Rework modeline init

First of all, if you add a list to the modeline which has a first
element that's a normal symbol, the symbol is evaluated and the rest
only if it turns out to be truthy.  That allows one to use
`eyebrowse-mode` to display the indicator only if the mode is active, so
no more removing is necessary to stop displaying it.

The other change makes sure that nothing, be it enabling the mode a
second time non-interactively or loading a theme (see #29 for further
details) can result in a duplicated indicator.
This commit is contained in:
Vasilij Schneidermann
2015-05-04 14:09:25 +02:00
parent 2d00828139
commit 418b566320

View File

@ -489,12 +489,10 @@ behaviour of `ranger`, a file manager."
;; emacs and emacsclient ;; emacs and emacsclient
(eyebrowse-init) (eyebrowse-init)
(add-hook 'after-make-frame-functions 'eyebrowse-init) (add-hook 'after-make-frame-functions 'eyebrowse-init)
(setq mode-line-misc-info (unless (assoc 'eyebrowse-mode mode-line-misc-info)
(-snoc mode-line-misc-info (push '(eyebrowse-mode (:eval (eyebrowse--update-mode-line)))
'(:eval (eyebrowse--update-mode-line))))) (cdr (last mode-line-misc-info)))))
(remove-hook 'after-make-frame-functions 'eyebrowse-init) (remove-hook 'after-make-frame-functions 'eyebrowse-init)))
(setq mode-line-misc-info
(remove '(:eval (eyebrowse--update-mode-line)) mode-line-misc-info))))
(provide 'eyebrowse) (provide 'eyebrowse)