mirror of
https://github.com/vale981/doom-modeline
synced 2025-03-05 09:21:38 -05:00
[Refactor] Restore to original format while disabling.
This commit is contained in:
parent
462c3a617e
commit
f963cbb42f
2 changed files with 17 additions and 12 deletions
|
@ -1045,6 +1045,17 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
|
|||
((floatp height) (* height (frame-char-height)))
|
||||
(t (frame-char-height)))))))
|
||||
|
||||
(defun doom-modeline--original-value (sym)
|
||||
"Return the original value for SYM, if any.
|
||||
|
||||
If SYM has an original value, return it in a list. Return nil
|
||||
otherwise."
|
||||
(let* ((orig-val-expr (get sym 'standard-value)))
|
||||
(when (consp orig-val-expr)
|
||||
(ignore-errors
|
||||
(list
|
||||
(eval (car orig-val-expr)))))))
|
||||
|
||||
(defun doom-modeline-add-variable-watcher (symbol watch-function)
|
||||
"Cause WATCH-FUNCTION to be called when SYMBOL is set if possible.
|
||||
|
||||
|
|
|
@ -232,11 +232,6 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
|
|||
;; Minor mode
|
||||
;;
|
||||
|
||||
(defvar doom-modeline--default-format mode-line-format
|
||||
"Storage for the default `mode-line-format'.
|
||||
|
||||
So it can be restored when `doom-modeline-mode' is disabled.")
|
||||
|
||||
(defvar doom-modeline-mode-map (make-sparse-keymap))
|
||||
|
||||
;; Suppress warnings
|
||||
|
@ -284,15 +279,14 @@ So it can be restored when `doom-modeline-mode' is disabled.")
|
|||
(advice-add #'helm-display-mode-line :after #'doom-modeline-set-helm-modeline))
|
||||
(progn
|
||||
;; Restore mode-line
|
||||
(setq-default mode-line-format doom-modeline--default-format)
|
||||
(dolist (buf (buffer-list))
|
||||
(with-current-buffer buf
|
||||
(setq mode-line-format doom-modeline--default-format)))
|
||||
(let ((original-format (doom-modeline--original-value 'mode-line-format)))
|
||||
(setq-default mode-line-format original-format)
|
||||
(dolist (buf (buffer-list))
|
||||
(with-current-buffer buf
|
||||
(setq mode-line-format original-format))))
|
||||
|
||||
;; For two-column editing
|
||||
(setq 2C-mode-line-format
|
||||
'("-%*- %15b --" (-3 . "%p") "--%[(" mode-name
|
||||
minor-mode-alist "%n" mode-line-process ")%]%-"))
|
||||
(setq 2C-mode-line-format (doom-modeline--original-value '2C-mode-line-format))
|
||||
|
||||
;; Remove hooks
|
||||
(remove-hook 'Info-mode-hook #'doom-modeline-set-info-modeline)
|
||||
|
|
Loading…
Add table
Reference in a new issue