aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2007-08-04 02:31:52 +0000
committerGlenn Morris2007-08-04 02:31:52 +0000
commit0917bb33fd255a6cfa8e4f4429083628d6618eb9 (patch)
tree20cbe525e33db88079b8e4914f8b9e2d3e5baccf
parenteb5c9d4f9a96c9089c3c48111fb0652d84ff187e (diff)
downloademacs-0917bb33fd255a6cfa8e4f4429083628d6618eb9.tar.gz
emacs-0917bb33fd255a6cfa8e4f4429083628d6618eb9.zip
(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.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/autorevert.el24
2 files changed, 30 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dde765a15e2..9ba954b2e6a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12007-08-04 Glenn Morris <rgm@gnu.org>
2
3 * autorevert.el (auto-revert-tail-mode): auto-revert-tail-pos is
4 zero, not nil, when the library is first loaded. Check for a file
5 that has been modified on disk.
6
7 * progmodes/cperl-mode.el (cperl-compilation-error-regexp-alist):
8 Remove duplicate defvar preventing initialization.
9 (cperl-mode): Fix compilation-error-regexp-alist-alist setting.
10
12007-08-03 Stefan Monnier <monnier@iro.umontreal.ca> 112007-08-03 Stefan Monnier <monnier@iro.umontreal.ca>
2 12
3 * diff-mode.el (diff-font-lock-keywords): Fix up false positives. 13 * diff-mode.el (diff-font-lock-keywords): Fix up false positives.
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 473e8e1976b..6c6dbd963d5 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -276,9 +276,9 @@ the list of old buffers.")
276 "Position of last known end of file.") 276 "Position of last known end of file.")
277 277
278(add-hook 'find-file-hook 278(add-hook 'find-file-hook
279 (lambda () 279 (lambda ()
280 (set (make-local-variable 'auto-revert-tail-pos) 280 (set (make-local-variable 'auto-revert-tail-pos)
281 (nth 7 (file-attributes buffer-file-name))))) 281 (nth 7 (file-attributes buffer-file-name)))))
282 282
283;; Functions: 283;; Functions:
284 284
@@ -334,9 +334,25 @@ Use `auto-revert-mode' for changes other than appends!"
334 (auto-revert-tail-mode 0) 334 (auto-revert-tail-mode 0)
335 (error "This buffer is not visiting a file")) 335 (error "This buffer is not visiting a file"))
336 (if (and (buffer-modified-p) 336 (if (and (buffer-modified-p)
337 (not auto-revert-tail-pos) ; library was loaded only after finding file 337 (zerop auto-revert-tail-pos) ; library was loaded only after finding file
338 (not (y-or-n-p "Buffer is modified, so tail offset may be wrong. Proceed? "))) 338 (not (y-or-n-p "Buffer is modified, so tail offset may be wrong. Proceed? ")))
339 (auto-revert-tail-mode 0) 339 (auto-revert-tail-mode 0)
340 ;; a-r-tail-pos stores the size of the file at the time of the
341 ;; last revert. After this package loads, it adds a
342 ;; find-file-hook to set this variable every time a file is
343 ;; loaded. If the package is loaded only _after_ visiting the
344 ;; file to be reverted, then we have no idea what the value of
345 ;; a-r-tail-pos should have been when the file was visited. If
346 ;; the file has changed on disk in the meantime, all we can do
347 ;; is offer to revert the whole thing. If you choose not to
348 ;; revert, then you might miss some output then happened
349 ;; between visiting the file and activating a-r-t-mode.
350 (and (zerop auto-revert-tail-pos)
351 (not (verify-visited-file-modtime (current-buffer)))
352 (y-or-n-p "File changed on disk, content may be missing. \
353Perform a full revert? ")
354 ;; Use this (not just revert-buffer) for point-preservation.
355 (auto-revert-handler))
340 ;; else we might reappend our own end when we save 356 ;; else we might reappend our own end when we save
341 (add-hook 'before-save-hook (lambda () (auto-revert-tail-mode 0)) nil t) 357 (add-hook 'before-save-hook (lambda () (auto-revert-tail-mode 0)) nil t)
342 (or (local-variable-p 'auto-revert-tail-pos) ; don't lose prior position 358 (or (local-variable-p 'auto-revert-tail-pos) ; don't lose prior position