1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-17 03:10:58 -08:00

(auto-revert-handler): In `auto-revert-tail-mode',

check only for changed size.
(auto-revert-tail-handler): Get size from caller.  If the file has
shrunk, tail the whole file again (the file presumably has been
rewritten).
This commit is contained in:
David Kastrup 2007-09-30 20:26:55 +00:00
parent b616a212d4
commit fdc31e1d38
2 changed files with 20 additions and 8 deletions

View file

@ -1,5 +1,11 @@
2007-09-30 David Kastrup <dak@gnu.org> 2007-09-30 David Kastrup <dak@gnu.org>
* autorevert.el (auto-revert-handler): In `auto-revert-tail-mode',
check only for changed size.
(auto-revert-tail-handler): Get size from caller. If the file has
shrunk, tail the whole file again (the file presumably has been
rewritten).
* woman.el (woman-topic-all-completions, woman-mini-help): Fix * woman.el (woman-topic-all-completions, woman-mini-help): Fix
fallout from 2007-09-07 introduction of `dolist' when the list fallout from 2007-09-07 introduction of `dolist' when the list
actually was being manipulated in the loop. actually was being manipulated in the loop.

View file

@ -416,12 +416,16 @@ will use an up-to-date value of `auto-revert-interval'"
"Revert current buffer, if appropriate. "Revert current buffer, if appropriate.
This is an internal function used by Auto-Revert Mode." This is an internal function used by Auto-Revert Mode."
(when (or auto-revert-tail-mode (not (buffer-modified-p))) (when (or auto-revert-tail-mode (not (buffer-modified-p)))
(let* ((buffer (current-buffer)) (let* ((buffer (current-buffer)) size
(revert (revert
(or (and buffer-file-name (or (and buffer-file-name
(not (file-remote-p buffer-file-name)) (not (file-remote-p buffer-file-name))
(file-readable-p buffer-file-name) (file-readable-p buffer-file-name)
(not (verify-visited-file-modtime buffer))) (if auto-revert-tail-mode
(/= auto-revert-tail-pos
(setq size
(nth 7 (file-attributes buffer-file-name))))
(not (verify-visited-file-modtime buffer))))
(and (or auto-revert-mode (and (or auto-revert-mode
global-auto-revert-non-file-buffers) global-auto-revert-non-file-buffers)
revert-buffer-function revert-buffer-function
@ -445,7 +449,7 @@ This is an internal function used by Auto-Revert Mode."
(push window eoblist))) (push window eoblist)))
'no-mini t)) 'no-mini t))
(if auto-revert-tail-mode (if auto-revert-tail-mode
(auto-revert-tail-handler) (auto-revert-tail-handler size)
;; Bind buffer-read-only in case user has done C-x C-q, ;; Bind buffer-read-only in case user has done C-x C-q,
;; so as not to forget that. This gives undesirable results ;; so as not to forget that. This gives undesirable results
;; when the file's mode changes, but that is less common. ;; when the file's mode changes, but that is less common.
@ -460,20 +464,22 @@ This is an internal function used by Auto-Revert Mode."
(when (or revert auto-revert-check-vc-info) (when (or revert auto-revert-check-vc-info)
(vc-find-file-hook))))) (vc-find-file-hook)))))
(defun auto-revert-tail-handler () (defun auto-revert-tail-handler (size)
(let ((size (nth 7 (file-attributes buffer-file-name))) (let ((modified (buffer-modified-p))
(modified (buffer-modified-p))
(inhibit-read-only t) ; Ignore. (inhibit-read-only t) ; Ignore.
(file buffer-file-name) (file buffer-file-name)
(buffer-file-name nil)) ; Ignore that file has changed. (buffer-file-name nil)) ; Ignore that file has changed.
(when (> size auto-revert-tail-pos) (when (/= auto-revert-tail-pos size)
(run-hooks 'before-revert-hook) (run-hooks 'before-revert-hook)
(undo-boundary) (undo-boundary)
(save-restriction (save-restriction
(widen) (widen)
(save-excursion (save-excursion
(goto-char (point-max)) (goto-char (point-max))
(insert-file-contents file nil auto-revert-tail-pos size))) (insert-file-contents file nil
(and (< auto-revert-tail-pos size)
auto-revert-tail-pos)
size)))
(run-hooks 'after-revert-hook) (run-hooks 'after-revert-hook)
(undo-boundary) (undo-boundary)
(setq auto-revert-tail-pos size) (setq auto-revert-tail-pos size)