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#36159: [PATCH] auto-revert mode doesn't work when changing buffer file name Date: Tue, 11 Jun 2019 18:55:41 +0200 Message-ID: <7390BA99-AA1F-4A87-85A5-FDCCF3E3C125@acm.org> References: <8736kgjmag.fsf@gmx.de> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_3B5D8334-6829-4050-A4BE-649795E1E17F" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="91287"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 36159@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 11 19:10:01 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.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hakHY-000Nat-9U for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Jun 2019 19:10:00 +0200 Original-Received: from localhost ([::1]:33132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hakHX-0004K5-6V for geb-bug-gnu-emacs@m.gmane.org; Tue, 11 Jun 2019 13:09:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52997) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hak44-0000Vu-DZ for bug-gnu-emacs@gnu.org; Tue, 11 Jun 2019 12:56:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hak42-0006H8-Q4 for bug-gnu-emacs@gnu.org; Tue, 11 Jun 2019 12:56:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46544) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hak42-0006FC-0P for bug-gnu-emacs@gnu.org; Tue, 11 Jun 2019 12:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hak41-0001P0-QX for bug-gnu-emacs@gnu.org; Tue, 11 Jun 2019 12:56:01 -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: Tue, 11 Jun 2019 16:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36159 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 36159-submit@debbugs.gnu.org id=B36159.15602721565379 (code B ref 36159); Tue, 11 Jun 2019 16:56:01 +0000 Original-Received: (at 36159) by debbugs.gnu.org; 11 Jun 2019 16:55:56 +0000 Original-Received: from localhost ([127.0.0.1]:60088 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hak3v-0001Oh-QO for submit@debbugs.gnu.org; Tue, 11 Jun 2019 12:55:56 -0400 Original-Received: from mail213c50.megamailservers.eu ([91.136.10.223]:57044 helo=mail194c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hak3q-0001OO-Jo for 36159@debbugs.gnu.org; Tue, 11 Jun 2019 12:55:51 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1560272144; bh=u6DS8pdy2wxLaLexzEvYwI9wPMXLH973zi9PUWjtLyk=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=IfldfQGsLE3X4k7Pn6EFhLZzbSWQx4SBkmrlagwYMZOj7pH7CtnvvOuoHimT0U1NP IbZ06AE/sHBVyG9ZrlAQfZpTxwXiACTayH+zuxb1mkics6dbLtruQIQVgFyqvCXm92 HvucTkoLij3RmM8/C7E5/vYIEqUF4lIMH6h0vHj0= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] ([188.150.171.71]) (authenticated bits=0) by mail194c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id x5BGtgmn022257; Tue, 11 Jun 2019 16:55:43 +0000 In-Reply-To: <8736kgjmag.fsf@gmx.de> X-Mailer: Apple Mail (2.3445.104.11) X-CTCH-RefID: str=0001.0A0B0214.5CFFDD10.002D, 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=OuZhNR3t c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=TBZ5LnL9W2t596cT49UA:9 a=CjuIK1q_8ugA:10 a=x-1L5Np1jqKB85HmLn8A: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:160388 Archived-At: --Apple-Mail=_3B5D8334-6829-4050-A4BE-649795E1E17F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 11 juni 2019 kl. 15.15 skrev Michael Albinus : >=20 >> +(defun auto-revert--set-visited-file-name () >=20 > Since we add it to a hook from another package, it shouldn't be marked > internal. Call it `auto-revert-set-visited-file-name'. Done. I actually wanted to add a buffer-local hook, but it turns out = that `after-set-visited-file-name-hook', as written, wouldn't work for = local hooks -- the very action of `set-visited-file-name' wipes out = local hooks, no doubt for good reasons, before they can trigger. > In the other tests, we separate the unwindforms from the bodyform (an > empty line, plus a comment). Maybe you could do it here as well. Done. I also removed the binding of `auto-revert-avoid-polling' in the new = test, since it isn't strictly necessary to exhibit the bug. > FAILED auto-revert-test05-global-notify-remote > FAILED auto-revert-test06-write-file-remote >=20 > Do you want to check, or shall I do it? Oh, would you do that? I feel bad about causing test failures like this! The first error may be from a recently committed (f2e4c34de6) fix of an = earlier copy-paste mistake; sorry about that. I'm unsure how to deal = with these errors myself; I have no inotifywait equivalent on this = machine (macOS). Thanks a lot for your help! --Apple-Mail=_3B5D8334-6829-4050-A4BE-649795E1E17F Content-Disposition: attachment; filename=0001-Keep-auto-revert-mode-working-when-changing-buffer-f.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Keep-auto-revert-mode-working-when-changing-buffer-f.patch" Content-Transfer-Encoding: quoted-printable =46rom=204baa9d2f7e704cc722e962a4ab5245157f0ff547=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Mon,=2010=20Jun=202019=2017:52:50=20+0200=0A= Subject:=20[PATCH]=20Keep=20auto-revert-mode=20working=20when=20changing=20= buffer=20file=20name=0A=0A*=20lisp/autorevert.el=20= (after-set-visited-file-name-hook):=0AAdd=20unconditionally.=0A= (global-auto-revert-mode):=20Don't=20use=0A= `after-set-visited-file-name-hook'=20here.=0A= (auto-revert-set-visited-file-name):=20Rename=20from=0A= `auto-revert--global-set-visited-file-name'=20and=20generalise.=0A*=20= test/lisp/autorevert-tests.el=20(auto-revert-test06-write-file):=20New.=0A= ---=0A=20lisp/autorevert.el=20=20=20=20=20=20=20=20=20=20=20=20|=2019=20= ++++++++++---------=0A=20test/lisp/autorevert-tests.el=20|=2034=20= ++++++++++++++++++++++++++++++++++=0A=202=20files=20changed,=2044=20= insertions(+),=209=20deletions(-)=0A=0Adiff=20--git=20= a/lisp/autorevert.el=20b/lisp/autorevert.el=0Aindex=20= 2de855b303..5c79a7e795=20100644=0A---=20a/lisp/autorevert.el=0A+++=20= b/lisp/autorevert.el=0A@@=20-347,6=20+347,8=20@@=20= auto-revert-find-file-function=0A=20=0A=20(add-hook=20'find-file-hook=0A=20= =09=20=20#'auto-revert-find-file-function)=0A+(add-hook=20= 'after-set-visited-file-name-hook=0A+=20=20=20=20=20=20=20=20=20=20= #'auto-revert-set-visited-file-name)=0A=20=0A=20(defvar=20= auto-revert--buffers-by-watch-descriptor=0A=20=20=20(make-hash-table=20= :test=20'equal)=0A@@=20-508,8=20+510,6=20@@=20global-auto-revert-mode=0A=20= =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= ;;=20Make=20sure=20future=20buffers=20are=20added=20as=20well.=0A=20=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=20= ;;=20To=20track=20non-file=20buffers,=20we=20need=20to=20listen=20in=20= to=20buffer=0A=20=20=20=20=20=20=20=20=20;;=20creation=20in=20general.=20= =20Listening=20to=20major-mode=20changes=20is=0A=20=20=20=20=20=20=20=20=20= ;;=20suitable,=20since=20we=20then=20know=20whether=20it's=20a=20mode=20= that=20is=20tracked.=0A@@=20-520,8=20+520,6=20@@=20= global-auto-revert-mode=0A=20=20=20=20=20;;=20Turn=20= global-auto-revert-mode=20OFF.=0A=20=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=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=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-551,14=20+549,17=20@@=20auto-revert--global-adopt-current-buffer=0A= =20=20=20(auto-revert--global-add-current-buffer)=0A=20=20=20= (auto-revert-set-timer))=0A=20=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+(defun=20= auto-revert-set-visited-file-name=20()=0A+=20=20"Update=20Auto-Revert=20= management=20of=20the=20current=20buffer.=0A=20Called=20after=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=20= (when=20auto-revert-notify-watch-descriptor=0A+=20=20=20=20;;=20Remove=20= any=20existing=20notifier=20so=20that=20we=20don't=20track=20the=20wrong=0A= +=20=20=20=20;;=20file=20in=20case=20the=20file=20name=20was=20changed.=0A= =20=20=20=20=20(auto-revert-notify-rm-watch))=0A-=20=20= (auto-revert--global-adopt-current-buffer))=0A+=20=20=20=20(cond=20= (global-auto-revert-mode=0A+=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=20= =20((or=20auto-revert-mode=20auto-revert-tail-mode)=0A+=20=20=20=20=20=20= =20=20=20=20=20(auto-revert-set-timer))))=0A=20=0A=20(defun=20= auto-revert--polled-buffers=20()=0A=20=20=20"List=20of=20buffers=20that=20= need=20to=20be=20polled."=0Adiff=20--git=20= a/test/lisp/autorevert-tests.el=20b/test/lisp/autorevert-tests.el=0A= index=203c9e04bf19..f21fb864f2=20100644=0A---=20= a/test/lisp/autorevert-tests.el=0A+++=20b/test/lisp/autorevert-tests.el=0A= @@=20-542,6=20+542,40=20@@=20auto-revert-test--wait-for-buffer-text=0A=20= (auto-revert--deftest-remote=20auto-revert-test05-global-notify=0A=20=20=20= "Test=20`global-auto-revert-mode'=20without=20polling=20for=20remote=20= buffers.")=0A=20=0A+(ert-deftest=20auto-revert-test06-write-file=20()=0A= +=20=20"Verify=20that=20notification=20follows=20`write-file'=20= correctly."=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=20temporary-file-directory)))=0A+=20=20(let*=20= ((auto-revert-use-notify=20t)=0A+=20=20=20=20=20=20=20=20=20(file-1=20= (make-temp-file=20"auto-revert-test"))=0A+=20=20=20=20=20=20=20=20=20= (file-2=20(concat=20file-1=20"-2"))=0A+=20=20=20=20=20=20=20=20=20(buf=20= nil))=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=20(find-file-noselect=20= file-1))=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(insert=20"A")=0A+=20=20=20=20=20=20=20=20= =20=20=20=20(save-buffer)=0A+=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (auto-revert-mode=201)=0A+=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (insert=20"B")=0A+=20=20=20=20=20=20=20=20=20=20=20=20(write-file=20= file-2)=0A+=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (auto-revert-test--write-file=20"C"=20file-2)=0A+=20=20=20=20=20=20=20=20= =20=20=20=20(auto-revert-test--wait-for-buffer-text=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20buf=20"C"=20(+=20auto-revert-interval=201))=0A+=20=20= =20=20=20=20=20=20=20=20=20=20(should=20(equal=20(buffer-string)=20= "C"))))=0A+=0A+=20=20=20=20=20=20;;=20Clean=20up.=0A+=20=20=20=20=20=20= (ignore-errors=20(kill-buffer=20buf))=0A+=20=20=20=20=20=20= (ignore-errors=20(delete-file=20file-1))=0A+=20=20=20=20=20=20= (ignore-errors=20(delete-file=20file-2)))))=0A+=0A= +(auto-revert--deftest-remote=20auto-revert-test06-write-file=0A+=20=20= "Test=20`write-file'=20in=20`auto-revert-mode'=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=_3B5D8334-6829-4050-A4BE-649795E1E17F--