Subject: bug#21432: 25.0.50; file-notify-rm-watch (inotify) errors if watched dir is deleted

From: Eli Zaretskii <[email-masked]>
Date: Tue, 08 Sep 2015 18:49:36 +0300

> From: Tassilo Horn <[email-masked]>
> Date: Tue, 08 Sep 2015 08:36:06 +0200
> 
> Right now, (at least) the inotify version of `file-notify-rm-watch'
> signals an error in case the given descriptor denotes a directory which
> has been deleted in the meantime.  If it denotes a file which has been
> deleted, no error is signaled.
> 
> Here's a receipe:
> 
> (require 'filenotify)
> (let* ((flags '(change))
>        (handler (lambda () nil))
>        (file (make-temp-file "foo"))
>        (file-watch (file-notify-add-watch file flags handler))
>        (dir (make-temp-file "bar" t))
>        (dir-watch (file-notify-add-watch dir flags handler)))
>   (delete-file file)
>   (delete-directory dir)
>   (file-notify-rm-watch file-watch)    ;; works
>   (message "Removed file watch")
>   (file-notify-rm-watch dir-watch)     ;; signals an error
>   (message "Removed directory watch"))
> 
> The documentation does not define any specific behavior for these
> situation, so this is currently a gray area which makes it hard for
> package developers to develop something which will work right accross
> the different notification backends.
> 
> I don't have a strong opinion about what the right behavior would be but
> at least it seems inconsistent that you get the error only with deleted
> directories.

There is no "right" behavior.  What you see is what the back-end
reports to us.  If we want Emacs to be smarter, it's the job of the
application, not of filenotify.el.