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: Sun, 19 May 2019 22:25:57 +0200 Message-ID: References: <87woj9nj77.fsf@gmx.de> <83r29fmz3f.fsf@gnu.org> <6b722334f6eaddcbbf3def636b5181c9439a172c.camel@acm.org> <831s1emvz7.fsf@gnu.org> <26e8159ac86da37d9cf555f6cb3f2dcb63ac0a67.camel@acm.org> <87y33mgo0c.fsf@gmx.de> <05128E42-E970-4C41-9DF9-E9E0BC1C9E4A@acm.org> <87tveagg4f.fsf@gmx.de> <87pnoygdx6.fsf@gmx.de> <8FEB518A-F5AA-488B-BDC5-7947FFE51394@acm.org> <87lfzlgvka.fsf@gmx.de> <3D200C55-AD11-4214-9C50-C2183F6598CC@acm.org> <93015872-0F5F-4E27-97BB-94BA0EE72653@acm.org> <87muju1vx1.fsf@gmx.de> <25E4EBE0-0E65-45B7-B56F-9C67A2862DFA@acm.org> <87a7fu1nv8.fsf@gmx.de> <87tvdyie82.fsf@gmx.de> <4FD5C2DB-8F3D-4317-B8ED-CB7A4605A2F1@acm.org> <87woimdczk.fsf@gmx.de> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_EF6DBC5C-583C-44D9-B8C9-D2D2DA0C277A" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="55436"; 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 Sun May 19 22:41:56 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 1hSSd0-000EIf-Ty for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 May 2019 22:41:55 +0200 Original-Received: from localhost ([127.0.0.1]:53173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSScz-0006Xi-6M for geb-bug-gnu-emacs@m.gmane.org; Sun, 19 May 2019 16:41:53 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSOd-0003QK-VT for bug-gnu-emacs@gnu.org; Sun, 19 May 2019 16:27:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSOc-0007r0-QZ for bug-gnu-emacs@gnu.org; Sun, 19 May 2019 16:27:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50310) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSOc-0007qq-L4 for bug-gnu-emacs@gnu.org; Sun, 19 May 2019 16:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hSSOc-0005uZ-EX for bug-gnu-emacs@gnu.org; Sun, 19 May 2019 16:27: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: Sun, 19 May 2019 20:27:02 +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.155829756722644 (code B ref 35418); Sun, 19 May 2019 20:27:02 +0000 Original-Received: (at 35418) by debbugs.gnu.org; 19 May 2019 20:26:07 +0000 Original-Received: from localhost ([127.0.0.1]:35621 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hSSNj-0005t9-5h for submit@debbugs.gnu.org; Sun, 19 May 2019 16:26:07 -0400 Original-Received: from mail231c50.megamailservers.eu ([91.136.10.241]:45784 helo=mail37c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hSSNe-0005sg-I0 for 35418@debbugs.gnu.org; Sun, 19 May 2019 16:26:04 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1558297560; bh=I+V/ekYuYzOephDAGzfV9buOAo2yZfiSCK+rtW/oqOc=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=LPexf9FYlgn6BIHGuQUS3DtAEeLZxClA7KHUxA73VvClemfLlW4DAaHZR+PtbWTA8 ExYndxqWeBCf54MgRHbWIS1f3vfE6STmm7gOYYXY3EZ2/VEVNXemB9D/kMaloBlOaD HoZCnO0j1DIayyWeYzzskSNLmkLschC/O0xlZUbA= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] ([188.150.171.71]) (authenticated bits=0) by mail37c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x4JKPwx7008220; Sun, 19 May 2019 20:25:59 +0000 In-Reply-To: <87woimdczk.fsf@gmx.de> X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0201.5CE1BBD8.004A, 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=ItQwjo3g c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=mDV3o1hIAAAA:8 a=lEriqonRAAAA:8 a=MPMERgMrRkygqWAbCeAA:9 a=qj69CpH6klWzQLlh:21 a=6V4oaCkPR5AWawAC:21 a=CjuIK1q_8ugA:10 a=fPw3ZMCt_jpd5vk-e2sA:9 a=B2y7HmGcmWMA:10 a=_FVE-zBwftR9WsbkzFJk:22 a=iCVytvwig4ZIu1j4Gkh3:22 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:159570 Archived-At: --Apple-Mail=_EF6DBC5C-583C-44D9-B8C9-D2D2DA0C277A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 19 maj 2019 kl. 11.12 skrev Michael Albinus : >=20 > Btw, you could always run the four tests on emba.gnu.org. Submit a > change (also a git branch would do), and the bot on emba.git.org would > run these test constellations for you. Same for filenotify-tests. That's good to know -- I'll try that next time. >> "Check if auto-revert is active (in current buffer or globally)." >=20 > Remove "or globally". Done. >> +(defun auto-revert-test--write-file (string file) >> + (write-region string nil file nil 'no-message)) >> + >> +(defun auto-revert-test--buffer-string (buffer) >> + (with-current-buffer buffer >> + (buffer-string))) >=20 > Pls add a docstring. Added. >> +(ert-deftest auto-revert-test05-global-notify () >> + "Test global-auto-revert-mode without polling." >=20 > Quote `global-auto-revert-mode'. Check also, whether file notification > is enabled: >=20 > (skip-unless (or file-notify--library > (file-remote-p temporary-file-directory))) Quoted, and check added. >> + (let* ((auto-revert-avoid-polling t) >=20 > Enable file notification explicitly. You don't know, whether the user > has disabled it. >=20 > (let* ((auto-revert-use-notify t) > (auto-revert-avoid-polling t) Done. >> + (auto-revert-interval 2) ; To speed up the test. >=20 > Do we really want this? I prefer to test the unmodified package. If = you > believe this takes too much time for ordinary "make check" calls, you > might tag the test case as :expensive-test, like > auto-revert-test01-auto-revert-several-files and > auto-revert-test02-auto-revert-deleted-file. That was probably just me being impatient; I've removed that line and = added :expensive-test. >> + (global-auto-revert-mode 1) ; Turn it on. >=20 > Save the value of global-auto-revert-mode, and reset it in Cleanup. = You > don't know the user's settings. Done. >> + (dolist (buf (list buf-1 buf-2 buf-3)) >> + (when (buffer-live-p buf) >> + (kill-buffer buf))) >=20 > Why not (ignore-errors (kill-buffer buf)) ? Using a condition felt more precise, but I have no strong opinion in = this case. Changed to ignore-errors. > Add the remote test case: >=20 > (auto-revert--deftest-remote auto-revert-test05-global-notify > "Test `global-auto-revert-mode' without polling for remote buffers." Added. Thanks for the tests and review! Revised patch attached. --Apple-Mail=_EF6DBC5C-583C-44D9-B8C9-D2D2DA0C277A Content-Disposition: attachment; filename=0001-Avoid-polling-in-global-auto-revert-mode-bug-35418.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Avoid-polling-in-global-auto-revert-mode-bug-35418.patch" Content-Transfer-Encoding: quoted-printable =46rom=202877e205b2fd90fac03b56aa8022d1c7722bfd6f=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Thu,=209=20May=202019=2009:40:46=20+0200=0A= Subject:=20[PATCH]=20Avoid=20polling=20in=20global-auto-revert-mode=20= (bug#35418)=0A=0AMake=20`auto-revert-avoid-polling'=20have=20effect=20in=20= global-auto-revert-mode.=0ABuffers=20actually=20handled=20by=20that=20= mode=20are=20marked=20with=20a=20non-nil=20value=0Aof=20= `auto-revert--global-mode'.=20=20When=20global-auto-revert-mode=20is=0A= entered,=20eligible=20buffers=20are=20marked=20in=20that=20way,=20and=20= hooks=20are=20set=20up=0Ato=20mark=20new=20buffers=20and=20take=20care=20= of=20buffers=20whose=20file=20names=20change.=0AThis=20way=20the=20= existing=20poll-avoidance=20logic=20can=20be=20used,=20since=20the=0A= entire=20set=20of=20buffers=20in=20auto-revert=20is=20known.=0A=0AA=20= new=20hook,=20`after-set-visited-file-name-hook',=20was=20added=20to=20= handle=0Athe=20case=20when=20the=20file=20name=20of=20a=20tracked=20= buffer=20changes.=0A=0A*=20lisp/autorevert.el=20= (auto-revert-avoid-polling):=20Amend=20doc=20string.=0A= (auto-revert--global-mode):=20New=20buffer-local=20variable.=0A= (global-auto-revert-mode):=20Mark=20existing=20buffers=20and=20set=20up=20= hooks=20when=0Amode=20is=20entered;=20do=20the=20opposite=20when=20= exited.=0A(auto-revert--global-add-current-buffer)=0A= (auto-revert--global-adopt-current-buffer)=0A= (auto-revert--set-visited-file-name-advice):=20New=20functions.=0A= (auto-revert--polled-buffers,=20auto-revert--need-polling-p)=0A= (auto-revert-notify-handler)=0A(auto-revert-active-p):=20Modify=20logic=20= to=20cover=20global-auto-revert-mode.=0A*=20lisp/files.el=20= (after-set-visited-file-name-hook):=20New=20hook.=0A= (set-visited-file-name-hook):=20Call=20new=20hook.=0A*=20= test/lisp/autorevert-tests.el=20(top):=20=20Use=20lexical-binding.=0A= (auto-revert-test--write-file,=20auto-revert-test--buffer-string)=0A= (auto-revert-test--wait-for,=20auto-revert-test--wait-for-buffer-text)=0A= (auto-revert-test05-global-notify):=20New=20test.=0A*=20= doc/lispref/hooks.texi=20(Standard=20Hooks):=0AMention=20new=20hook=20= (in=20a=20comment,=20since=20it's=20unclear=20whether=20it=20should=0A= actually=20be=20documented=20here)=0A*=20etc/NEWS=20(Changes=20in=20= Specialized=20Modes=20and=20Packages):=20Update=20entry.=0A---=0A=20= doc/lispref/hooks.texi=20=20=20=20=20=20=20=20|=20=20=201=20+=0A=20= etc/NEWS=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= |=20=20=203=20+-=0A=20lisp/autorevert.el=20=20=20=20=20=20=20=20=20=20=20= =20|=20124=20++++++++++++++++++++++++++--------=0A=20lisp/files.el=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=20=206=20+-=0A=20= test/lisp/autorevert-tests.el=20|=20107=20++++++++++++++++++++++++++++-=0A= =205=20files=20changed,=20210=20insertions(+),=2031=20deletions(-)=0A=0A= diff=20--git=20a/doc/lispref/hooks.texi=20b/doc/lispref/hooks.texi=0A= index=2071992464e0..f775aa4d4b=20100644=0A---=20a/doc/lispref/hooks.texi=0A= +++=20b/doc/lispref/hooks.texi=0A@@=20-251,6=20+251,7=20@@=20I=20thought=20= did=20not=20need=20to=20be=20mentioned=20here:=0A=20=0A=20Lisp:=0A=20= after-load-functions=0A+after-set-visited-file-name-hook=0A=20= auto-coding-functions=0A=20choose-completion-string-functions=0A=20= completing-read-function=0Adiff=20--git=20a/etc/NEWS=20b/etc/NEWS=0A= index=20d70cda179e..9ca98c370e=20100644=0A---=20a/etc/NEWS=0A+++=20= b/etc/NEWS=0A@@=20-1443,8=20+1443,7=20@@=20When=20set=20to=20a=20non-nil=20= value,=20buffers=20in=20Auto=20Revert=20mode=20are=20no=20longer=0A=20= polled=20for=20changes=20periodically.=20=20This=20reduces=20the=20power=20= consumption=0A=20of=20an=20idle=20Emacs,=20but=20may=20fail=20on=20some=20= network=20file=20systems;=20set=0A=20= 'auto-revert-notify-exclude-dir-regexp'=20to=20match=20files=20where=0A= -notification=20is=20not=20supported.=20=20The=20new=20variable=20= currently=20has=20no=0A-effect=20in=20'global-auto-revert-mode'.=20=20= The=20default=20value=20is=20nil.=0A+notification=20is=20not=20= supported.=20=20The=20default=20value=20is=20nil.=0A=20=0A=20***=20New=20= variable=20'buffer-auto-revert-by-notification'=0A=20A=20major=20mode=20= can=20declare=20that=20notification=20on=20the=20buffer's=20default=0A= diff=20--git=20a/lisp/autorevert.el=20b/lisp/autorevert.el=0Aindex=20= 197a2bf157..2de855b303=20100644=0A---=20a/lisp/autorevert.el=0A+++=20= b/lisp/autorevert.el=0A@@=20-312,10=20+312,7=20@@=20when=20those=20files=20= are=20modified=20from=20another=20computer.=0A=20=0A=20When=20nil,=20= buffers=20in=20Auto-Revert=20Mode=20will=20always=20be=20polled=20for=0A=20= changes=20to=20their=20files=20on=20disk=20every=20= `auto-revert-interval'=0A-seconds,=20in=20addition=20to=20using=20= notification=20for=20those=20files.=0A-=0A-In=20Global=20Auto-Revert=20= Mode,=20polling=20is=20always=20done=20regardless=20of=0A-the=20value=20= of=20this=20variable."=0A+seconds,=20in=20addition=20to=20using=20= notification=20for=20those=20files."=0A=20=20=20:group=20'auto-revert=0A=20= =20=20:type=20'boolean=0A=20=20=20:set=20(lambda=20(variable=20value)=0A= @@=20-335,6=20+332,9=20@@=20buffers=20to=20this=20list.=0A=20The=20timer=20= function=20`auto-revert-buffers'=20is=20responsible=20for=20purging=0A=20= the=20list=20of=20old=20buffers.")=0A=20=0A+(defvar-local=20= auto-revert--global-mode=20nil=0A+=20=20"Non-nil=20if=20buffer=20is=20= handled=20by=20Global=20Auto-Revert=20mode.")=0A+=0A=20(defvar=20= auto-revert-remaining-buffers=20()=0A=20=20=20"Buffers=20not=20checked=20= when=20user=20input=20stopped=20execution.")=0A=20=0A@@=20-501,34=20= +501,107=20@@=20specifies=20in=20the=20mode=20line."=0A=20=20=20:global=20= t=20:group=20'auto-revert=20:lighter=20global-auto-revert-mode-text=0A=20= =20=20(auto-revert-set-timer)=0A=20=20=20(if=20global-auto-revert-mode=0A= -=20=20=20=20=20=20(auto-revert-buffers)=0A+=20=20=20=20=20=20;;=20Turn=20= global-auto-revert-mode=20ON.=0A+=20=20=20=20=20=20(progn=0A+=20=20=20=20= =20=20=20=20(dolist=20(buf=20(buffer-list))=0A+=20=20=20=20=20=20=20=20=20= =20(with-current-buffer=20buf=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (auto-revert--global-add-current-buffer)))=0A+=20=20=20=20=20=20=20=20;;=20= Make=20sure=20future=20buffers=20are=20added=20as=20well.=0A+=20=20=20=20= =20=20=20=20(add-hook=20'find-file-hook=20= #'auto-revert--global-adopt-current-buffer)=0A+=20=20=20=20=20=20=20=20= (add-hook=20'after-set-visited-file-name-hook=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20= #'auto-revert--global-set-visited-file-name)=0A+=20=20=20=20=20=20=20=20= ;;=20To=20track=20non-file=20buffers,=20we=20need=20to=20listen=20in=20= to=20buffer=0A+=20=20=20=20=20=20=20=20;;=20creation=20in=20general.=20=20= Listening=20to=20major-mode=20changes=20is=0A+=20=20=20=20=20=20=20=20;;=20= suitable,=20since=20we=20then=20know=20whether=20it's=20a=20mode=20that=20= is=20tracked.=0A+=20=20=20=20=20=20=20=20(when=20= global-auto-revert-non-file-buffers=0A+=20=20=20=20=20=20=20=20=20=20= (add-hook=20'after-change-major-mode-hook=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20= #'auto-revert--global-adopt-current-buffer))=0A+=20=20=20=20=20=20=20=20= (auto-revert-buffers))=0A+=20=20=20=20;;=20Turn=20= global-auto-revert-mode=20OFF.=0A+=20=20=20=20(remove-hook=20= 'after-change-major-mode-hook=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20#'auto-revert--global-adopt-current-buffer)=0A+=20=20=20=20= (remove-hook=20'after-set-visited-file-name-hook=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20= #'auto-revert--global-set-visited-file-name)=0A+=20=20=20=20(remove-hook=20= 'find-file-hook=20#'auto-revert--global-adopt-current-buffer)=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-=20=20=20=20=20=20=20=20(when=20(and=20= auto-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=20auto-revert-buffer-list)))=0A-=09= =20=20(auto-revert-notify-rm-watch))))))=0A+=20=20=20=20=20=20=20=20= (when=20auto-revert--global-mode=0A+=20=20=20=20=20=20=20=20=20=20(setq=20= auto-revert--global-mode=20nil)=0A+=20=20=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=20=20(not=20(or=20auto-revert-mode=20= auto-revert-tail-mode)))=0A+=09=20=20=20=20= (auto-revert-notify-rm-watch)))))))=0A+=0A+(defun=20= auto-revert--global-add-current-buffer=20()=0A+=20=20"Set=20current=20= buffer=20to=20be=20tracked=20by=20Global=20Auto-Revert=20if=20= appropriate."=0A+=20=20(when=20(and=20(not=20auto-revert--global-mode)=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20(or=20buffer-file-name=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(and=20= global-auto-revert-non-file-buffers=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(not=20(string-prefix-p=20"=20"=20= (buffer-name)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20;;=20Any=20non-file=20buffer=20must=20have=20a=20custom=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20= `buffer-stale-function'=20to=20be=20tracked,=20since=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20we=20wouldn't=20= know=20when=20to=20revert=20it=20otherwise.=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(not=20(eq=20= buffer-stale-function=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=20=20=20= #'buffer-stale--default-function))))=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20(not=20(memq=20'major-mode=20global-auto-revert-ignore-modes))=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20(not=20= global-auto-revert-ignore-buffer))=0A+=20=20=20=20(setq=20= auto-revert--global-mode=20t)))=0A+=0A+(defun=20= auto-revert--global-adopt-current-buffer=20()=0A+=20=20"Consider=20= tracking=20current=20buffer=20in=20a=20running=20Global=20Auto-Revert=20= mode."=0A+=20=20(auto-revert--global-add-current-buffer)=0A+=20=20= (auto-revert-set-timer))=0A+=0A+(defun=20= auto-revert--global-set-visited-file-name=20()=0A+=20=20"Update=20Global=20= Auto-Revert=20management=20of=20the=20current=20buffer.=0A+Called=20= after=20`set-visited-file-name'."=0A+=20=20;;=20Remove=20any=20existing=20= notifier=20first=20so=20that=20we=20don't=20track=20the=0A+=20=20;;=20= wrong=20file=20in=20case=20the=20file=20name=20was=20changed.=0A+=20=20= (when=20auto-revert-notify-watch-descriptor=0A+=20=20=20=20= (auto-revert-notify-rm-watch))=0A+=20=20= (auto-revert--global-adopt-current-buffer))=0A=20=0A=20(defun=20= auto-revert--polled-buffers=20()=0A=20=20=20"List=20of=20buffers=20that=20= need=20to=20be=20polled."=0A-=20=20(cond=20(global-auto-revert-mode=20= (buffer-list))=0A+=20=20(cond=20(global-auto-revert-mode=0A+=20=20=20=20=20= =20=20=20=20(mapcan=20(lambda=20(buffer)=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(and=20(not=20(and=20= auto-revert-avoid-polling=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=20=20=20=20=20=20= (buffer-local-value=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=20=20=20=20=20=20=20= 'auto-revert-notify-watch-descriptor=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=20=20=20=20=20=20=20= buffer)))=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(or=20(buffer-local-value=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=20= 'auto-revert--global-mode=20buffer)=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(buffer-local-value=20= 'auto-revert-mode=20buffer)=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(buffer-local-value=20= 'auto-revert-tail-mode=20buffer))=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(list=20buffer)))=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(buffer-list)))=0A=20=20=20=20=20=20=20=20= =20(auto-revert-avoid-polling=0A=20=20=20=20=20=20=20=20=20=20(mapcan=20= (lambda=20(buffer)=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(and=20(not=20(buffer-local-value=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=20=20=20=20= 'auto-revert-notify-watch-descriptor=20buffer))=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(list=20buffer)))=0A= -=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= auto-revert-buffer-list))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(and=20(not=20(buffer-local-value=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=20=20= 'auto-revert-notify-watch-descriptor=20buffer))=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(list=20buffer)))=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20auto-revert-buffer-list))=0A= =20=20=20=20=20=20=20=20=20(t=20auto-revert-buffer-list)))=0A=20=0A=20;;=20= Same=20as=20above=20in=20a=20boolean=20context,=20but=20cheaper.=0A=20= (defun=20auto-revert--need-polling-p=20()=0A=20=20=20"Whether=20periodic=20= polling=20is=20required."=0A-=20=20(or=20global-auto-revert-mode=0A-=20=20= =20=20=20=20(if=20auto-revert-avoid-polling=0A-=20=20=20=20=20=20=20=20=20= =20(not=20(cl-every=20(lambda=20(buffer)=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(buffer-local-value=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'auto-revert-notify-watch-descriptor=20buffer))=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-buffer-list))=0A-=20=20=20=20=20=20=20=20= auto-revert-buffer-list)))=0A+=20=20(cond=20(global-auto-revert-mode=0A+=20= =20=20=20=20=20=20=20=20(or=20(not=20auto-revert-avoid-polling)=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20(cl-some=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(lambda=20(buffer)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(and=20(not=20(buffer-local-value=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= 'auto-revert-notify-watch-descriptor=20buffer))=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20(or=20(buffer-local-value=20= 'auto-revert--global-mode=20buffer)=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(buffer-local-value=20= 'auto-revert-mode=20buffer)=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(buffer-local-value=20= 'auto-revert-tail-mode=20buffer))))=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(buffer-list))))=0A+=20=20=20=20=20=20=20=20= (auto-revert-avoid-polling=0A+=20=20=20=20=20=20=20=20=20(not=20= (cl-every=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(lambda=20= (buffer)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (buffer-local-value=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20'auto-revert-notify-watch-descriptor=20buffer))=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20auto-revert-buffer-list)))=0A+=20=20=20=20=20=20=20= =20(t=20auto-revert-buffer-list)))=0A=20=0A=20(defun=20= auto-revert-set-timer=20()=0A=20=20=20"Restart=20or=20cancel=20the=20= timer=20used=20by=20Auto-Revert=20Mode.=0A@@=20-652,9=20+725,8=20@@=20= system.")=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(null=20buffer-file-name))=0A=20=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=20;;=20Restart=20the=20timer=20if=20it=20wasn't=20= running.=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(when=20(and=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=20=20=20=20=20=20=20=20=20(not=20= auto-revert-timer))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(auto-revert-set-timer)))))=0A+=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(auto-revert-set-timer))))=0A=20=0A=20=20=20=20=20=20= =20=20=20;;=20Loop=20over=20all=20buffers,=20in=20order=20to=20find=20= the=20intended=20one.=0A=20=20=20=20=20=20=20=20=20(cl-dolist=20(buffer=20= buffers)=0A@@=20-697,12=20+769,10=20@@=20If=20the=20buffer=20needs=20to=20= be=20reverted,=20do=20it=20now."=0A=20=20=20=20=20=20=20=20=20= (auto-revert-handler)))))=0A=20=0A=20(defun=20auto-revert-active-p=20()=0A= -=20=20"Check=20if=20auto-revert=20is=20active=20(in=20current=20buffer=20= or=20globally)."=0A+=20=20"Check=20if=20auto-revert=20is=20active=20in=20= current=20buffer."=0A=20=20=20(or=20auto-revert-mode=0A=20=20=20=20=20=20= =20auto-revert-tail-mode=0A-=20=20=20=20=20=20(and=20= global-auto-revert-mode=0A-=20=20=20=20=20=20=20=20=20=20=20(not=20= global-auto-revert-ignore-buffer)=0A-=20=20=20=20=20=20=20=20=20=20=20= (not=20(memq=20major-mode=20global-auto-revert-ignore-modes)))))=0A+=20=20= =20=20=20=20auto-revert--global-mode))=0A=20=0A=20(defun=20= auto-revert-handler=20()=0A=20=20=20"Revert=20current=20buffer,=20if=20= appropriate.=0Adiff=20--git=20a/lisp/files.el=20b/lisp/files.el=0Aindex=20= 1dec0ed7ca..287ad14aec=20100644=0A---=20a/lisp/files.el=0A+++=20= b/lisp/files.el=0A@@=20-4269,6=20+4269,9=20@@=20However,=20the=20mode=20= will=20not=20be=20changed=20if=0A=20=20=20:type=20'boolean=0A=20=20=20= :group=20'editing-basics)=0A=20=0A+(defvar=20= after-set-visited-file-name-hook=20nil=0A+=20=20"Normal=20hook=20run=20= just=20after=20setting=20visited=20file=20name=20of=20current=20= buffer.")=0A+=0A=20(defun=20set-visited-file-name=20(filename=20= &optional=20no-query=20along-with-file)=0A=20=20=20"Change=20name=20of=20= file=20visited=20in=20current=20buffer=20to=20FILENAME.=0A=20This=20also=20= renames=20the=20buffer=20to=20correspond=20to=20the=20new=20file.=0A@@=20= -4389,7=20+4392,8=20@@=20the=20old=20visited=20file=20has=20been=20= renamed=20to=20the=20new=20name=20FILENAME."=0A=20=09=20=20=20=20=20=20= (set-auto-mode=20t)=0A=20=09=20=20=20=20=20=20(or=20(eq=20old=20= major-mode)=0A=20=09=09=20=20(hack-local-variables))))=0A-=20=20=20=20= (error=20nil))))=0A+=20=20=20=20=20=20(error=20nil))=0A+=20=20=20=20= (run-hooks=20'after-set-visited-file-name-hook)))=0A=20=0A=20(defun=20= write-file=20(filename=20&optional=20confirm)=0A=20=20=20"Write=20= current=20buffer=20into=20file=20FILENAME.=0Adiff=20--git=20= a/test/lisp/autorevert-tests.el=20b/test/lisp/autorevert-tests.el=0A= index=20af9edac1be..7c8a83d6ca=20100644=0A---=20= a/test/lisp/autorevert-tests.el=0A+++=20b/test/lisp/autorevert-tests.el=0A= @@=20-1,4=20+1,4=20@@=0A-;;;=20auto-revert-tests.el=20---=20Tests=20of=20= auto-revert=0A+;;;=20auto-revert-tests.el=20---=20Tests=20of=20= auto-revert=20=20=20-*-=20lexical-binding:=20t=20-*-=0A=20=0A=20;;=20= Copyright=20(C)=202015-2019=20Free=20Software=20Foundation,=20Inc.=0A=20=0A= @@=20-433,6=20+433,111=20@@=20This=20expects=20`auto-revert--messages'=20= to=20be=20bound=20by=0A=20(auto-revert--deftest-remote=20= auto-revert-test04-auto-revert-mode-dired=0A=20=20=20"Check=20remote=20= autorevert=20for=20dired.")=0A=20=0A+(defun=20= auto-revert-test--write-file=20(string=20file)=0A+=20=20"Write=20STRING=20= to=20FILE."=0A+=20=20(write-region=20string=20nil=20file=20nil=20= 'no-message))=0A+=0A+(defun=20auto-revert-test--buffer-string=20(buffer)=0A= +=20=20"Contents=20of=20BUFFER=20as=20a=20string."=0A+=20=20= (with-current-buffer=20buffer=0A+=20=20=20=20(buffer-string)))=0A+=0A= +(defun=20auto-revert-test--wait-for=20(pred=20max-wait)=0A+=20=20"Wait=20= until=20PRED=20is=20true,=20or=20MAX-WAIT=20seconds=20elapsed."=0A+=20=20= (let=20((ct=20(current-time)))=0A+=20=20=20=20(while=20(and=20(<=20= (float-time=20(time-subtract=20(current-time)=20ct))=20max-wait)=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20(not=20(funcall=20pred)))=0A+=20= =20=20=20=20=20(read-event=20nil=20nil=200.1))))=0A+=0A+(defun=20= auto-revert-test--wait-for-buffer-text=20(buffer=20string=20max-wait)=0A= +=20=20"Wait=20until=20BUFFER=20has=20the=20contents=20STRING,=20or=20= MAX-WAIT=20seconds=20elapsed."=0A+=20=20(auto-revert-test--wait-for=0A+=20= =20=20(lambda=20()=20(string-equal=20(auto-revert-test--buffer-string=20= buffer)=20string))=0A+=20=20=20max-wait))=0A+=0A+(ert-deftest=20= auto-revert-test05-global-notify=20()=0A+=20=20"Test=20= `global-auto-revert-mode'=20without=20polling."=0A+=20=20:tags=20= '(:expensive-test)=0A+=20=20(skip-unless=20(or=20file-notify--library=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(file-remote-p=20= temporary-file-directory)))=0A+=20=20(let*=20((auto-revert-use-notify=20= t)=0A+=20=20=20=20=20=20=20=20=20(auto-revert-avoid-polling=20t)=0A+=20=20= =20=20=20=20=20=20=20(was-in-global-auto-revert-mode=20= global-auto-revert-mode)=0A+=20=20=20=20=20=20=20=20=20(file-1=20= (make-temp-file=20"global-auto-revert-test-1"))=0A+=20=20=20=20=20=20=20=20= =20(file-2=20(make-temp-file=20"global-auto-revert-test-2"))=0A+=20=20=20= =20=20=20=20=20=20(file-3=20(make-temp-file=20= "global-auto-revert-test-3"))=0A+=20=20=20=20=20=20=20=20=20(file-2b=20= (concat=20file-2=20"-b"))=0A+=20=20=20=20=20=20=20=20=20buf-1=20buf-2=20= buf-3)=0A+=20=20=20=20(unwind-protect=0A+=20=20=20=20=20=20=20=20(progn=0A= +=20=20=20=20=20=20=20=20=20=20(setq=20buf-1=20(find-file-noselect=20= file-1))=0A+=20=20=20=20=20=20=20=20=20=20(setq=20buf-2=20= (find-file-noselect=20file-2))=0A+=20=20=20=20=20=20=20=20=20=20= (auto-revert-test--write-file=20"1-a"=20file-1)=0A+=20=20=20=20=20=20=20=20= =20=20(should=20(equal=20(auto-revert-test--buffer-string=20buf-1)=20= ""))=0A+=0A+=20=20=20=20=20=20=20=20=20=20(global-auto-revert-mode=201)=20= =20=20;=20Turn=20it=20on.=0A+=0A+=20=20=20=20=20=20=20=20=20=20(should=20= (buffer-local-value=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20'auto-revert-notify-watch-descriptor=20buf-1))=0A+=20=20=20=20=20=20= =20=20=20=20(should=20(buffer-local-value=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20'auto-revert-notify-watch-descriptor=20= buf-2))=0A+=0A+=20=20=20=20=20=20=20=20=20=20;;=20buf-1=20should=20have=20= been=20reverted=20immediately=20when=20the=20mode=0A+=20=20=20=20=20=20=20= =20=20=20;;=20was=20enabled.=0A+=20=20=20=20=20=20=20=20=20=20(should=20= (equal=20(auto-revert-test--buffer-string=20buf-1)=20"1-a"))=0A+=0A+=20=20= =20=20=20=20=20=20=20=20;;=20Alter=20a=20file.=0A+=20=20=20=20=20=20=20=20= =20=20(auto-revert-test--write-file=20"2-a"=20file-2)=0A+=20=20=20=20=20=20= =20=20=20=20;;=20Allow=20for=20some=20time=20to=20handle=20notification=20= events.=0A+=20=20=20=20=20=20=20=20=20=20= (auto-revert-test--wait-for-buffer-text=20buf-2=20"2-a"=201)=0A+=20=20=20= =20=20=20=20=20=20=20(should=20(equal=20(auto-revert-test--buffer-string=20= buf-2)=20"2-a"))=0A+=0A+=20=20=20=20=20=20=20=20=20=20;;=20Visit=20a=20= file,=20and=20modify=20it=20on=20disk.=0A+=20=20=20=20=20=20=20=20=20=20= (setq=20buf-3=20(find-file-noselect=20file-3))=0A+=20=20=20=20=20=20=20=20= =20=20;;=20Newly=20opened=20buffers=20won't=20be=20use=20notification=20= until=20the=0A+=20=20=20=20=20=20=20=20=20=20;;=20first=20poll=20cycle;=20= wait=20for=20it.=0A+=20=20=20=20=20=20=20=20=20=20= (auto-revert-test--wait-for=0A+=20=20=20=20=20=20=20=20=20=20=20(lambda=20= ()=20(buffer-local-value=0A+=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-notify-watch-descriptor=20buf-3))=0A= +=20=20=20=20=20=20=20=20=20=20=20(+=20auto-revert-interval=201))=0A+=20=20= =20=20=20=20=20=20=20=20(should=20(buffer-local-value=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20= 'auto-revert-notify-watch-descriptor=20buf-3))=0A+=20=20=20=20=20=20=20=20= =20=20(auto-revert-test--write-file=20"3-a"=20file-3)=0A+=20=20=20=20=20=20= =20=20=20=20(auto-revert-test--wait-for-buffer-text=20buf-3=20"3-a"=201)=0A= +=20=20=20=20=20=20=20=20=20=20(should=20(equal=20= (auto-revert-test--buffer-string=20buf-3)=20"3-a"))=0A+=0A+=20=20=20=20=20= =20=20=20=20=20;;=20Delete=20a=20visited=20file,=20and=20re-create=20it=20= with=20new=20contents.=0A+=20=20=20=20=20=20=20=20=20=20(delete-file=20= file-1)=0A+=20=20=20=20=20=20=20=20=20=20(sleep-for=200.5)=0A+=20=20=20=20= =20=20=20=20=20=20(should=20(equal=20(auto-revert-test--buffer-string=20= buf-1)=20"1-a"))=0A+=20=20=20=20=20=20=20=20=20=20= (auto-revert-test--write-file=20"1-b"=20file-1)=0A+=20=20=20=20=20=20=20=20= =20=20(auto-revert-test--wait-for-buffer-text=20buf-1=20"1-b"=0A+=20=20=20= =20=20=20=20=20=20=20=20(+=20auto-revert-interval=201))=0A+=20=20=20=20=20= =20=20=20=20=20(should=20(buffer-local-value=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20'auto-revert-notify-watch-descriptor=20= buf-1))=0A+=0A+=20=20=20=20=20=20=20=20=20=20;;=20Write=20a=20buffer=20= to=20a=20new=20file,=20then=20modify=20the=20new=20file=20on=20disk.=0A+=20= =20=20=20=20=20=20=20=20=20(with-current-buffer=20buf-2=0A+=20=20=20=20=20= =20=20=20=20=20=20=20(write-file=20file-2b))=0A+=20=20=20=20=20=20=20=20=20= =20(should=20(equal=20(auto-revert-test--buffer-string=20buf-2)=20= "2-a"))=0A+=20=20=20=20=20=20=20=20=20=20(auto-revert-test--write-file=20= "2-b"=20file-2b)=0A+=20=20=20=20=20=20=20=20=20=20= (auto-revert-test--wait-for-buffer-text=20buf-2=20"2-b"=0A+=20=20=20=20=20= =20=20=20=20=20=20(+=20auto-revert-interval=201))=0A+=20=20=20=20=20=20=20= =20=20=20(should=20(buffer-local-value=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20'auto-revert-notify-watch-descriptor=20buf-2)))=0A= +=0A+=20=20=20=20=20=20;;=20Clean=20up.=0A+=20=20=20=20=20=20(unless=20= was-in-global-auto-revert-mode=0A+=20=20=20=20=20=20=20=20= (global-auto-revert-mode=200))=20=20=20=20;=20Turn=20it=20off.=0A+=20=20=20= =20=20=20(dolist=20(buf=20(list=20buf-1=20buf-2=20buf-3))=0A+=20=20=20=20= =20=20=20=20(ignore-errors=20(kill-buffer=20buf)))=0A+=20=20=20=20=20=20= (dolist=20(file=20(list=20file-1=20file-2=20file-2b=20file-3))=0A+=20=20=20= =20=20=20=20=20(ignore-errors=20(delete-file=20file)))=0A+=20=20=20=20=20= =20)))=0A+=0A+(auto-revert--deftest-remote=20= auto-revert-test04-auto-revert-mode-dired=0A+=20=20"Test=20= `global-auto-revert-mode'=20without=20polling=20for=20remote=20= buffers.")=0A+=0A=20(defun=20auto-revert-test-all=20(&optional=20= interactive)=0A=20=20=20"Run=20all=20tests=20for=20\\[auto-revert]."=0A=20= =20=20(interactive=20"p")=0A--=20=0A2.20.1=20(Apple=20Git-117)=0A=0A= --Apple-Mail=_EF6DBC5C-583C-44D9-B8C9-D2D2DA0C277A--