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

From: Michael Albinus <[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?

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

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. I haven't changed it in gfilenotify yet, it's on my todo
list. And the manual must be adapted, as Tassilo has said.

Best regards, Michael.

PS: Tassilo, you write great test cases. Do you want to contribute to
test/automated/file-notify-tests.el?

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