]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle an error of file-notify-add-watch in autorevert.el
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 21 Jul 2025 07:24:23 +0000 (09:24 +0200)
committerEshel Yaron <me@eshelyaron.com>
Fri, 25 Jul 2025 08:10:50 +0000 (10:10 +0200)
* lisp/autorevert.el (auto-revert-notify-add-watch):
Disable `auto-revert-use-notify' in the buffer when
`file-notify-add-watch' fails.

(cherry picked from commit ef84a1b2d65e187988ae4e66306ac17244a68fc5)

lisp/autorevert.el

index 492bb565c256754fa3463e93be50e858eb79fbf4..a634756fcc103a0eeb931bae38d899fd178a721e 100644 (file)
@@ -671,12 +671,13 @@ will use an up-to-date value of `auto-revert-interval'."
               file
                (if buffer-file-name '(change attribute-change) '(change))
                'auto-revert-notify-handler))))
-      (when auto-revert-notify-watch-descriptor
-        (setq auto-revert-notify-modified-p t
-              auto-revert--buffer-by-watch-descriptor
-              (cons (cons auto-revert-notify-watch-descriptor (current-buffer))
-                    auto-revert--buffer-by-watch-descriptor))
-        (add-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch nil t))))
+    (if (null auto-revert-notify-watch-descriptor)
+        (setq-local auto-revert-use-notify nil)
+      (setq auto-revert-notify-modified-p t
+            auto-revert--buffer-by-watch-descriptor
+            (cons (cons auto-revert-notify-watch-descriptor (current-buffer))
+                  auto-revert--buffer-by-watch-descriptor))
+      (add-hook 'kill-buffer-hook #'auto-revert-notify-rm-watch nil t))))
 
 ;; If we have file notifications, we want to update the auto-revert buffers
 ;; immediately when a notification occurs. Since file updates can happen very