Variable: auto-revert-tail-mode-hook
auto-revert-tail-mode-hook is a customizable variable defined in
autorevert.el.gz.
Value
nil
Documentation
Hook run after entering or leaving auto-revert-tail-mode(var)/auto-revert-tail-mode(fun).
No problems result if this variable is not bound.
add-hook automatically binds it. (This is true for all hook variables.)
Source Code
;; Defined in /usr/src/emacs/lisp/autorevert.el.gz
;;;###autoload
(define-minor-mode auto-revert-tail-mode
"Toggle reverting tail of buffer when the file grows.
When Auto-Revert Tail Mode is enabled, the tail of the file is
constantly followed, as with the shell command `tail -f'. This
means that whenever the file grows on disk (presumably because
some background process is appending to it from time to time),
this is reflected in the current buffer.
You can edit the buffer and turn this mode off and on again as
you please. But make sure the background process has stopped
writing before you save the file!
When a buffer is reverted, a message is generated. This can be
suppressed by setting `auto-revert-verbose' to nil.
Use `auto-revert-mode' for changes other than appends!"
:group 'find-file :lighter auto-revert-tail-mode-text
(when auto-revert-tail-mode
(unless buffer-file-name
(auto-revert-tail-mode 0)
(error "This buffer is not visiting a file"))
(if (and (buffer-modified-p)
(zerop auto-revert-tail-pos) ; library was loaded only after finding file
(not (y-or-n-p "Buffer is modified, so tail offset may be wrong. Proceed? ")))
(auto-revert-tail-mode 0)
;; a-r-tail-pos stores the size of the file at the time of the
;; last revert. After this package loads, it adds a
;; find-file-hook to set this variable every time a file is
;; loaded. If the package is loaded only _after_ visiting the
;; file to be reverted, then we have no idea what the value of
;; a-r-tail-pos should have been when the file was visited. If
;; the file has changed on disk in the meantime, all we can do
;; is offer to revert the whole thing. If you choose not to
;; revert, then you might miss some output then happened
;; between visiting the file and activating a-r-t-mode.
(and (zerop auto-revert-tail-pos)
(not (verify-visited-file-modtime (current-buffer)))
(y-or-n-p "File changed on disk, content may be missing. \
Perform a full revert? ")
;; Use this (not just revert-buffer) for point-preservation.
(auto-revert-buffers))
;; else we might reappend our own end when we save
(add-hook 'before-save-hook (lambda () (auto-revert-tail-mode 0)) nil t)
(or (local-variable-p 'auto-revert-tail-pos) ; don't lose prior position
(setq-local auto-revert-tail-pos
(file-attribute-size
(file-attributes buffer-file-name))))
;; let auto-revert-mode set up the mechanism for us if it isn't already
(or auto-revert-mode
(let ((auto-revert-tail-mode t))
(auto-revert-mode 1)))
(setq auto-revert-mode nil))))