From: João Távora Date: Wed, 26 May 2021 17:51:30 +0000 (+0100) Subject: Use project-files to know which directory watchers to skip X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~131 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b1a379cd774f40f6709fdfbb5c469fc317f22f8d;p=emacs.git Use project-files to know which directory watchers to skip 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 for the idea. * eglot.el (eglot--directories-recursively): Remove. GitHub-reference: per https://github.com/joaotavora/eglot/issues/697 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 4c47ad004bb..4ead874eec5 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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)))) - ;;; Rust-specific ;;;