emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File watch support in autorevert.el


From: Eli Zaretskii
Subject: Re: File watch support in autorevert.el
Date: Fri, 11 Jan 2013 17:57:52 +0200

> From: Michael Albinus <address@hidden>
> Cc: address@hidden
> Date: Fri, 11 Jan 2013 16:18:46 +0100
> 
> Eli Zaretskii <address@hidden> 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.

You cannot expect that, not in general, because there's no such
promise in the docs of these interfaces.  That's why the interface
returns to you the full information about the transaction.  I don't
think it's wise to ignore that information.

> >  . 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.

Since the documentation clearly says this event is generated when the
file is _closed_, I wonder why a test case is needed.

> >  . 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 don't see this in Emacs 24.2.92 on Windows.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]