From 418b5663200757276530cc0a90776d0bd1b1e727 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Mon, 4 May 2015 14:09:25 +0200 Subject: [PATCH] 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. --- eyebrowse.el | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/eyebrowse.el b/eyebrowse.el index 9f4d331..a512286 100644 --- a/eyebrowse.el +++ b/eyebrowse.el @@ -489,12 +489,10 @@ behaviour of `ranger`, a file manager." ;; emacs and emacsclient (eyebrowse-init) (add-hook 'after-make-frame-functions 'eyebrowse-init) - (setq mode-line-misc-info - (-snoc mode-line-misc-info - '(:eval (eyebrowse--update-mode-line))))) - (remove-hook 'after-make-frame-functions 'eyebrowse-init) - (setq mode-line-misc-info - (remove '(:eval (eyebrowse--update-mode-line)) mode-line-misc-info)))) + (unless (assoc 'eyebrowse-mode mode-line-misc-info) + (push '(eyebrowse-mode (:eval (eyebrowse--update-mode-line))) + (cdr (last mode-line-misc-info))))) + (remove-hook 'after-make-frame-functions 'eyebrowse-init))) (provide 'eyebrowse)