Improve: Watch buffer-read-only.

This commit is contained in:
Vincent Zhang 2018-12-16 18:09:26 +08:00
parent ee2aa11bbe
commit 4b22534199

View file

@ -214,6 +214,7 @@ It returns a file name which can be used directly as argument of
(declare-function symbol-overlay-assoc 'symbol-overlay) (declare-function symbol-overlay-assoc 'symbol-overlay)
(declare-function symbol-overlay-get-list 'symbol-overlay) (declare-function symbol-overlay-get-list 'symbol-overlay)
(declare-function symbol-overlay-get-symbol 'symbol-overlay) (declare-function symbol-overlay-get-symbol 'symbol-overlay)
(declare-function undo-tree-redo 'undo-tree)
(declare-function undo-tree-undo 'undo-tree) (declare-function undo-tree-undo 'undo-tree)
(declare-function window-numbering-clear-mode-line 'window-numbering) (declare-function window-numbering-clear-mode-line 'window-numbering)
(declare-function window-numbering-get-number-string 'window-numbering) (declare-function window-numbering-get-number-string 'window-numbering)
@ -798,6 +799,12 @@ buffer where knowing the current project directory is important."
(advice-add #'narrow-to-region :after #'doom-modeline-update-buffer-file-state-icon) (advice-add #'narrow-to-region :after #'doom-modeline-update-buffer-file-state-icon)
(advice-add #'widen :after #'doom-modeline-update-buffer-file-state-icon) (advice-add #'widen :after #'doom-modeline-update-buffer-file-state-icon)
(add-variable-watcher
'buffer-read-only
(lambda (_sym val op _where)
(when (and (eq op 'set) (eq val nil))
(doom-modeline-update-buffer-file-state-icon))))
(defvar-local doom-modeline--buffer-file-name nil) (defvar-local doom-modeline--buffer-file-name nil)
(defun doom-modeline-update-buffer-file-name (&rest _) (defun doom-modeline-update-buffer-file-name (&rest _)
"Update buffer file name in mode-line." "Update buffer file name in mode-line."