Subject: bug#21435: 25.0.50; file-notify has problems after renames

From: Eli Zaretskii <[email-masked]>
Date: Tue, 08 Sep 2015 21:21:37 +0300

> From: Michael Albinus <[email-masked]>
> Cc: Tassilo Horn <[email-masked]>,  [email-masked]
> Date: Tue, 08 Sep 2015 20:04:20 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > IOW, technically, the file/directory you watched disappeared from the
> > filesystem, so what is reported afterwards is IMO entirely resonable
> > at this low level.
> 
> Well, inotify sends then the low-level event `delete-self', which is
> different from the usual `delete'. filenotify.el translates both to the
> upper-level event `deleted'. In case of `delete-self', filenotify.el
> could do something more, like removing the watch. Do we want this?

I don't think filenotify.el should remove the watch on its own, but it
could send an event that would allow the application do that if it
wants to.

> > One application we have on top of filenotify.el is auto-revert.el.
> > Now, if you see some user-level problems there when files are
> > renamed/deleted, please report them.
> >
> >> Another thing is that renames always seem to be reported twice (although
> >> the example in the manual lists only one event but that example has
> >> probably gathered with the gfilenotify backend).
> >
> > This doesn't happen with w32notify.  filenotify.el includes some code
> > to produce a single notification out of the 2 reported by back-ends in
> > this case; perhaps something doesn't work there with inotify.  Can you
> > step through the code and see why?
> 
> Two days ago (commit dbdc459a48091f5953faf14bcaaa7e6d37fbf024), I've
> changed filenotify.el to fire 2 events `renamed' in case the directories
> of the source and target are different. This was triggered by a user
> report, that he wants to have auto-revert-mode for two different
> directories under dired control. So the event is sent for the two
> different handlers activated by the respective *-add-watch calls.

But then Tassilo's "renames always seem to be reported twice" is
inaccurate: this should only happen when a file is moved to another
directory.

> I've tested for inotify, it works (confirmed by that user). The use case
> of that user was, that a file has been moved outside Emacs from one
> directory to the other. An he wanted to see it in both dired buffers,
> immediately.
> 
> I couldn't test this for w32notify, but it should behave like this since
> Sunday.

If you can show some simple test case, I can run it.

> PPS: Forgive me slow progress; I'm still suffering from health problems.

Wish you to recover quickly.