From: João Távora Date: Sun, 2 Apr 2023 22:01:29 +0000 (+0100) Subject: Eglot: don't watch directories that don't exist X-Git-Tag: emacs-29.0.90~37 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=86cf9fd932c654cc502bedf634458a918ee5e9cb;p=emacs.git Eglot: don't watch directories that don't exist project-files isn't guaranteed to return existing files, so better check if they exist because placing a watcher on them. Originally reported at: https://github.com/joaotavora/eglot/issues/1198 * lisp/progmodes/eglot.el (eglot-register-capability workspace/didChangeWatchedFiles): Check if directories exist. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 8f64f849d72..4a9209ab9b4 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3433,8 +3433,9 @@ at point. With prefix argument, prompt for ACTION-KIND." (unwind-protect (progn (dolist (dir dirs-to-watch) - (push (file-notify-add-watch dir '(change) #'handle-event) - (gethash id (eglot--file-watches server)))) + (when (file-readable-p dir) + (push (file-notify-add-watch dir '(change) #'handle-event) + (gethash id (eglot--file-watches server))))) (setq success `(:message ,(format "OK, watching %s directories in %s watchers"