ui/modeline: refresh +modeline-buffer-state often

This fixes issues where the buffer's modified state isn't reflected
properly in the mode-line, at the expense of a little (but acceptable
loss of) efficiency.
This commit is contained in:
Henrik Lissner 2018-10-18 13:13:35 -04:00
parent e8b6887259
commit 97f8594a71
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -402,22 +402,7 @@ Meant for `+modeline-buffer-path-function'."
;; ;;
;; Segments ;; Segments
(defun +modeline|update-on-change ()
(+modeline--set-+modeline-buffer-state)
(remove-hook 'post-command-hook #'+modeline|update-on-change t))
(defun +modeline|start-update-on-change ()
(add-hook 'post-command-hook #'+modeline|update-on-change nil t))
(add-hook 'first-change-hook #'+modeline|start-update-on-change)
(advice-add #'undo :after #'+modeline--set-+modeline-buffer-state)
(advice-add #'undo-tree-undo :after #'+modeline--set-+modeline-buffer-state)
(def-modeline-segment! +modeline-buffer-state (def-modeline-segment! +modeline-buffer-state
:on-hooks (find-file-hook
read-only-mode-hook
after-change-functions
after-save-hook
after-revert-hook)
(let* ((base (buffer-base-buffer)) (let* ((base (buffer-base-buffer))
(icon (cond (buffer-read-only (icon (cond (buffer-read-only
(all-the-icons-octicon (all-the-icons-octicon