mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-27 11:09:52 +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)
|
(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
|
;; 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 'after-change-major-mode-hook #'doom-modeline-update-buffer-file-icon)
|
||||||
(add-hook 'clone-indirect-buffer-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)
|
(defun doom-modeline-buffer-file-state-icon (icon &optional text face height voffset)
|
||||||
"Displays an ICON with FACE, HEIGHT and VOFFSET.
|
"Displays an ICON with FACE, HEIGHT and VOFFSET.
|
||||||
TEXT is the alternative if it is not applicable.
|
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)
|
(lambda (_sym val op _where)
|
||||||
(when (eq op 'set)
|
(when (eq op 'set)
|
||||||
(setq buffer-read-only val)
|
(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)))))
|
(doom-modeline-update-buffer-file-state-icon)))))
|
||||||
|
|
||||||
(defvar-local doom-modeline--buffer-file-name nil)
|
(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)
|
(add-hook 'after-save-hook #'doom-modeline--update-vcs-icon)
|
||||||
(advice-add #'vc-refresh-state :after #'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)
|
(defvar-local doom-modeline--vcs-text nil)
|
||||||
(defun doom-modeline-update-vcs-text (&rest _)
|
(defun doom-modeline-update-vcs-text (&rest _)
|
||||||
"Update text of vsc state in mode-line."
|
"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-status-changed-functions #'doom-modeline-update-flycheck-icon)
|
||||||
(add-hook 'flycheck-mode-hook #'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)
|
(defvar-local doom-modeline--flycheck-text nil)
|
||||||
(defun doom-modeline-update-flycheck-text (&optional status)
|
(defun doom-modeline-update-flycheck-text (&optional status)
|
||||||
"Update flycheck text via STATUS."
|
"Update flycheck text via STATUS."
|
||||||
|
@ -789,15 +769,6 @@ mouse-2: Show help for minor mode"
|
||||||
map))))))
|
map))))))
|
||||||
(advice-add #'flymake--handle-report :after #'doom-modeline-update-flymake-icon)
|
(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)
|
(defvar-local doom-modeline--flymake-text nil)
|
||||||
(defun doom-modeline-update-flymake-text (&rest _)
|
(defun doom-modeline-update-flymake-text (&rest _)
|
||||||
"Update flymake text."
|
"Update flymake text."
|
||||||
|
|
Loading…
Reference in a new issue