diff options
| author | Luc Teirlinck | 2004-04-05 01:09:37 +0000 |
|---|---|---|
| committer | Luc Teirlinck | 2004-04-05 01:09:37 +0000 |
| commit | 1f41bcba72b31a2d629896dad4cd82b1a234451c (patch) | |
| tree | da723756a3eef0090e6be6f8d09fef0762f929ae | |
| parent | 8c5fe07fa2dbf6c520728fe39a83f3a5516d786b (diff) | |
| download | emacs-1f41bcba72b31a2d629896dad4cd82b1a234451c.tar.gz emacs-1f41bcba72b31a2d629896dad4cd82b1a234451c.zip | |
(auto-revert-handler): If point (or a window point) is at the end of
the buffer, keep it there after reverting. This allows to tail a file.
Mention this in the `Commentary'.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/autorevert.el | 36 |
2 files changed, 41 insertions, 5 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8fb7dd36323..cf38476e364 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2004-04-04 Luc Teirlinck <teirllm@auburn.edu> | ||
| 2 | |||
| 3 | * autorevert.el (auto-revert-handler): If point (or a window | ||
| 4 | point) is at the end of the buffer, keep it there after | ||
| 5 | reverting. This allows to tail a file. | ||
| 6 | Mention this in the `Commentary'. | ||
| 7 | |||
| 8 | * format.el (format-write-file): Add optional argument CONFIRM | ||
| 9 | and make it behave like the analogous argument to `write-file'. | ||
| 10 | |||
| 1 | 2004-04-04 Eli Zaretskii <eliz@gnu.org> | 11 | 2004-04-04 Eli Zaretskii <eliz@gnu.org> |
| 2 | 12 | ||
| 3 | * calendar/timeclock.el (timeclock-relative) | 13 | * calendar/timeclock.el (timeclock-relative) |
diff --git a/lisp/autorevert.el b/lisp/autorevert.el index 6e74a96eff5..58bb6d29705 100644 --- a/lisp/autorevert.el +++ b/lisp/autorevert.el | |||
| @@ -44,6 +44,17 @@ | |||
| 44 | ;; seconds. The check is aborted whenever the user actually uses | 44 | ;; seconds. The check is aborted whenever the user actually uses |
| 45 | ;; Emacs. You should never even notice that this package is active | 45 | ;; Emacs. You should never even notice that this package is active |
| 46 | ;; (except that your buffers will be reverted, of course). | 46 | ;; (except that your buffers will be reverted, of course). |
| 47 | ;; | ||
| 48 | ;; After reverting a file buffer, Auto Revert Mode normally puts point | ||
| 49 | ;; at the same position that a regular manual revert would. However, | ||
| 50 | ;; there is one exception to this rule. If point is at the end of the | ||
| 51 | ;; buffer before reverting, it stays at the end. Similarly if point | ||
| 52 | ;; is displayed at the end of a file buffer in any window, it will stay | ||
| 53 | ;; at the end of the buffer in that window, even if the window is not | ||
| 54 | ;; selected. This way, you can use Auto Revert Mode to `tail' a file. | ||
| 55 | ;; Just put point at the end of the buffer and it will stay there. | ||
| 56 | ;; These rules apply to file buffers. For non-file buffers, the | ||
| 57 | ;; behavior may be mode dependent. | ||
| 47 | 58 | ||
| 48 | ;; Usage: | 59 | ;; Usage: |
| 49 | ;; | 60 | ;; |
| @@ -298,10 +309,10 @@ will use an up-to-date value of `auto-revert-interval'" | |||
| 298 | "Revert current buffer, if appropriate. | 309 | "Revert current buffer, if appropriate. |
| 299 | This is an internal function used by Auto-Revert Mode." | 310 | This is an internal function used by Auto-Revert Mode." |
| 300 | (unless (buffer-modified-p) | 311 | (unless (buffer-modified-p) |
| 301 | (let (revert) | 312 | (let ((buffer (current-buffer)) revert eob eoblist) |
| 302 | (or (and (buffer-file-name) | 313 | (or (and buffer-file-name |
| 303 | (file-readable-p (buffer-file-name)) | 314 | (file-readable-p buffer-file-name) |
| 304 | (not (verify-visited-file-modtime (current-buffer))) | 315 | (not (verify-visited-file-modtime buffer)) |
| 305 | (setq revert t)) | 316 | (setq revert t)) |
| 306 | (and (or auto-revert-mode global-auto-revert-non-file-buffers) | 317 | (and (or auto-revert-mode global-auto-revert-non-file-buffers) |
| 307 | revert-buffer-function | 318 | revert-buffer-function |
| @@ -312,7 +323,22 @@ This is an internal function used by Auto-Revert Mode." | |||
| 312 | (when (and auto-revert-verbose | 323 | (when (and auto-revert-verbose |
| 313 | (not (eq revert 'fast))) | 324 | (not (eq revert 'fast))) |
| 314 | (message "Reverting buffer `%s'." (buffer-name))) | 325 | (message "Reverting buffer `%s'." (buffer-name))) |
| 315 | (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes)) | 326 | ;; If point (or a window point) is at the end of the buffer, |
| 327 | ;; we want to keep it at the end after reverting. This allows | ||
| 328 | ;; to tail a file. | ||
| 329 | (when buffer-file-name | ||
| 330 | (setq eob (eobp)) | ||
| 331 | (walk-windows | ||
| 332 | #'(lambda (window) | ||
| 333 | (and (eq (window-buffer window) buffer) | ||
| 334 | (= (window-point window) (point-max)) | ||
| 335 | (push window eoblist))) | ||
| 336 | 'no-mini t)) | ||
| 337 | (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes) | ||
| 338 | (when buffer-file-name | ||
| 339 | (when eob (goto-char (point-max))) | ||
| 340 | (dolist (window eoblist) | ||
| 341 | (set-window-point window (point-max))))) | ||
| 316 | ;; `preserve-modes' avoids changing the (minor) modes. But we | 342 | ;; `preserve-modes' avoids changing the (minor) modes. But we |
| 317 | ;; do want to reset the mode for VC, so we do it manually. | 343 | ;; do want to reset the mode for VC, so we do it manually. |
| 318 | (when (or revert auto-revert-check-vc-info) | 344 | (when (or revert auto-revert-check-vc-info) |