all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: zhang cc <ccsmile2008@outlook.com>
To: Michael Albinus <michael.albinus@gmx.de>, Eli Zaretskii <eliz@gnu.org>
Cc: "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: auto-revert error on macOS when auto-revert-use-notify is t
Date: Fri, 29 Dec 2017 15:45:35 +0000	[thread overview]
Message-ID: <SG2PR0601MB140554B8E95DDDE450C9324BA8050@SG2PR0601MB1405.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <83r2rdg7u3.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 3342 bytes --]

It seems that this not a bug, but a user experience issue. It is not convenient to tweak vim and
other apps which can modify file.

What about the following logic:
When the auto-revert module known the file is renamed or deleted, delete the watch
and start a one shot short timer(about 100ms) to check the visiting file of the buffer. On timeout,
if the file exists, revert the file and add a new watch, otherwise, tell user the file doesn’t exist
and fallback to the default polling(5s).
Once the visiting file of the buffer can be accessed, go back to use file-notify again.

On 29 Dec 2017, 6:14 PM +0800, Eli Zaretskii <eliz@gnu.org>, wrote:
From: Michael Albinus <michael.albinus@gmx.de
Date: Fri, 29 Dec 2017 11:02:10 +0100
Cc: "emacs-devel@gnu.org" <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 #<buffer
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) #<bytecode 0x40a952e1>)(13
(#<buffer 1.c>))
maphash(#f(compiled-function (key value) #<bytecode 0x40a952e1>)
#<hash-table equal 7/65 0x40e7896d>)
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)))) <<<<<<<<<<<<<

[-- Attachment #2: Type: text/html, Size: 4716 bytes --]

  reply	other threads:[~2017-12-29 15:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-29  5:08 auto-revert error on macOS when auto-revert-use-notify is t zhang cc
2017-12-29 10:02 ` Michael Albinus
2017-12-29 10:13   ` Eli Zaretskii
2017-12-29 15:45     ` zhang cc [this message]
2018-01-02 13:23       ` Michael Albinus
2018-01-05 14:47         ` zhang cc
2018-01-20 15:34           ` Michael Albinus
2018-01-21 11:01             ` zhang cc
2018-01-21 20:16             ` Alan Third
2018-01-22  8:17               ` Michael Albinus
2018-01-22 23:05                 ` Alan Third
2018-03-11  4:26                   ` zhang cc
     [not found]                   ` <18101cae-50ff-44a2-af65-f77b9039f461@Spark>
2018-03-11  4:29                     ` zhang cc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SG2PR0601MB140554B8E95DDDE450C9324BA8050@SG2PR0601MB1405.apcprd06.prod.outlook.com \
    --to=ccsmile2008@outlook.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.