mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-23 19:19:50 +00:00
Simplify the variable watchers.
This commit is contained in:
parent
43d0956960
commit
605c5615c1
1 changed files with 19 additions and 48 deletions
|
@ -164,6 +164,25 @@
|
|||
(declare-function winum-get-number-string 'winum)
|
||||
|
||||
|
||||
;;
|
||||
;; global watchers
|
||||
;;
|
||||
|
||||
(when (>= emacs-major-version 26)
|
||||
(add-variable-watcher
|
||||
'doom-modeline-icon
|
||||
(lambda (_sym val op _where)
|
||||
(when (eq op 'set)
|
||||
(setq doom-modeline-icon val)
|
||||
(revert-buffer t t))))
|
||||
|
||||
(add-variable-watcher
|
||||
'all-the-icons-scale-factor
|
||||
(lambda (_sym val op _where)
|
||||
(when (eq op 'set)
|
||||
(setq all-the-icons-scale-factor val)
|
||||
(revert-buffer t t)))))
|
||||
|
||||
;;
|
||||
;; buffer information
|
||||
;;
|
||||
|
@ -205,14 +224,6 @@ buffer where knowing the current project directory is important."
|
|||
(add-hook 'after-change-major-mode-hook #'doom-modeline-update-buffer-file-icon)
|
||||
(add-hook 'clone-indirect-buffer-hook #'doom-modeline-update-buffer-file-icon)
|
||||
|
||||
(when (>= emacs-major-version 26)
|
||||
(add-variable-watcher
|
||||
'all-the-icons-scale-factor
|
||||
(lambda (_sym val op _where)
|
||||
(when (eq op 'set)
|
||||
(setq all-the-icons-scale-factor val)
|
||||
(doom-modeline-update-buffer-file-icon)))))
|
||||
|
||||
(defun doom-modeline-buffer-file-state-icon (icon &optional text face height voffset)
|
||||
"Displays an ICON with FACE, HEIGHT and VOFFSET.
|
||||
TEXT is the alternative if it is not applicable.
|
||||
|
@ -275,20 +286,6 @@ Uses `all-the-icons-material' to fetch the icon."
|
|||
(lambda (_sym val op _where)
|
||||
(when (eq op 'set)
|
||||
(setq buffer-read-only val)
|
||||
(doom-modeline-update-buffer-file-state-icon))))
|
||||
|
||||
(add-variable-watcher
|
||||
'doom-modeline-icon
|
||||
(lambda (_sym val op _where)
|
||||
(when (eq op 'set)
|
||||
(setq doom-modeline-icon val)
|
||||
(doom-modeline-update-buffer-file-state-icon))))
|
||||
|
||||
(add-variable-watcher
|
||||
'all-the-icons-scale-factor
|
||||
(lambda (_sym val op _where)
|
||||
(when (eq op 'set)
|
||||
(setq all-the-icons-scale-factor val)
|
||||
(doom-modeline-update-buffer-file-state-icon)))))
|
||||
|
||||
(defvar-local doom-modeline--buffer-file-name nil)
|
||||
|
@ -532,14 +529,6 @@ Uses `all-the-icons-octicon' to fetch the icon."
|
|||
(add-hook 'after-save-hook #'doom-modeline--update-vcs-icon)
|
||||
(advice-add #'vc-refresh-state :after #'doom-modeline--update-vcs-icon)
|
||||
|
||||
(when (>= emacs-major-version 26)
|
||||
(add-variable-watcher
|
||||
'doom-modeline-icon
|
||||
(lambda (_sym val op _where)
|
||||
(when (eq op 'set)
|
||||
(setq doom-modeline-icon val)
|
||||
(doom-modeline--update-vcs-icon)))))
|
||||
|
||||
(defvar-local doom-modeline--vcs-text nil)
|
||||
(defun doom-modeline-update-vcs-text (&rest _)
|
||||
"Update text of vsc state in mode-line."
|
||||
|
@ -654,15 +643,6 @@ mouse-2: Show help for minor mode")
|
|||
(add-hook 'flycheck-status-changed-functions #'doom-modeline-update-flycheck-icon)
|
||||
(add-hook 'flycheck-mode-hook #'doom-modeline-update-flycheck-icon)
|
||||
|
||||
(when (>= emacs-major-version 26)
|
||||
(add-variable-watcher
|
||||
'doom-modeline-icon
|
||||
(lambda (_sym val op _where)
|
||||
(when (eq op 'set)
|
||||
(setq doom-modeline-icon val)
|
||||
(when (bound-and-true-p flycheck-mode)
|
||||
(flycheck-buffer))))))
|
||||
|
||||
(defvar-local doom-modeline--flycheck-text nil)
|
||||
(defun doom-modeline-update-flycheck-text (&optional status)
|
||||
"Update flycheck text via STATUS."
|
||||
|
@ -789,15 +769,6 @@ mouse-2: Show help for minor mode"
|
|||
map))))))
|
||||
(advice-add #'flymake--handle-report :after #'doom-modeline-update-flymake-icon)
|
||||
|
||||
(when (>= emacs-major-version 26)
|
||||
(add-variable-watcher
|
||||
'doom-modeline-icon
|
||||
(lambda (_sym val op _where)
|
||||
(when (eq op 'set)
|
||||
(setq doom-modeline-icon val)
|
||||
(when (bound-and-true-p flymake-mode)
|
||||
(flymake-start))))))
|
||||
|
||||
(defvar-local doom-modeline--flymake-text nil)
|
||||
(defun doom-modeline-update-flymake-text (&rest _)
|
||||
"Update flymake text."
|
||||
|
|
Loading…
Reference in a new issue