mirror of
https://github.com/correl/doom-modeline.git
synced 2024-11-27 11:09:52 +00:00
Ignore unhandled errors in after-change-functions.
Close #184. If an unhandled error happens in running these functions, the variable’s value remains nil. That prevents the error from happening repeatedly and making Emacs nonfunctional.
This commit is contained in:
parent
944148526f
commit
2360bd543c
1 changed files with 36 additions and 34 deletions
|
@ -264,31 +264,32 @@ Uses `all-the-icons-material' to fetch the icon."
|
||||||
(defun doom-modeline-update-buffer-file-state-icon (&rest _)
|
(defun doom-modeline-update-buffer-file-state-icon (&rest _)
|
||||||
"Update the buffer or file state in mode-line."
|
"Update the buffer or file state in mode-line."
|
||||||
(setq doom-modeline--buffer-file-state-icon
|
(setq doom-modeline--buffer-file-state-icon
|
||||||
(cond (buffer-read-only
|
(ignore-errors
|
||||||
(doom-modeline-buffer-file-state-icon
|
(cond (buffer-read-only
|
||||||
"lock"
|
(doom-modeline-buffer-file-state-icon
|
||||||
"%1*"
|
"lock"
|
||||||
'doom-modeline-warning))
|
"%1*"
|
||||||
((and buffer-file-name (buffer-modified-p)
|
'doom-modeline-warning))
|
||||||
doom-modeline-buffer-modification-icon)
|
((and buffer-file-name (buffer-modified-p)
|
||||||
(doom-modeline-buffer-file-state-icon
|
doom-modeline-buffer-modification-icon)
|
||||||
"save"
|
(doom-modeline-buffer-file-state-icon
|
||||||
"%1*"
|
"save"
|
||||||
'doom-modeline-buffer-modified))
|
"%1*"
|
||||||
((and buffer-file-name
|
'doom-modeline-buffer-modified))
|
||||||
(not (file-exists-p buffer-file-name)))
|
((and buffer-file-name
|
||||||
(doom-modeline-buffer-file-state-icon
|
(not (file-exists-p buffer-file-name)))
|
||||||
"do_not_disturb_alt"
|
(doom-modeline-buffer-file-state-icon
|
||||||
"!"
|
"do_not_disturb_alt"
|
||||||
'doom-modeline-urgent))
|
"!"
|
||||||
((or (buffer-narrowed-p)
|
'doom-modeline-urgent))
|
||||||
(and (bound-and-true-p fancy-narrow-mode)
|
((or (buffer-narrowed-p)
|
||||||
(fancy-narrow-active-p)))
|
(and (bound-and-true-p fancy-narrow-mode)
|
||||||
(doom-modeline-buffer-file-state-icon
|
(fancy-narrow-active-p)))
|
||||||
"vertical_align_center"
|
(doom-modeline-buffer-file-state-icon
|
||||||
"><"
|
"vertical_align_center"
|
||||||
'doom-modeline-warning))
|
"><"
|
||||||
(t ""))))
|
'doom-modeline-warning))
|
||||||
|
(t "")))))
|
||||||
(add-hook 'find-file-hook #'doom-modeline-update-buffer-file-state-icon)
|
(add-hook 'find-file-hook #'doom-modeline-update-buffer-file-state-icon)
|
||||||
(add-hook 'after-revert-hook #'doom-modeline-update-buffer-file-state-icon)
|
(add-hook 'after-revert-hook #'doom-modeline-update-buffer-file-state-icon)
|
||||||
(add-hook 'after-save-hook #'doom-modeline-update-buffer-file-state-icon)
|
(add-hook 'after-save-hook #'doom-modeline-update-buffer-file-state-icon)
|
||||||
|
@ -327,16 +328,17 @@ Uses `all-the-icons-material' to fetch the icon."
|
||||||
(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."
|
||||||
(setq doom-modeline--buffer-file-name
|
(setq doom-modeline--buffer-file-name
|
||||||
(save-match-data
|
(ignore-errors
|
||||||
(if buffer-file-name
|
(save-match-data
|
||||||
(doom-modeline-buffer-file-name)
|
(if buffer-file-name
|
||||||
(propertize "%b"
|
(doom-modeline-buffer-file-name)
|
||||||
'face (if (doom-modeline--active)
|
(propertize "%b"
|
||||||
'doom-modeline-buffer-file
|
'face (if (doom-modeline--active)
|
||||||
'mode-line-inactive)
|
'doom-modeline-buffer-file
|
||||||
'help-echo "Buffer name
|
'mode-line-inactive)
|
||||||
|
'help-echo "Buffer name
|
||||||
mouse-1: Previous buffer\nmouse-3: Next buffer"
|
mouse-1: Previous buffer\nmouse-3: Next buffer"
|
||||||
'local-map mode-line-buffer-identification-keymap)))))
|
'local-map mode-line-buffer-identification-keymap))))))
|
||||||
(add-hook 'find-file-hook #'doom-modeline-update-buffer-file-name)
|
(add-hook 'find-file-hook #'doom-modeline-update-buffer-file-name)
|
||||||
(add-hook 'after-revert-hook #'doom-modeline-update-buffer-file-name)
|
(add-hook 'after-revert-hook #'doom-modeline-update-buffer-file-name)
|
||||||
(add-hook 'after-save-hook #'doom-modeline-update-buffer-file-name)
|
(add-hook 'after-save-hook #'doom-modeline-update-buffer-file-name)
|
||||||
|
|
Loading…
Reference in a new issue