* bug#60956: 27.2; project-try-vc considers every nonempty directory a root when vc-handled-backends is nil
@ 2023-01-19 22:45 Jason Orendorff
2023-01-20 12:14 ` Dmitry Gutov
0 siblings, 1 reply; 5+ messages in thread
From: Jason Orendorff @ 2023-01-19 22:45 UTC (permalink / raw)
To: 60956
[-- Attachment #1: Type: text/plain, Size: 8041 bytes --]
I observed that `eglot' would happily start dozens of language server
processes, but each one of them only seemed to know about a tiny
fraction of my code. I tracked this down and found a minor bug in
project.el.
In `project-try-vc', when `vc-handled-backends' is nil, the value of
`marker-re' computed here:
https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/project.el?id=207901457c018d94b1ce9e13a897d8241b1f3af2#n516
is the empty string.
If no vc backends are enabled, no directory should be treated as a vc
root. But the empty regexp matches everything, so *all* directories are
treated as vc roots.
Consequently, `eglot' spawned a lot of processes, because it starts one
per project.
The workaround is to set `vc-handled-backends' to any other value. (I
suppose I configured it to nil long ago, when working in a huge
Mercurial repository. Back then, commonplace hg commands in that repo
were unreasonably slow.)
In GNU Emacs 27.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60
Version 10.14.6 (Build 18G95))
of 2021-03-27 built on builder10-14.porkrind.org
Windowing system distributor 'Apple', version 10.3.2299
System Description: macOS 13.0.1
Recent messages:
(".git")
project-try-vc-2
"~/src/blackbird/"
Quit
Followed link to /Users/jorendorff/src/dotfiles/.emacs
Mark set [3 times]
Quit
Making completion list...
Type "q" to restore previous buffer.
user-error: No cross-reference here
Quit
Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules'
Configured features:
NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES
THREADS JSON PDUMPER GMP
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: Info
Minor modes in effect:
show-paren-mode: t
global-git-commit-mode: t
magit-auto-revert-mode: t
shell-dirtrack-mode: t
override-global-mode: t
tooltip-mode: t
global-eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
/Users/jorendorff/.emacs.d/elpa/jsonrpc-1.0.15/jsonrpc hides
/Applications/Emacs.app/Contents/Resources/lisp/jsonrpc
/Users/jorendorff/.emacs.d/elpa/xref-1.6.0/xref hides
/Applications/Emacs.app/Contents/Resources/lisp/progmodes/xref
/Users/jorendorff/.emacs.d/elpa/project-0.9.3/project hides
/Applications/Emacs.app/Contents/Resources/lisp/progmodes/project
/Users/jorendorff/.emacs.d/elpa/flymake-1.2.2/flymake hides
/Applications/Emacs.app/Contents/Resources/lisp/progmodes/flymake
/Users/jorendorff/.emacs.d/elpa/seq-2.23/seq hides
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/seq
/Users/jorendorff/.emacs.d/elpa/eldoc-1.13.0/eldoc hides
/Applications/Emacs.app/Contents/Resources/lisp/emacs-lisp/eldoc
Features:
(shadow sort mail-extr emacsbug sendmail vc-git vc-annotate vc-filewise
apropos jka-compr vc-dir vc vc-dispatcher rustic-flycheck let-alist
rustic-spellcheck rustic-expand rustic-lsp rustic-playground
rustic-rustfix rustic-racer rustic-babel rustic-rustfmt rustic-comint
rustic-clippy rustic-doc xdg rustic-popup rustic-cargo rustic-compile
spinner rustic-interaction rustic xterm-color org-element avl-tree org
ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote
org-src ob-comint org-pcomplete org-list org-faces org-entities
org-version ob-emacs-lisp ob-core ob-eval org-table ol org-keys
org-compat org-macs org-loaddefs cal-menu calendar cal-loaddefs tar-mode
arc-mode archive-mode autoload lisp-mnt mm-archive gnutls network-stream
url-http url-gw nsm url-cache url-auth url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf mailcap
cus-edit cus-start cus-load wid-edit cl-print eieio-opt speedbar
sb-image ezimage dframe ibuf-ext ibuffer ibuffer-loaddefs help-fns
radix-tree make-mode sql view conf-mode goto-addr tmm git-rebase
magit-ediff ediff ediff-merg ediff-mult ediff-wind ediff-diff ediff-help
ediff-init ediff-util dired-x bug-reference magit-extras face-remap
sh-script smie executable pulse find-dired misearch multi-isearch vc-svn
grep paren page-ext rust-utils rust-mode rust-rustfmt rust-playpen
rust-compile rust-cargo company-lean company-etags company lean-mode
lean-dev lean-right-click lean-message-boxes lean-type lean-hole
lean-flycheck lean-info lean-server lean-debug lean-leanpkg lean-syntax
lean-input quail lean-settings lean-util f s lean-eri yaml-mode
terraform-mode hcl-mode protobuf-mode cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs markdown-mode color
lua-mode haskell-mode haskell-cabal haskell-utils haskell-font-lock
haskell-indentation haskell-string haskell-sort-imports haskell-lexeme
haskell-align-imports haskell-complete-module haskell-ghc-support
noutline outline etags fileloop generator dabbrev haskell-customize
yasnippet multiple-cursors mc-separate-operations
rectangular-region-mode mc-mark-pop mc-edit-lines
mc-hide-unmatched-lines-mode mc-mark-more mc-cycle-cursors
multiple-cursors-core advice rect magit-submodule magit-obsolete
magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull
magit-fetch magit-clone magit-remote magit-commit magit-sequence
magit-notes magit-worktree magit-tag magit-merge magit-branch
magit-reset magit-files magit-refs magit-status magit magit-repos
magit-apply magit-wip magit-log which-func magit-diff smerge-mode diff
diff-mode git-commit log-edit message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums
mail-prsvr mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log
magit-core magit-autorevert autorevert magit-margin magit-transient
magit-process with-editor shell pcomplete server magit-mode transient
edmacro kmacro magit-git magit-base magit-section format-spec crm
compat-27 compat-26 compat compat-macs eglot array filenotify jsonrpc
ert pp ewoc debug backtrace xref flymake-proc flymake thingatpt warnings
compile comint ring pcase url-util project imenu flycheck ansi-color
find-func rx dash cl-extra help-mode use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode use-package-core finder-inf info package easymenu browse-url
url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json subr-x map url-vars seq byte-opt gv
bytecomp byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel term/ns-win ns-win
ucs-normalize mule-util term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads kqueue cocoa ns
multi-tty make-network-process emacs)
Memory information:
((conses 16 838747 195081)
(symbols 48 49430 2)
(strings 32 217132 39331)
(string-bytes 1 7847174)
(vectors 16 106459)
(vector-slots 8 1958647 115236)
(floats 8 419 673)
(intervals 56 49417 2047)
(buffers 1000 201))
[-- Attachment #2: Type: text/html, Size: 8866 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#60956: 27.2; project-try-vc considers every nonempty directory a root when vc-handled-backends is nil
2023-01-19 22:45 bug#60956: 27.2; project-try-vc considers every nonempty directory a root when vc-handled-backends is nil Jason Orendorff
@ 2023-01-20 12:14 ` Dmitry Gutov
2023-01-20 15:55 ` Jason Orendorff
0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Gutov @ 2023-01-20 12:14 UTC (permalink / raw)
To: Jason Orendorff, 60956
[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]
Hi!
On 20/01/2023 00:45, Jason Orendorff wrote:
> I observed that `eglot' would happily start dozens of language server
> processes, but each one of them only seemed to know about a tiny
> fraction of my code. I tracked this down and found a minor bug in
> project.el.
>
> In `project-try-vc', when `vc-handled-backends' is nil, the value of
> `marker-re' computed here:
>
> https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/project.el?id=207901457c018d94b1ce9e13a897d8241b1f3af2#n516 <https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/progmodes/project.el?id=207901457c018d94b1ce9e13a897d8241b1f3af2#n516>
>
> is the empty string.
>
> If no vc backends are enabled, no directory should be treated as a vc
> root. But the empty regexp matches everything, so *all* directories are
> treated as vc roots.
>
> Consequently, `eglot' spawned a lot of processes, because it starts one
> per project.
>
> The workaround is to set `vc-handled-backends' to any other value. (I
> suppose I configured it to nil long ago, when working in a huge
> Mercurial repository. Back then, commonplace hg commands in that repo
> were unreasonably slow.)
Thank you for this report.
Please try the attached patch.
[-- Attachment #2: project-marker-wildcard.diff --]
[-- Type: text/x-patch, Size: 1058 bytes --]
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index dc87cb8e15d..4a2ca45e633 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -514,11 +514,14 @@ project-try-vc
(lambda (b) (assoc-default b backend-markers-alist))
vc-handled-backends)))
(marker-re
- (mapconcat
- (lambda (m) (format "\\(%s\\)" (wildcard-to-regexp m)))
- (append backend-markers
- (project--value-in-dir 'project-vc-extra-root-markers dir))
- "\\|"))
+ (concat
+ "\\`"
+ (mapconcat
+ (lambda (m) (format "\\(%s\\)" (wildcard-to-regexp m)))
+ (append backend-markers
+ (project--value-in-dir 'project-vc-extra-root-markers dir))
+ "\\|")
+ "\\'"))
(locate-dominating-stop-dir-regexp
(or vc-ignore-dir-regexp locate-dominating-stop-dir-regexp))
last-matches
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#60956: 27.2; project-try-vc considers every nonempty directory a root when vc-handled-backends is nil
2023-01-20 12:14 ` Dmitry Gutov
@ 2023-01-20 15:55 ` Jason Orendorff
2023-01-20 16:52 ` Dmitry Gutov
2023-01-20 17:29 ` Dmitry Gutov
0 siblings, 2 replies; 5+ messages in thread
From: Jason Orendorff @ 2023-01-20 15:55 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: 60956
This patch fixes the bug; `(project-current)' now returns nil as expected.
It seems `eglot' still defaults to the current directory if
`project-current' does not find a better one, but at least now that's
my fault! :) Thank you for the quick response.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#60956: 27.2; project-try-vc considers every nonempty directory a root when vc-handled-backends is nil
2023-01-20 15:55 ` Jason Orendorff
@ 2023-01-20 16:52 ` Dmitry Gutov
2023-01-20 17:29 ` Dmitry Gutov
1 sibling, 0 replies; 5+ messages in thread
From: Dmitry Gutov @ 2023-01-20 16:52 UTC (permalink / raw)
To: Jason Orendorff; +Cc: 60956-done
Version: 29.1
On 20/01/2023 17:55, Jason Orendorff wrote:
> This patch fixes the bug; `(project-current)' now returns nil as expected.
>
> It seems `eglot' still defaults to the current directory if
> `project-current' does not find a better one, but at least now that's
> my fault! 😄 Thank you for the quick response.
Thanks for checking!
I've pushed to emacs-29, it should propagate to master and GNU ELPA in
due time.
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#60956: 27.2; project-try-vc considers every nonempty directory a root when vc-handled-backends is nil
2023-01-20 15:55 ` Jason Orendorff
2023-01-20 16:52 ` Dmitry Gutov
@ 2023-01-20 17:29 ` Dmitry Gutov
1 sibling, 0 replies; 5+ messages in thread
From: Dmitry Gutov @ 2023-01-20 17:29 UTC (permalink / raw)
To: Jason Orendorff; +Cc: 60956
On 20/01/2023 17:55, Jason Orendorff wrote:
> It seems `eglot' still defaults to the current directory if
> `project-current' does not find a better one, but at least now that's
> my fault! 😄 Thank you for the quick response.
BTW note that you can now use the option project-vc-extra-root-markers
to help your custom project detection, especially when
vc-handled-backends is nil.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-20 17:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-19 22:45 bug#60956: 27.2; project-try-vc considers every nonempty directory a root when vc-handled-backends is nil Jason Orendorff
2023-01-20 12:14 ` Dmitry Gutov
2023-01-20 15:55 ` Jason Orendorff
2023-01-20 16:52 ` Dmitry Gutov
2023-01-20 17:29 ` Dmitry Gutov
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.