GNU bug report logs - #60956
27.2; project-try-vc considers every nonempty directory a root when vc-handled-backends is nil

Previous Next

Package: emacs;

Reported by: Jason Orendorff <jason.orendorff <at> gmail.com>

Date: Fri, 20 Jan 2023 08:43:01 UTC

Severity: normal

Found in version 27.2

Fixed in version 29.1

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60956 in the body.
You can then email your comments to 60956 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#60956; Package emacs. (Fri, 20 Jan 2023 08:43:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jason Orendorff <jason.orendorff <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 20 Jan 2023 08:43:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jason Orendorff <jason.orendorff <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.2; project-try-vc considers every nonempty directory a root when
 vc-handled-backends is nil
Date: Thu, 19 Jan 2023 16:45:21 -0600
[Message part 1 (text/plain, inline)]
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))
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60956; Package emacs. (Fri, 20 Jan 2023 12:15:01 GMT) Full text and rfc822 format available.

Message #8 received at 60956 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Jason Orendorff <jason.orendorff <at> gmail.com>, 60956 <at> debbugs.gnu.org
Subject: Re: bug#60956: 27.2; project-try-vc considers every nonempty
 directory a root when vc-handled-backends is nil
Date: Fri, 20 Jan 2023 14:14:15 +0200
[Message part 1 (text/plain, inline)]
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.
[project-marker-wildcard.diff (text/x-patch, attachment)]

Reply sent to Dmitry Gutov <dgutov <at> yandex.ru>:
You have taken responsibility. (Fri, 20 Jan 2023 16:53:02 GMT) Full text and rfc822 format available.

Notification sent to Jason Orendorff <jason.orendorff <at> gmail.com>:
bug acknowledged by developer. (Fri, 20 Jan 2023 16:53:02 GMT) Full text and rfc822 format available.

Message #13 received at 60956-done <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Jason Orendorff <jason.orendorff <at> gmail.com>
Cc: 60956-done <at> debbugs.gnu.org
Subject: Re: bug#60956: 27.2; project-try-vc considers every nonempty
 directory a root when vc-handled-backends is nil
Date: Fri, 20 Jan 2023 18:52:13 +0200
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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60956; Package emacs. (Fri, 20 Jan 2023 17:30:03 GMT) Full text and rfc822 format available.

Message #16 received at 60956 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Jason Orendorff <jason.orendorff <at> gmail.com>
Cc: 60956 <at> debbugs.gnu.org
Subject: Re: bug#60956: 27.2; project-try-vc considers every nonempty
 directory a root when vc-handled-backends is nil
Date: Fri, 20 Jan 2023 19:29:01 +0200
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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60956; Package emacs. (Fri, 20 Jan 2023 18:47:02 GMT) Full text and rfc822 format available.

Message #19 received at 60956 <at> debbugs.gnu.org (full text, mbox):

From: Jason Orendorff <jason.orendorff <at> gmail.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 60956 <at> debbugs.gnu.org
Subject: Re: bug#60956: 27.2; project-try-vc considers every nonempty
 directory a root when vc-handled-backends is nil
Date: Fri, 20 Jan 2023 09:55:38 -0600
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.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 18 Feb 2023 12:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 40 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.