mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-27 10:54:40 +00:00
Make global-auto-revert-non-file-buffers work better
* lisp/autorevert.el (global-auto-revert-mode): Always switch on the non-file tracking. (auto-revert--global-possibly-adopt-current-buffer): New function to respect dynamically changing `global-auto-revert-non-file-buffers'.
This commit is contained in:
parent
e000a7ab10
commit
8a8319140c
@ -521,13 +521,12 @@ specifies in the mode line."
|
||||
;; To track non-file buffers, we need to listen in to buffer
|
||||
;; creation in general. Listening to major-mode changes is
|
||||
;; suitable, since we then know whether it's a mode that is tracked.
|
||||
(when global-auto-revert-non-file-buffers
|
||||
(add-hook 'after-change-major-mode-hook
|
||||
#'auto-revert--global-adopt-current-buffer))
|
||||
(add-hook 'after-change-major-mode-hook
|
||||
#'auto-revert--global-possibly-adopt-current-buffer)
|
||||
(auto-revert-buffers))
|
||||
;; Turn global-auto-revert-mode OFF.
|
||||
(remove-hook 'after-change-major-mode-hook
|
||||
#'auto-revert--global-adopt-current-buffer)
|
||||
#'auto-revert--global-possibly-adopt-current-buffer)
|
||||
(remove-hook 'find-file-hook #'auto-revert--global-adopt-current-buffer)
|
||||
(dolist (buf (buffer-list))
|
||||
(with-current-buffer buf
|
||||
@ -556,6 +555,12 @@ specifies in the mode line."
|
||||
nil)))
|
||||
(setq auto-revert--global-mode t)))
|
||||
|
||||
(defun auto-revert--global-possibly-adopt-current-buffer ()
|
||||
"Consider tracking current buffer in a running Global Auto-Revert mode.
|
||||
This tracks buffers if `global-auto-revert-non-file-buffers' is non-nil."
|
||||
(when global-auto-revert-non-file-buffers
|
||||
(auto-revert--global-adopt-current-buffer)))
|
||||
|
||||
(defun auto-revert--global-adopt-current-buffer ()
|
||||
"Consider tracking current buffer in a running Global Auto-Revert mode."
|
||||
(auto-revert--global-add-current-buffer)
|
||||
|
Loading…
Reference in New Issue
Block a user