unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Eli Zaretskii <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: File watch support in autorevert.el
Date: Fri, 11 Jan 2013 16:18:46 +0100	[thread overview]
Message-ID: <87ip73n3xl.fsf@gmx.de> (raw)
In-Reply-To: <83fw28uj9c.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 11 Jan 2013 12:05:51 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

>  . The code as written is too naive: it blindly assumes that every
>    single notification reported by the filesystem for a given watch is
>    necessarily the one requested in the auto-revert-notify-add-watch
>    call.  But that assumption is false, at least on Windows, where the
>    implementation actually watches events to the entire parent
>    directory of the file we are interested in.  So Emacs reverts the
>    file whenever _any_ file in the same directory was changed.  I
>    believe similar problems can happen with inotify, albeit much more
>    rarely.  For that reason, I think auto-revert-notify-handler should
>    filter events by ASPECTS/ACTION member, and on Windows also by FILE
>    member of the event.

Will do for the inotify case. It is a simple bit easier, because you can
install a file watch for exactly one file, and you can expect it returns
for that file only.

This will be different, when we implement `dired-buffer-stale-p' based
on file watches.

In general, something like IN_DELETE* and IN_MOVE* must be handled
properly. That's clearly missing in my first shot.

>  . It isn't clear to me that using IN_CLOSE_WRITE with inotify is TRT:
>    AFAIU, that would mean we only revert a file when the application
>    writing to it closes its descriptor.  IOW, if the application makes
>    several changes to the file during a prolonged operation, and
>    doesn't close and reopen the file in between, we will only see the
>    changes at the end, but not during the operation.  Wouldn't it be
>    better to use IN_MODIFY instead?

See my other message. I believe IN_CLOSE_WRITE is sufficient for the
inotify case, but I might be wrong. I would need a test case which shows
it.

>  . At least on Windows, turning on auto-revert-mode and then modifying
>    and saving the file announces that it was auto-reverted.  This
>    didn't happen with the auto-revert method that doesn't use file
>    notifications.  Is this a bug?

I have an old Emacs instance, w/o support of inotify in
autorevert.el. There I see the same message.

>  . I believe some of the features added to autorevert.el, such as a
>    hash list of watch descriptors, should be in some infrastructure
>    with appropriate APIs.

Yes. During these tests we want to identify these features. When
possible, I will try to add more general functions in autorevert.el,
which could be extracted later for a general API.

Best regards, Michael.



  parent reply	other threads:[~2013-01-11 15:18 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-10 14:28 File watch support in autorevert.el Michael Albinus
2013-01-10 17:11 ` Stefan Monnier
2013-01-10 17:14   ` Lennart Borgman
2013-01-10 20:38   ` Michael Albinus
2013-01-11 10:05 ` Eli Zaretskii
2013-01-11 14:34   ` Stefan Monnier
2013-01-11 14:43     ` Eli Zaretskii
2013-01-11 15:01       ` Michael Albinus
2013-01-11 15:50         ` Eli Zaretskii
2013-01-11 16:09           ` Michael Albinus
2013-01-11 19:19             ` Eli Zaretskii
2013-01-11 16:19           ` Michael Albinus
2013-01-11 16:39         ` Stefan Monnier
2013-01-11 22:43           ` Michael Albinus
2013-01-12 11:28             ` Eli Zaretskii
2013-01-12 13:34               ` Michael Albinus
2013-01-12 15:09                 ` Eli Zaretskii
2013-01-12 19:08                   ` Michael Albinus
2013-01-17  9:38                   ` Michael Albinus
2013-01-17 16:54                     ` Eli Zaretskii
2013-01-17 19:19                       ` Michael Albinus
2013-01-17 19:39                         ` Eli Zaretskii
2013-01-11 15:57       ` Stefan Monnier
2013-01-11 15:18   ` Michael Albinus [this message]
2013-01-11 15:57     ` Eli Zaretskii
2013-01-11 16:31       ` Michael Albinus
2013-01-11 18:47         ` Eli Zaretskii
2013-01-11 16:44     ` Stefan Monnier
2013-01-11 22:47       ` Michael Albinus
2013-01-12 11:36         ` Eli Zaretskii
2013-01-12 13:14           ` Michael Albinus
2013-01-12 14:06             ` Eli Zaretskii
2013-01-12 14:16               ` Michael Albinus
2013-01-11 22:39   ` Michael Albinus
2013-01-11 23:01   ` Michael Albinus
2013-01-12 11:31     ` Eli Zaretskii
2013-01-12 13:08       ` Michael Albinus
2013-01-12 13:26         ` Michael Albinus
2013-01-12 14:03         ` Eli Zaretskii
2013-01-12 14:12           ` Michael Albinus
2013-01-12 14:39             ` Eli Zaretskii
2013-01-12 19:04               ` Michael Albinus

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87ip73n3xl.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).