Subject: Re: bug#65904: 29.1.50; autorevert can't revert files in a symlink directory

From: Michael Albinus <[email-masked]>
Date: Thu, 14 Sep 2023 13:58:05 +0200

zhanghj <[email-masked]> writes:

Hi,

> How does it work in Emacs 26/27? Why don't you let it keep the old behavior?

That time, it was unspecified, whether symlinked files/directories are
watched. Some file notification backends did, other backends didn't. In
Emacs 29, this was clarified, see (info "(elisp) File Notifications")

--8<---------------cut here---------------start------------->8---
     If FILE is a symlink, it doesn’t follow that link.  Just FILE
     itself will be watched.
--8<---------------cut here---------------end--------------->8---

There is the idea to add a new flag to the `file-notify-add-watch'
function, `follow'. This would allow to follow symlinks, with different
implementations in the different backends. Buth this hasn't been
implemented yet.

If you need this feature urgently in inotify (I guess you're using this
backend), try the appended patch in filenotify.el (untested).

Best regards, Michael.

diff --git a/lisp/filenotify.el b/lisp/filenotify.el
index e9f8d4e515d..6025f35cb6e 100644
--- a/lisp/filenotify.el
+++ b/lisp/filenotify.el
@@ -339,7 +339,6 @@ file-notify--add-watch-inotify
   "Add a watch for FILE in DIR with FLAGS, using inotify."
   (inotify-add-watch dir
                      (append
-                      '(dont-follow)
                       (and (memq 'change flags)
                            '(create delete delete-self modify move-self move))
                       (and (memq 'attribute-change flags)