From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#35418: [PATCH] Don't poll auto-revert files that use notification Date: Mon, 29 Apr 2019 13:06:50 +0200 Message-ID: References: <83sgu71b91.fsf@gnu.org> <74CB5185-5DA1-4786-BD9C-9EEB3D43B3C1@acm.org> <83o94uz9h2.fsf@gnu.org> <875zqzssql.fsf@gmx.de> <83d0l7v193.fsf@gnu.org> <86EFE367-90FF-4786-BC91-FC28FAF38A4E@acm.org> <877ebdqmbj.fsf@gmx.de> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_63FF422E-39C5-4384-BCDA-EBD6A6EE7DB4" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="197852"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 35418@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 29 13:07:18 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hL47w-000pIR-8O for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Apr 2019 13:07:16 +0200 Original-Received: from localhost ([127.0.0.1]:55803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hL47v-0004XJ-6s for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Apr 2019 07:07:15 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hL47j-0004XA-Pq for bug-gnu-emacs@gnu.org; Mon, 29 Apr 2019 07:07:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hL47i-0007iK-H6 for bug-gnu-emacs@gnu.org; Mon, 29 Apr 2019 07:07:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hL47i-0007i2-AI for bug-gnu-emacs@gnu.org; Mon, 29 Apr 2019 07:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hL47i-0005Wc-12 for bug-gnu-emacs@gnu.org; Mon, 29 Apr 2019 07:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 29 Apr 2019 11:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35418 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 35418-submit@debbugs.gnu.org id=B35418.155653601921230 (code B ref 35418); Mon, 29 Apr 2019 11:07:01 +0000 Original-Received: (at 35418) by debbugs.gnu.org; 29 Apr 2019 11:06:59 +0000 Original-Received: from localhost ([127.0.0.1]:38519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hL47e-0005WL-P2 for submit@debbugs.gnu.org; Mon, 29 Apr 2019 07:06:59 -0400 Original-Received: from mail83c50.megamailservers.eu ([91.136.10.93]:47434 helo=mail18c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hL47b-0005W8-Gw for 35418@debbugs.gnu.org; Mon, 29 Apr 2019 07:06:57 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1556536013; bh=zmvOhTgtItiyywVFSzTJ8egmGKY0aT/WSsg5nchDyQ0=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=AtnxNO5sXhtlaWffNMJ6TRTrHhy9Ofv2FNFdFyHcIEJHcmvuEoVNdN16cGu7W9lhM X8KPh59BMiRQwcbS7HiT3oUuXfgebHCHf0brtGGW9XE2+fE0/4+wfIcAyY5mHDwWsq MhyGWTzg83PJweZEL1Y/OAp7132/HDRwRq/Sa9Yo= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.1.64] (c-e636e253.032-75-73746f71.bbcust.telenor.se [83.226.54.230]) (authenticated bits=0) by mail18c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x3TB6pFr006946; Mon, 29 Apr 2019 11:06:52 +0000 In-Reply-To: <877ebdqmbj.fsf@gmx.de> X-Mailer: Apple Mail (2.3445.104.8) X-CTCH-RefID: str=0001.0A0B0207.5CC6DACD.0038, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=S7n3PrkP c=1 sm=1 tr=0 a=M+GU/qJco4WXjv8D6jB2IA==:117 a=M+GU/qJco4WXjv8D6jB2IA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=IBGAhrbTSAdScrTBqPcA:9 a=d9utRVh_FFTiS5Pj:21 a=JBt6rzN59fMSCSbz:21 a=CjuIK1q_8ugA:10 a=09XKyqVNrCcG81hL1tgA:9 a=B2y7HmGcmWMA:10 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:158421 Archived-At: --Apple-Mail=_63FF422E-39C5-4384-BCDA-EBD6A6EE7DB4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 29 apr. 2019 kl. 09.53 skrev Michael Albinus : >=20 >> Here is an updated patch. There is a new variable, >> `auto-revert-always-poll', which is t by default. >> There is also a note in etc/NEWS. Does it merit a mention in the = manual as well? >=20 > Yes, please. There is now a paragraph added to the manual. By the way, the organisation of this part of the manual could be = improved -- don't you agree? There is a section called Reverting, which starts about `revert-buffer' = but then goes on to talk about the auto-revert, global-auto-revert and = auto-revert-tail modes and details about the mechanisms behind them: = polling, intervals, notification. Then there is a (sibling) section called Autorevert, which despite its = name only talks about auto-reverting non-file buffers. This can be reorganised in various ways. We could move all autorevert = text to a sibling node to Reverting, or to one or more child nodes. In = any case, such text shuffling should not be part of this patch. > I believe it shall be said, that this user option does not compete = with > `auto-revert-use-notify'. Rather, polling is used additionally to file > notification. When `auto-revert-use-notify' is nil, the value of > `auto-revert-always-poll' doesn't matter; there will always be = polling. Good point; the doc string has been clarified. > Saying this, the user option might need another name. What about > `auto-revert-also-poll'? Naming is always hard. I started with `auto-revert-avoid-polling' but = wanted to avoid a negative name. I tried `auto-revert-also-poll' but it somehow didn't feel right; not = all buffers use notification. It is nothing I feel strongly about, so if you do prefer that name I'll = change, but I've kept the original name in the patch for now. >> +(defvar auto-revert--polled-buffers () >> + "List of buffers in Auto-Revert Mode that must be polled. >> +It contains the buffers in `auto-revert-buffer-list' whose >> +`auto-revert-notify-watch-descriptor' is nil.") >=20 > Is this variable needed? It is used only once in > `auto-revert--need-polling', and it could be computed easily by It is also used in `auto-revert-buffers', but you are quite right that = it could be a function. I decided to maintain it as a derived state = because it felt silly to replace O(1) code with O(N), and the invariant = is clear enough (stated in its doc string). (Some of the places where = the variable is updated are O(N) but less frequently executed.) I can replace it with a function if you want, but the code didn't seem = to gain much from doing so. > `auto-revert--need-polling' shall always return the buffer list, also = for > `global-auto-revert-mode'. Sorry, it was meant as a predicate and is only used as such. Clarified by renaming it to `auto-revert--need-polling-p'. Thank you very much for your review! Updated patch attached. --Apple-Mail=_63FF422E-39C5-4384-BCDA-EBD6A6EE7DB4 Content-Disposition: attachment; filename=0001-Don-t-poll-auto-revert-files-that-use-notification.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Don-t-poll-auto-revert-files-that-use-notification.patch" Content-Transfer-Encoding: quoted-printable =46rom=2017a48cc4a106112830b1399fff2966bd16b8c23c=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Wed,=2024=20Apr=202019=2018:39:05=20+0200=0A= Subject:=20[PATCH]=20Don't=20poll=20auto-revert=20files=20that=20use=20= notification=0A=0AIt=20is=20a=20waste=20to=20periodically=20poll=20files=20= that=20use=20change=20notification=0Ain=20auto-revert=20mode;=20stop=20= doing=20that.=20=20If=20no=20files=20need=20polling,=0Aturn=20off=20the=20= periodic=20execution=20entirely=20to=20further=20avoid=20wasting=20= power.=0AUse=20a=20timer=20to=20inhibit=20immediate=20reversion=20for=20= some=20time=20after=20a=0Anotification.=0A=0AThis=20change=20does=20not=20= apply=20to=20files=20in=20global-auto-revert-mode,=20where=0Apolling=20= is=20still=20necessary.=20=20It=20is=20disabled=20by=20default,=20and=20= enabled=20by=0Asetting=20`auto-revert-always-poll'=20to=20nil.=0A=0A*=20= lisp/autorevert.el=0A(auto-revert--polled-buffers,=20= auto-revert--lockout-interval,=0Aauto-revert--lockout-timer,=20= auto-revert--end-lockout,=20auto-revert-always-poll,=0A= auto-revert--need-polling-p):=20New.=0A= (auto-revert-remove-current-buffer,=20auto-revert-mode,=0A= global-auto-revert-mode,=20auto-revert-set-timer,=0A= auto-revert-notify-add-watch,=20auto-revert-buffers,=0A= auto-revert-notify-handler):=20Maintain=20and=20use=20= auto-revert--polled-buffers.=0AHonour=20new=20lockout=20timer.=20=20= Start=20lockout=20timer=20if=20necessary.=0AMaintain=20and=20use=20= auto-revert--polled-buffers.=0A(auto-revert-buffers-counter,=20= auto-revert-buffers-counter-lockedout):=20Remove.=0A=0A*=20etc/NEWS=20= (Changes=20in=20Specialized=20Modes=20and=20Packages):=20Mention=20the=20= change.=0A=0A*=20doc/emacs/files.texi=20(Reverting):=20Add=20paragraph=20= describing=0Aauto-revert-always-poll.=0A---=0A=20doc/emacs/files.texi=20= |=20=2013=20+++++=0A=20etc/NEWS=20=20=20=20=20=20=20=20=20=20=20=20=20|=20= =2010=20++++=0A=20lisp/autorevert.el=20=20=20|=20125=20= ++++++++++++++++++++++++++++++-------------=0A=203=20files=20changed,=20= 111=20insertions(+),=2037=20deletions(-)=0A=0Adiff=20--git=20= a/doc/emacs/files.texi=20b/doc/emacs/files.texi=0Aindex=20= a57428230c..2dd48503b4=20100644=0A---=20a/doc/emacs/files.texi=0A+++=20= b/doc/emacs/files.texi=0A@@=20-988,6=20+988,19=20@@=20the=20polling=20= interval=20through=20the=20variable=20@code{auto-revert-interval}.=0A=20= supported,=20@code{auto-revert-use-notify}=20will=20be=20@code{nil}=20by=0A= =20default.=0A=20=0A+@vindex=20auto-revert-always-poll=0A+@vindex=20= auto-revert-notify-exclude-dir-regexp=0A+=20=20By=20default,=20= Auto-Revert=20mode=20will=20poll=20files=20for=20changes=0A+periodically=20= even=20when=20file=20notifications=20are=20used.=20=20Such=20polling=20= is=0A+usually=20unnecessary,=20and=20turning=20it=20off=20may=20save=20= power=20by=20relying=20on=0A+notifications=20only.=20=20To=20do=20so,=20= set=20the=20variable=0A+@code{auto-revert-always-poll}=20to=20= @code{nil}.=20=20However,=20notification=0A+is=20ineffective=20on=20= certain=20file=20systems;=20mainly=20network=20file=20system=20on=0A= +Unix-like=20machines,=20where=20files=20can=20be=20altered=20from=20= other=20machines.=0A+To=20force=20polling=20when=20= @code{auto-revert-always-poll}=20is=20@code{nil},=0A+set=20= @code{auto-revert-notify-exclude-dir-regexp}=20to=20match=20files=20that=0A= +should=20be=20excluded=20from=20using=20notification.=0A+=0A=20=20=20= One=20use=20of=20Auto-Revert=20mode=20is=20to=20``tail''=20a=20file=20= such=20as=20a=20system=0A=20log,=20so=20that=20changes=20made=20to=20= that=20file=20by=20other=20programs=20are=0A=20continuously=20displayed.=20= =20To=20do=20this,=20just=20move=20the=20point=20to=20the=20end=20of=0A= diff=20--git=20a/etc/NEWS=20b/etc/NEWS=0Aindex=209b32d720b6..cf997aa0c8=20= 100644=0A---=20a/etc/NEWS=0A+++=20b/etc/NEWS=0A@@=20-1389,6=20+1389,16=20= @@=20Packages=20deriving=20from=20'js-mode'=20with=20= 'define-derived-mode'=20should=0A=20call=20this=20function=20to=20add=20= enabled=20syntax=20extensions=20to=20their=20mode=0A=20name,=20too.=0A=20= =0A+**=20Autorevert=0A+=0A+***=20New=20variable=20= 'auto-revert-always-poll'=20for=20saving=20power.=0A+Set=20this=20= variable=20to=20nil=20to=20prevent=20buffers=20in=20auto-revert=20mode=20= from=0A+being=20polled=20for=20changes=20periodically.=20=20This=20= reduces=20the=20power=0A+consumption=20of=20an=20idle=20Emacs,=20but=20= may=20fail=20on=20some=20network=20file=0A+systems.=20=20Make=20sure=20= that=20'auto-revert-notify-exclude-dir-regexp'=0A+matches=20files=20= where=20notification=20is=20not=20supported.=0A+The=20default=20value=20= is=20t.=0A+=0A=20=0C=0A=20*=20New=20Modes=20and=20Packages=20in=20Emacs=20= 27.1=0A=20=0Adiff=20--git=20a/lisp/autorevert.el=20b/lisp/autorevert.el=0A= index=201d20896c83..b16b1b5833=20100644=0A---=20a/lisp/autorevert.el=0A= +++=20b/lisp/autorevert.el=0A@@=20-302,6=20+302,29=20@@=20You=20should=20= set=20this=20variable=20through=20Custom."=0A=20=20=20:type=20'regexp=0A=20= =20=20:version=20"24.4")=0A=20=0A+(defcustom=20auto-revert-always-poll=20= t=0A+=20=20"Non-nil=20to=20poll=20files=20in=20addition=20to=20the=20use=20= of=20notification.=0A+=0A+Set=20this=20variable=20to=20nil=20to=20save=20= power=20by=20avoiding=20polling=20when=0A+possible.=20=20Files=20on=20= file-systems=20that=20do=20not=20support=20change=0A+notifications=20= must=20match=20`auto-revert-notify-exclude-dir-regexp'=0A+for=20= Auto-Revert=20to=20work=20properly=20in=20this=20case.=20=20This=20= typically=0A+includes=20files=20on=20network=20file=20systems=20on=20= Unix-like=20machines,=0A+when=20those=20files=20are=20modified=20from=20= another=20computer.=0A+=0A+When=20non-nil,=20buffers=20in=20Auto-Revert=20= Mode=20will=20always=20be=20polled=0A+for=20changes=20to=20their=20files=20= on=20disk=20every=20`auto-revert-interval'=0A+seconds,=20in=20addition=20= to=20using=20notification=20for=20those=20files.=0A+=0A+In=20Global=20= Auto-Revert=20Mode,=20polling=20is=20always=20done=20regardless=20of=0A= +the=20value=20of=20this=20variable."=0A+=20=20:group=20'auto-revert=0A+=20= =20:type=20'boolean=0A+=20=20:set=20(lambda=20(variable=20value)=0A+=20=20= =20=20=20=20=20=20=20(set-default=20variable=20value)=0A+=20=20=20=20=20=20= =20=20=20(auto-revert-set-timer))=0A+=20=20:version=20"27.1")=0A+=0A=20= ;;=20Internal=20variables:=0A=20=0A=20(defvar=20auto-revert-buffer-list=20= ()=0A@@=20-319,6=20+342,11=20@@=20the=20list=20of=20old=20buffers.")=0A=20= (defvar=20auto-revert-tail-pos=200=0A=20=20=20"Position=20of=20last=20= known=20end=20of=20file.")=0A=20=0A+(defvar=20= auto-revert--polled-buffers=20()=0A+=20=20"List=20of=20buffers=20in=20= Auto-Revert=20Mode=20that=20must=20be=20polled.=0A+It=20contains=20the=20= buffers=20in=20`auto-revert-buffer-list'=20whose=0A= +`auto-revert-notify-watch-descriptor'=20is=20nil.")=0A+=0A=20(defun=20= auto-revert-find-file-function=20()=0A=20=20=20(setq-local=20= auto-revert-tail-pos=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (file-attribute-size=20(file-attributes=20buffer-file-name))))=0A@@=20= -346,8=20+374,12=20@@=20This=20has=20been=20reported=20by=20a=20file=20= notification=20event.")=0A=20(defun=20auto-revert-remove-current-buffer=20= (&optional=20buffer)=0A=20=20=20"Remove=20BUFFER=20from=20= `auto-revert-buffer-list'.=0A=20BUFFER=20defaults=20to=20= `current-buffer'."=0A+=20=20(unless=20buffer=0A+=20=20=20=20(setq=20= buffer=20(current-buffer)))=0A=20=20=20(setq=20auto-revert-buffer-list=0A= -=20=20=20=20=20=20=20=20(delq=20(or=20buffer=20(current-buffer))=20= auto-revert-buffer-list)))=0A+=20=20=20=20=20=20=20=20(delq=20buffer=20= auto-revert-buffer-list))=0A+=20=20(setq=20auto-revert--polled-buffers=0A= +=20=20=20=20=20=20=20=20(delq=20buffer=20auto-revert--polled-buffers)))=0A= =20=0A=20;;;###autoload=0A=20(define-minor-mode=20auto-revert-mode=0A@@=20= -367,6=20+399,7=20@@=20without=20being=20changed=20in=20the=20part=20= that=20is=20already=20in=20the=20buffer."=0A=20=20=20(if=20= auto-revert-mode=0A=20=20=20=20=20=20=20(when=20(not=20(memq=20= (current-buffer)=20auto-revert-buffer-list))=0A=20=20=20=20=20=20=20=20=20= (push=20(current-buffer)=20auto-revert-buffer-list)=0A+=20=20=20=20=20=20= =20=20(push=20(current-buffer)=20auto-revert--polled-buffers)=0A=20=20=20= =20=20=20=20=20=20(add-hook=0A=20=20=20=20=20=20=20=20=20=20= 'kill-buffer-hook=0A=20=20=20=20=20=20=20=20=20=20= #'auto-revert-remove-current-buffer=0A@@=20-479,9=20+512,17=20@@=20= specifies=20in=20the=20mode=20line."=0A=20=20=20=20=20=20=20= (auto-revert-buffers)=0A=20=20=20=20=20(dolist=20(buf=20(buffer-list))=0A= =20=20=20=20=20=20=20(with-current-buffer=20buf=0A-=09(when=20= auto-revert-notify-watch-descriptor=0A+=20=20=20=20=20=20=20=20(when=20= (and=20auto-revert-notify-watch-descriptor=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(not=20(memq=20buf=20= auto-revert-buffer-list)))=0A=20=09=20=20= (auto-revert-notify-rm-watch))))))=0A=20=0A+(defun=20= auto-revert--need-polling-p=20()=0A+=20=20"Whether=20periodic=20polling=20= is=20required."=0A+=20=20(or=20global-auto-revert-mode=0A+=20=20=20=20=20= =20(if=20auto-revert-always-poll=0A+=20=20=20=20=20=20=20=20=20=20= auto-revert-buffer-list=0A+=20=20=20=20=20=20=20=20= auto-revert--polled-buffers)))=0A+=0A=20(defun=20auto-revert-set-timer=20= ()=0A=20=20=20"Restart=20or=20cancel=20the=20timer=20used=20by=20= Auto-Revert=20Mode.=0A=20If=20such=20a=20timer=20is=20active,=20cancel=20= it.=20=20Start=20a=20new=20timer=20if=0A@@=20-492,10=20+533,10=20@@=20= will=20use=20an=20up-to-date=20value=20of=20`auto-revert-interval'"=0A=20= =20=20(if=20(timerp=20auto-revert-timer)=0A=20=20=20=20=20=20=20= (cancel-timer=20auto-revert-timer))=0A=20=20=20(setq=20auto-revert-timer=0A= -=09(if=20(or=20global-auto-revert-mode=20auto-revert-buffer-list)=0A-=09= =20=20=20=20(run-with-timer=20auto-revert-interval=0A-=09=09=09=20=20=20=20= auto-revert-interval=0A-=09=09=09=20=20=20=20'auto-revert-buffers))))=0A= +=09(and=20(auto-revert--need-polling-p)=0A+=09=20=20=20=20=20= (run-with-timer=20auto-revert-interval=0A+=09=09=09=20=20=20=20=20= auto-revert-interval=0A+=09=09=09=20=20=20=20=20'auto-revert-buffers))))=0A= =20=0A=20(defun=20auto-revert-notify-rm-watch=20()=0A=20=20=20"Disable=20= file=20notification=20for=20current=20buffer's=20associated=20file."=0A= @@=20-551,6=20+592,8=20@@=20will=20use=20an=20up-to-date=20value=20of=20= `auto-revert-interval'"=0A=20=09=20=20=20=20=20=20=20(gethash=20= auto-revert-notify-watch-descriptor=0A=20=09=09=20=20=20=20=20=20=20=20= auto-revert--buffers-by-watch-descriptor))=0A=20=20=20=20=20=20=20=20=20=20= auto-revert--buffers-by-watch-descriptor)=0A+=20=20=20=20=20=20=20=20= (setq=20auto-revert--polled-buffers=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(delq=20(current-buffer)=20auto-revert--polled-buffers))=0A=20=20=20= =20=20=20=20=20=20(add-hook=20'kill-buffer-hook=20= #'auto-revert-notify-rm-watch=20nil=20t)))))=0A=20=0A=20;;=20If=20we=20= have=20file=20notifications,=20we=20want=20to=20update=20the=20= auto-revert=20buffers=0A@@=20-558,24=20+601,20=20@@=20will=20use=20an=20= up-to-date=20value=20of=20`auto-revert-interval'"=0A=20;;=20often,=20we=20= want=20to=20skip=20some=20revert=20operations=20so=20that=20we=20don't=20= spend=20all=20our=0A=20;;=20time=20reverting=20the=20buffer.=0A=20;;=0A= -;;=20We=20do=20this=20by=20reverting=20immediately=20in=20response=20to=20= the=20first=20in=20a=20flurry=20of=0A-;;=20notifications.=20We=20= suppress=20subsequent=20notifications=20until=20the=20next=20time=0A-;;=20= `auto-revert-buffers'=20is=20called=20(this=20happens=20on=20a=20timer=20= with=20a=20period=20set=20by=0A-;;=20`auto-revert-interval').=0A-(defvar=20= auto-revert-buffers-counter=201=0A-=20=20"Incremented=20each=20time=20= `auto-revert-buffers'=20is=20called")=0A-(defvar-local=20= auto-revert-buffers-counter-lockedout=200=0A-=20=20"Buffer-local=20value=20= to=20indicate=20whether=20we=20should=20immediately=0A-update=20the=20= buffer=20on=20a=20notification=20event=20or=20not.=20If=0A-=0A-=20=20(=3D=20= auto-revert-buffers-counter-lockedout=0A-=20=20=20=20=20= auto-revert-buffers-counter)=0A-=0A-then=20the=20updates=20are=20locked=20= out,=20and=20we=20wait=20until=20the=20next=20call=0A-of=20= `auto-revert-buffers'=20to=20revert=20the=20buffer.=20If=20no=20lockout=20= is=0A-present,=20then=20we=20revert=20immediately=20and=20set=20the=20= lockout,=20so=20that=0A-no=20more=20reverts=20are=20possible=20until=20= the=20next=20call=20of=0A-`auto-revert-buffers'")=0A+;;=20We=20do=20this=20= by=20reverting=20immediately=20in=20response=20to=20the=20first=20in=20a=0A= +;;=20flurry=20of=20notifications.=20Any=20notifications=20during=20the=20= following=0A+;;=20`auto-revert-lockout-interval'=20seconds=20are=20noted=20= but=20not=20acted=20upon=0A+;;=20until=20the=20end=20of=20that=20= interval.=0A+=0A+(defconst=20auto-revert--lockout-interval=202.5=0A+=20=20= "Duration,=20in=20seconds,=20of=20the=20Auto-Revert=20Mode=20= notification=20lockout.=0A+This=20is=20the=20quiescence=20after=20each=20= notification=20of=20a=20file=20being=0A+changed=20during=20which=20no=20= automatic=20reverting=20takes=20place,=20to=0A+prevent=20many=20updates=20= in=20rapid=20succession=20from=20overwhelming=20the=0A+system.")=0A+=0A= +(defvar-local=20auto-revert--lockout-timer=20nil=0A+=20=20"Timer=20= awaiting=20the=20end=20of=20the=20notification=20lockout=20interval,=20= or=20nil.")=0A=20=0A=20(defun=20auto-revert-notify-handler=20(event)=0A=20= =20=20"Handle=20an=20EVENT=20returned=20from=20file=20notification."=0A= @@=20-604,7=20+643,13=20@@=20no=20more=20reverts=20are=20possible=20= until=20the=20next=20call=20of=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(file-name-nondirectory=20= buffer-file-name)))=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20;;=20A=20buffer=20w/o=20a=20file,=20like=20dired.=0A=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(null=20= buffer-file-name))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (auto-revert-notify-rm-watch))))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(auto-revert-notify-rm-watch)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(when=20(memq=20buffer=20auto-revert-buffer-list)=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(unless=20(memq=20buffer=20= auto-revert--polled-buffers)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(push=20buffer=20auto-revert--polled-buffers))=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20Restart=20the=20= timer=20if=20it=20wasn't=20running.=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(unless=20auto-revert-timer=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(auto-revert-set-timer))))))=0A=20=0A= =20=20=20=20=20=20=20=20=20;;=20Loop=20over=20all=20buffers,=20in=20= order=20to=20find=20the=20intended=20one.=0A=20=20=20=20=20=20=20=20=20= (cl-dolist=20(buffer=20buffers)=0A@@=20-630,11=20+675,21=20@@=20no=20= more=20reverts=20are=20possible=20until=20the=20next=20call=20of=0A=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(setq=20= auto-revert-notify-modified-p=20t)=0A=20=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20;;=20Revert=20the=20buffer=20now=20if=20we're=20not=20= locked=20out.=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(when=20= (/=3D=20auto-revert-buffers-counter-lockedout=0A-=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= auto-revert-buffers-counter)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(unless=20auto-revert--lockout-timer=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(auto-revert-handler)=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(setq=20= auto-revert-buffers-counter-lockedout=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20= auto-revert-buffers-counter))))))))))=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(setq=20auto-revert--lockout-timer=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(run-with-timer=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20auto-revert--lockout-interval=20nil=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20#'auto-revert--end-lockout=20= buffer)))))))))))=0A+=0A+(defun=20auto-revert--end-lockout=20(buffer)=0A= +=20=20"End=20the=20lockout=20period=20after=20a=20notification.=0A+If=20= the=20buffer=20needs=20to=20be=20reverted,=20do=20it=20now."=0A+=20=20= (when=20(buffer-live-p=20buffer)=0A+=20=20=20=20(with-current-buffer=20= buffer=0A+=20=20=20=20=20=20(setq=20auto-revert--lockout-timer=20nil)=0A= +=20=20=20=20=20=20(when=20auto-revert-notify-modified-p=0A+=20=20=20=20=20= =20=20=20(auto-revert-handler)))))=0A=20=0A=20(defun=20= auto-revert-active-p=20()=0A=20=20=20"Check=20if=20auto-revert=20is=20= active=20(in=20current=20buffer=20or=20globally)."=0A@@=20-755,13=20= +810,10=20@@=20This=20function=20is=20also=20responsible=20for=20= removing=20buffers=20no=20longer=20in=0A=20Auto-Revert=20Mode=20from=20= `auto-revert-buffer-list',=20and=20for=20canceling=0A=20the=20timer=20= when=20no=20buffers=20need=20to=20be=20checked."=0A=20=0A-=20=20(setq=20= auto-revert-buffers-counter=0A-=20=20=20=20=20=20=20=20(1+=20= auto-revert-buffers-counter))=0A-=0A=20=20=20(save-match-data=0A-=20=20=20= =20(let=20((bufs=20(if=20global-auto-revert-mode=0A-=09=09=20=20=20=20= (buffer-list)=0A-=09=09=20=20auto-revert-buffer-list))=0A+=20=20=20=20= (let=20((bufs=20(cond=20(global-auto-revert-mode=20(buffer-list))=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (auto-revert-always-poll=20auto-revert-buffer-list)=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(t=20= auto-revert--polled-buffers)))=0A=20=09=20=20remaining=20new)=0A=20=20=20= =20=20=20=20;;=20Buffers=20with=20remote=20contents=20shall=20be=20= reverted=20only=20if=20the=0A=20=20=20=20=20=20=20;;=20connection=20is=20= established=20already.=0A@@=20-810,8=20+862,7=20@@=20the=20timer=20when=20= no=20buffers=20need=20to=20be=20checked."=0A=20=09(setq=20bufs=20(cdr=20= bufs)))=0A=20=20=20=20=20=20=20(setq=20auto-revert-remaining-buffers=20= bufs)=0A=20=20=20=20=20=20=20;;=20Check=20if=20we=20should=20cancel=20= the=20timer.=0A-=20=20=20=20=20=20(when=20(and=20(not=20= global-auto-revert-mode)=0A-=09=09=20(null=20auto-revert-buffer-list))=0A= +=20=20=20=20=20=20(unless=20(auto-revert--need-polling-p)=0A=20=20=20=20= =20=20=20=20=20(if=20(timerp=20auto-revert-timer)=0A=20=20=20=20=20=20=20= =20=20=20=20=20=20(cancel-timer=20auto-revert-timer))=0A=20=09(setq=20= auto-revert-timer=20nil)))))=0A--=20=0A2.20.1=20(Apple=20Git-117)=0A=0A= --Apple-Mail=_63FF422E-39C5-4384-BCDA-EBD6A6EE7DB4--