Add option to exclude from global-mode-string

Fixes #2500
This commit is contained in:
Eivind Fonn 2015-08-01 12:52:08 +02:00 committed by syl20bnr
parent a64b6ef3d2
commit e856f6d5f0
2 changed files with 16 additions and 17 deletions

View file

@ -203,6 +203,10 @@ It runs `tabulated-list-revert-hook', then calls `tabulated-list-print'."
(if dotspacemacs-maximized-at-startup
(add-hook 'window-setup-hook 'toggle-frame-maximized))))
(defvar spacemacs--global-mode-line-excludes nil
"List of elements to exclude from the global modeline string.
These should have their own segments in the modeline.")
;; ---------------------------------------------------------------------------
;; Session
;; ---------------------------------------------------------------------------

View file

@ -1099,20 +1099,14 @@ Example: (evil-map visual \"<\" \"<gv\")"
:defer t
:init
(progn
(spacemacs|add-toggle mode-line-battery
:status fancy-battery-mode
:on
(fancy-battery-mode)
(spacemacs/mode-line-battery-remove-from-global)
:off (fancy-battery-mode -1)
:documentation "Display battery info in mode-line."
:evil-leader "tmb")
:status fancy-battery-mode
:on (fancy-battery-mode)
:off (fancy-battery-mode -1)
:documentation "Display battery info in mode-line."
:evil-leader "tmb")
(defun spacemacs/mode-line-battery-remove-from-global ()
"Remove the battery info from the `global-mode-string'."
(setq global-mode-string (delq 'fancy-battery-mode-line
global-mode-string)))
(push 'fancy-battery spacemacs--global-mode-excludes)
(defun spacemacs/mode-line-battery-percentage ()
"Return the load percentage or an empty string."
@ -1136,9 +1130,7 @@ Example: (evil-map visual \"<\" \"<gv\")"
;; basically remove all faces and properties.
(defun fancy-battery-default-mode-line ()
"Assemble a mode line string for Fancy Battery Mode."
(spacemacs/mode-line-battery-remove-from-global)
(when fancy-battery-last-status
(let* ((type (cdr (assq ?L fancy-battery-last-status)))
(percentage (spacemacs/mode-line-battery-percentage))
(time (spacemacs/mode-line-battery-time)))
@ -2871,7 +2863,8 @@ It is a string holding:
:when (bound-and-true-p nyan-mode))
(spacemacs|define-mode-line-segment global-mode
(powerline-raw global-mode-string)
(powerline-raw (-difference global-mode-string
spacemacs--global-mode-line-excludes))
:when (spacemacs//mode-line-nonempty global-mode-string))
(spacemacs|define-mode-line-segment battery
@ -2899,15 +2892,17 @@ It is a string holding:
(spacemacs|custom-flycheck-lighter ,type))))))
(spacemacs|define-mode-line-segment org-clock
(funcall spacemacs-mode-line-org-clock-format-function)
(substring-no-properties (funcall spacemacs-mode-line-org-clock-format-function))
:when (and spacemacs-mode-line-org-clock-current-taskp
(fboundp 'org-clocking-p)
(org-clocking-p)))
(push 'org-mode-line-string spacemacs--global-mode-line-excludes)
(spacemacs|define-mode-line-segment org-pomodoro
(concat "[" (nth 1 org-pomodoro-mode-line) "]")
(nth 1 org-pomodoro-mode-line)
:when (and (fboundp 'org-pomodoro-active-p)
(org-pomodoro-active-p)))
(push 'org-pomodoro-mode-line spacemacs--global-mode-line-excludes)
;; END define modeline segments