]> git.eshelyaron.com Git - emacs.git/commitdiff
Use project-files to know which directory watchers to skip
authorJoão Távora <joaotavora@gmail.com>
Wed, 26 May 2021 17:51:30 +0000 (18:51 +0100)
committerJoão Távora <joaotavora@gmail.com>
Wed, 26 May 2021 17:51:30 +0000 (18:51 +0100)
The directory-finding logic is probably a bit slower than using
eglot--directories-recursively, but since it honours `.gitignores` and
ignores more directories it's much faster overall.  And guaranteed to
create less watchers.

Thanks to Dmitry Gutov <dgutov@yandex.ru> for the idea.

* eglot.el (eglot--directories-recursively): Remove.

GitHub-reference: per https://github.com/joaotavora/eglot/issues/697

lisp/progmodes/eglot.el

index 4c47ad004bb1052b5fc7ffb327e4540a842e65f9..4ead874eec53ad5b560715b8e4c934f197729353 100644 (file)
@@ -2777,7 +2777,9 @@ at point.  With prefix argument, prompt for ACTION-KIND."
                    (eglot--glob-compile globPattern t t))
                  watchers))
          (dirs-to-watch
-          (eglot--directories-recursively default-directory)))
+          (delete-dups (mapcar #'file-name-directory
+                               (project-files
+                                (eglot--project server))))))
     (cl-labels
         ((handle-event
           (event)
@@ -2878,15 +2880,6 @@ If NOERROR, return predicate, else erroring function."
   (when (eq ?! (aref arg 1)) (aset arg 1 ?^))
   `(,self () (re-search-forward ,(concat "\\=" arg)) (,next)))
 
-(defun eglot--directories-recursively (&optional dir)
-  "Because `directory-files-recursively' isn't complete in 26.3."
-  (cons (setq dir (expand-file-name (or dir default-directory)))
-        (cl-loop with default-directory = dir
-                 with completion-regexp-list = '("^[^.]")
-                 for f in (file-name-all-completions "" dir)
-                 if (and (file-directory-p f) (not (string= "node_modules/" f)))
-                 append (eglot--directories-recursively f))))
-
 \f
 ;;; Rust-specific
 ;;;