From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: auto-revert error on macOS when auto-revert-use-notify is t Date: Fri, 29 Dec 2017 12:13:40 +0200 Message-ID: <83r2rdg7u3.fsf@gnu.org> References: <87po6xvom5.fsf@gmx.de> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1514542335 8952 195.159.176.226 (29 Dec 2017 10:12:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 29 Dec 2017 10:12:15 +0000 (UTC) Cc: emacs-devel@gnu.org, ccsmile2008@outlook.com To: Michael Albinus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 29 11:12:11 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUre6-0001r6-0Q for ged-emacs-devel@m.gmane.org; Fri, 29 Dec 2017 11:12:10 +0100 Original-Received: from localhost ([::1]:35464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUrg4-0005SC-Ne for ged-emacs-devel@m.gmane.org; Fri, 29 Dec 2017 05:14:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUrfu-0005QM-V1 for emacs-devel@gnu.org; Fri, 29 Dec 2017 05:14:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eUrfq-0001zH-EB for emacs-devel@gnu.org; Fri, 29 Dec 2017 05:14:02 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:39665) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eUrfq-0001z8-Ae; Fri, 29 Dec 2017 05:13:58 -0500 Original-Received: from [176.228.60.248] (port=3144 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eUrfp-0002K7-BD; Fri, 29 Dec 2017 05:13:57 -0500 In-reply-to: <87po6xvom5.fsf@gmx.de> (message from Michael Albinus on Fri, 29 Dec 2017 11:02:10 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:221452 Archived-At: > From: Michael Albinus > Date: Fri, 29 Dec 2017 11:02:10 +0100 > Cc: "emacs-devel@gnu.org" > > > Emacs: 26.0.90 > > OS: macOS 10.13.2 > > > > 1. start Emacs with -Q > > 2. open a test file (like 1.c) > > 3. turn on auto-revert-mode by run global-auto-revert-mode > > 4. add auto-revert-use-notify as a watcher variable by > > debug-on-variable-change > > 5. open the test file with vim > > 6. modify the test file in vim and save it > > 7. Emacs enter debug with the following msg: > > > > Debugger entered--setting auto-revert-use-notify in buffer 1.c to nil: > > debug--implement-debug-watch(auto-revert-use-notify nil set # > 1.c>) > > auto-revert-notify-handler((13 stopped "/Users/jun/test/1.c")) > > file-notify--rm-descriptor(13) > > file-notify-rm-watch(13) > > #f(compiled-function (key value) #)(13 > > (#)) > > maphash(#f(compiled-function (key value) #) > > #) > > auto-revert-notify-rm-watch() > > auto-revert-notify-handler((13 stopped "/Users/jun/test/1.c")) > > file-notify--rm-descriptor(13) > > file-notify-rm-watch(13) > > file-notify-callback((13 (rename delete) "/Users/jun/test/1.c")) > > file-notify-handle-event((file-notify (13 (rename delete) > > "/Users/jun/test/1.c") file-notify-callback)) > > funcall-interactively(file-notify-handle-event (file-notify (13 > > (rename delete) "/Users/jun/test/1.c") file-notify-callback)) > > call-interactively(file-notify-handle-event nil [(file-notify (13 > > (rename delete) "/Users/jun/test/1.c") file-notify-callback)]) > > command-execute(file-notify-handle-event nil [(file-notify (13 > > (rename delete) "/Users/jun/test/1.c") file-notify-callback)] t) > > Well, this is not an error. The watchdog over "/Users/jun/test/1.c" > receives the `(rename delete)' events from writing the file. Due to > this, the watchdog is removed, as you see in the backtrace. Exactly, I think this is precisely the expected behavior: step 4 requests the debugger to be entered when auto-revert-use-notify is modified, and auto-revert-notify-handler does modify it when the watched file is deleted: (if (eq action 'stopped) ;; File notification has stopped. Continue with polling. (cl-dolist (buffer (if global-auto-revert-mode (buffer-list) auto-revert-buffer-list)) (with-current-buffer buffer (when (and (equal descriptor auto-revert-notify-watch-descriptor) (or ;; A buffer associated with a file. (and (stringp buffer-file-name) (string-equal (file-name-nondirectory file) (file-name-nondirectory buffer-file-name))) ;; A buffer w/o a file, like dired. (null buffer-file-name))) (auto-revert-notify-rm-watch) (setq-local auto-revert-use-notify nil)))) <<<<<<<<<<<<<