Subject: bug#26126: 26.0.50; file-notify-rm-watch removes arbitrary watches

From: Michael Albinus <[email-masked]>
Date: Sat, 18 Mar 2017 20:49:22 +0100

Andreas Politz <[email-masked]> writes:

Hi Andreas,

> Do you remember what this comment from file-notify-callback is talking
> about ?
>
> #+BEGIN_SRC emacs-lisp
> ((memq action '(moved rename))
>  ;; The kqueue rename event does not return file1 in
>  ;; case a file monitor is established.
>  (if (setq file1 (file-notify--event-file1-name event))
>      'renamed 'deleted))
> #+END_SRC

kqueue is the oldest of he supported native libraries. It is the only
one (IIRC), which does not return source and target file name in case of
a rename. That's why that the kqueue `rename' event is transformed into
a `deleted' event. This is what the comment is speaking about.

I admit it would be more understandable if there would be an overview of
the events and their arguments, the different libraries are sending.

> And file-notify--event-file1-name basically returns nil, if the file1
> argument of event is not a string.  But this seems to contradict the
> comment, which states that file1 *is* nil, implying that the stored
> filename should be used, or not ?

The fourth slot of an event structure could be either a string (file1)
or a cookie, or nil. This is tried to check.

> -ap

Best regards, Michael.