Variable: global-auto-revert-mode
global-auto-revert-mode is a customizable variable defined in
autorevert.el.gz.
Value
nil
Documentation
Non-nil if Global Auto-Revert mode is enabled.
See the global-auto-revert-mode(var)/global-auto-revert-mode(fun) command
for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node (emacs)Easy Customization)
or call the function global-auto-revert-mode(var)/global-auto-revert-mode(fun).
Probably introduced at or before Emacs version 25.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/autorevert.el.gz
;;;###autoload
(define-minor-mode global-auto-revert-mode
"Toggle Global Auto-Revert Mode.
Global Auto-Revert Mode is a global minor mode that reverts any
buffer associated with a file when the file changes on disk. Use
`auto-revert-mode' to revert a particular buffer.
If `global-auto-revert-non-file-buffers' is non-nil, this mode
may also revert some non-file buffers, as described in the
documentation of that variable. It ignores buffers with modes
matching `global-auto-revert-ignore-modes', and buffers with a
non-nil value of `global-auto-revert-ignore-buffer'.
When a buffer is reverted, a message is generated. This can be
suppressed by setting `auto-revert-verbose' to nil.
This function calls the hook `global-auto-revert-mode-hook'.
It displays the text that `global-auto-revert-mode-text'
specifies in the mode line."
:global t :group 'auto-revert :lighter global-auto-revert-mode-text
(auto-revert-set-timer)
(if global-auto-revert-mode
;; Turn global-auto-revert-mode ON.
(progn
(dolist (buf (buffer-list))
(with-current-buffer buf
(auto-revert--global-add-current-buffer)))
;; Make sure future buffers are added as well.
(add-hook 'find-file-hook #'auto-revert--global-adopt-current-buffer)
;; 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.
(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-possibly-adopt-current-buffer)
(remove-hook 'find-file-hook #'auto-revert--global-adopt-current-buffer)
(dolist (buf (buffer-list))
(with-current-buffer buf
(when auto-revert--global-mode
(setq auto-revert--global-mode nil)
(when (and auto-revert-notify-watch-descriptor
(not (or auto-revert-mode auto-revert-tail-mode)))
(auto-revert-notify-rm-watch)))))))