diff options
| author | Dima Kogan | 2015-02-19 21:36:03 +0100 |
|---|---|---|
| committer | Michael Albinus | 2015-02-19 21:36:03 +0100 |
| commit | 12ab9571935d79c69ffab0fb1ea3f6e20f475860 (patch) | |
| tree | daa86172287451c050e40f50b6dc33c68614fe36 | |
| parent | d4ed798d2598a914b1313e58acaff5b66c487318 (diff) | |
| download | emacs-12ab9571935d79c69ffab0fb1ea3f6e20f475860.tar.gz emacs-12ab9571935d79c69ffab0fb1ea3f6e20f475860.zip | |
auto-revert-mode can now revert immediately in response to a change event
Fixes: debbugs:18958
* autorevert.el (auto-revert-buffers-counter)
(auto-revert-buffers-counter-lockedout): New variables.
(auto-revert-buffers): Increase `auto-revert-buffers-counter'.
(auto-revert-notify-handler): Apply `auto-revert-handler' if not
suppressed by lockout.
| -rw-r--r-- | lisp/ChangeLog | 16 | ||||
| -rw-r--r-- | lisp/autorevert.el | 36 |
2 files changed, 48 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cdcb340614a..3d15b4095bf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2015-02-19 Dima Kogan <dima@secretsauce.net> | ||
| 2 | |||
| 3 | * autorevert.el (auto-revert-buffers-counter) | ||
| 4 | (auto-revert-buffers-counter-lockedout): New variables. | ||
| 5 | (auto-revert-buffers): Increase `auto-revert-buffers-counter'. | ||
| 6 | (auto-revert-notify-handler): Apply `auto-revert-handler' if not | ||
| 7 | suppressed by lockout. (Bug#18958) | ||
| 8 | |||
| 1 | 2015-02-19 Stefan Monnier <monnier@iro.umontreal.ca> | 9 | 2015-02-19 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 10 | ||
| 3 | * emacs-lisp/eieio-opt.el (eieio-help-class): `eieio-class-parents' | 11 | * emacs-lisp/eieio-opt.el (eieio-help-class): `eieio-class-parents' |
| @@ -29,7 +37,7 @@ | |||
| 29 | * files.el (find-alternate-file, abort-if-file-too-large, write-file) | 37 | * files.el (find-alternate-file, abort-if-file-too-large, write-file) |
| 30 | (set-visited-file-name): | 38 | (set-visited-file-name): |
| 31 | * emacs-lisp/lisp.el (kill-backward-up-list): | 39 | * emacs-lisp/lisp.el (kill-backward-up-list): |
| 32 | Use user-error instead of error. (Bug#14480) | 40 | Use user-error instead of error. (Bug#14480) |
| 33 | 41 | ||
| 34 | 2015-02-18 Stefan Monnier <monnier@iro.umontreal.ca> | 42 | 2015-02-18 Stefan Monnier <monnier@iro.umontreal.ca> |
| 35 | 43 | ||
| @@ -45,12 +53,12 @@ | |||
| 45 | * emacs-lisp/easy-mmode.el (define-minor-mode): Process macro | 53 | * emacs-lisp/easy-mmode.el (define-minor-mode): Process macro |
| 46 | arguments correctly. (Bug#19685) | 54 | arguments correctly. (Bug#19685) |
| 47 | (define-minor-mode): Clarify docstring. | 55 | (define-minor-mode): Clarify docstring. |
| 48 | Clarify mode switch messages for minor modes. (Bug#19690) | 56 | Clarify mode switch messages for minor modes. (Bug#19690) |
| 49 | 57 | ||
| 50 | 2015-02-16 Kelly Dean <kelly@prtime.org> | 58 | 2015-02-16 Kelly Dean <kelly@prtime.org> |
| 51 | 59 | ||
| 52 | * emacs-lisp/package-x.el (package-upload-buffer-internal): | 60 | * emacs-lisp/package-x.el (package-upload-buffer-internal): |
| 53 | Create valid tar files. (Bug#19536) | 61 | Create valid tar files. (Bug#19536) |
| 54 | 62 | ||
| 55 | 2015-02-16 Kelly Dean <kelly@prtime.org> | 63 | 2015-02-16 Kelly Dean <kelly@prtime.org> |
| 56 | 64 | ||
| @@ -60,7 +68,7 @@ | |||
| 60 | 2015-02-16 Kelly Dean <kelly@prtime.org> | 68 | 2015-02-16 Kelly Dean <kelly@prtime.org> |
| 61 | 69 | ||
| 62 | * help-mode.el (help-do-xref): Prevent duplicated display of Info | 70 | * help-mode.el (help-do-xref): Prevent duplicated display of Info |
| 63 | buffer, and prevent interference with existing buffer. (Bug#13190) | 71 | buffer, and prevent interference with existing buffer. (Bug#13190) |
| 64 | 72 | ||
| 65 | 2015-02-16 Fabián Ezequiel Gallina <fgallina@gnu.org> | 73 | 2015-02-16 Fabián Ezequiel Gallina <fgallina@gnu.org> |
| 66 | 74 | ||
diff --git a/lisp/autorevert.el b/lisp/autorevert.el index 8c8c6174c47..02cef24f2aa 100644 --- a/lisp/autorevert.el +++ b/lisp/autorevert.el | |||
| @@ -531,6 +531,30 @@ will use an up-to-date value of `auto-revert-interval'" | |||
| 531 | ;; Fallback to file checks. | 531 | ;; Fallback to file checks. |
| 532 | (set (make-local-variable 'auto-revert-use-notify) nil)))) | 532 | (set (make-local-variable 'auto-revert-use-notify) nil)))) |
| 533 | 533 | ||
| 534 | ;; If we have file notifications, we want to update the auto-revert buffers | ||
| 535 | ;; immediately when a notification occurs. Since file updates can happen very | ||
| 536 | ;; often, we want to skip some revert operations so that we don't spend all our | ||
| 537 | ;; time reverting the buffer. | ||
| 538 | ;; | ||
| 539 | ;; We do this by reverting immediately in response to the first in a flurry of | ||
| 540 | ;; notifications. We suppress subsequent notifications until the next time | ||
| 541 | ;; `auto-revert-buffers' is called (this happens on a timer with a period set by | ||
| 542 | ;; `auto-revert-interval'). | ||
| 543 | (defvar auto-revert-buffers-counter 1 | ||
| 544 | "Incremented each time `auto-revert-buffers' is called") | ||
| 545 | (defvar-local auto-revert-buffers-counter-lockedout 0 | ||
| 546 | "Buffer-local value to indicate whether we should immediately | ||
| 547 | update the buffer on a notification event or not. If | ||
| 548 | |||
| 549 | (= auto-revert-buffers-counter-lockedout | ||
| 550 | auto-revert-buffers-counter) | ||
| 551 | |||
| 552 | then the updates are locked out, and we wait until the next call | ||
| 553 | of `auto-revert-buffers' to revert the buffer. If no lockout is | ||
| 554 | present, then we revert immediately and set the lockout, so that | ||
| 555 | no more reverts are possible until the next call of | ||
| 556 | `auto-revert-buffers'") | ||
| 557 | |||
| 534 | (defun auto-revert-notify-handler (event) | 558 | (defun auto-revert-notify-handler (event) |
| 535 | "Handle an EVENT returned from file notification." | 559 | "Handle an EVENT returned from file notification." |
| 536 | (with-demoted-errors | 560 | (with-demoted-errors |
| @@ -566,6 +590,14 @@ will use an up-to-date value of `auto-revert-interval'" | |||
| 566 | (file-name-nondirectory buffer-file-name))))) | 590 | (file-name-nondirectory buffer-file-name))))) |
| 567 | ;; Mark buffer modified. | 591 | ;; Mark buffer modified. |
| 568 | (setq auto-revert-notify-modified-p t) | 592 | (setq auto-revert-notify-modified-p t) |
| 593 | |||
| 594 | ;; Revert the buffer now if we're not locked out | ||
| 595 | (when (/= auto-revert-buffers-counter-lockedout | ||
| 596 | auto-revert-buffers-counter) | ||
| 597 | (auto-revert-handler) | ||
| 598 | (setq auto-revert-buffers-counter-lockedout | ||
| 599 | auto-revert-buffers-counter)) | ||
| 600 | |||
| 569 | ;; No need to check other buffers. | 601 | ;; No need to check other buffers. |
| 570 | (cl-return))))))))) | 602 | (cl-return))))))))) |
| 571 | 603 | ||
| @@ -686,6 +718,10 @@ are checked first the next time this function is called. | |||
| 686 | This function is also responsible for removing buffers no longer in | 718 | This function is also responsible for removing buffers no longer in |
| 687 | Auto-Revert mode from `auto-revert-buffer-list', and for canceling | 719 | Auto-Revert mode from `auto-revert-buffer-list', and for canceling |
| 688 | the timer when no buffers need to be checked." | 720 | the timer when no buffers need to be checked." |
| 721 | |||
| 722 | (setq auto-revert-buffers-counter | ||
| 723 | (1+ auto-revert-buffers-counter)) | ||
| 724 | |||
| 689 | (save-match-data | 725 | (save-match-data |
| 690 | (let ((bufs (if global-auto-revert-mode | 726 | (let ((bufs (if global-auto-revert-mode |
| 691 | (buffer-list) | 727 | (buffer-list) |