]> git.eshelyaron.com Git - emacs.git/commit
Don't poll auto-revert files that use notification (bug#35418)
authorMattias Engdegård <mattiase@acm.org>
Wed, 24 Apr 2019 16:39:05 +0000 (18:39 +0200)
committerMattias Engdegård <mattiase@acm.org>
Tue, 30 Apr 2019 11:25:52 +0000 (13:25 +0200)
commitc61bbb4c8e7e2f2068c1cfac9a001806a1969202
tree2708a16e72d6099b676c7e50d0ef11fe11e194c3
parentf478082f9ff22ff41fbd9616ebea75757f9a0311
Don't poll auto-revert files that use notification (bug#35418)

It is a waste to periodically poll files that use change notification
in auto-revert mode; stop doing that.  If no files need polling,
turn off the periodic execution entirely to further avoid wasting power.
Use a timer to inhibit immediate reversion for some time after a
notification, for throttling.

This change does not apply to files in global-auto-revert-mode, where
polling is still necessary.  It is disabled by default, and enabled by
setting `auto-revert-avoid-polling' to non-nil.

* lisp/autorevert.el
(toplevel): Require cl-lib.
(auto-revert-avoid-polling, auto-revert--polled-buffers)
(auto-revert--need-polling-p, auto-revert--lockout-interval)
(auto-revert--lockout-timer, auto-revert--end-lockout): New.
(global-auto-revert-mode): Keep notifiers for buffers in auto-revert mode.
(auto-revert-set-timer): Use auto-revert--need-polling-p.
(auto-revert-notify-handler): Restart polling if notification stopped.
Use new lockout timer.
(auto-revert-buffers):
Use auto-revert--polled-buffers and auto-revert--need-polling-p.
(auto-revert-buffers-counter, auto-revert-buffers-counter-lockedout):
Remove.

* etc/NEWS (Changes in Specialized Modes and Packages):
Describe the new auto-revert-avoid-polling variable.

* doc/emacs/files.texi (Reverting):
Add paragraph describing auto-revert-avoid-polling.
doc/emacs/files.texi
etc/NEWS
lisp/autorevert.el