summaryrefslogtreecommitdiff
path: root/lisp/autorevert.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2007-08-04 02:35:10 +0000
committerGlenn Morris <rgm@gnu.org>2007-08-04 02:35:10 +0000
commitb1ab8c381057452c4ad8010c4da8be2ddfeed1cf (patch)
tree57aab4795e4fa7759538e55be39f36d2683876c1 /lisp/autorevert.el
parente9bfd3a3f9953520b99e4dac4cc0e59b6a9fc83c (diff)
downloademacs-b1ab8c381057452c4ad8010c4da8be2ddfeed1cf.tar.gz
(auto-revert-tail-mode): auto-revert-tail-pos is zero, not nil, when
the library is first loaded. Check for a file that has been modified on disk.
Diffstat (limited to 'lisp/autorevert.el')
-rw-r--r--lisp/autorevert.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 1f4ebc57b19..cad94e789d6 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -337,6 +337,22 @@ Use `auto-revert-mode' for changes other than appends!"
(not 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-handler))
;; 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