unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Jason Orendorff <jason.orendorff@gmail.com>, 60956@debbugs.gnu.org
Subject: 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	[thread overview]
Message-ID: <d5c330d1-988a-df9e-25b6-be2fc5cb4d1a@yandex.ru> (raw)
In-Reply-To: <CAPh8+ZrpsSqD9qx3gndReCB3j4tNkG5NurHvshc5R3f8NY0W=g@mail.gmail.com>

[-- 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

  reply	other threads:[~2023-01-20 12:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-01-20 15:55   ` Jason Orendorff
2023-01-20 16:52     ` Dmitry Gutov
2023-01-20 17:29     ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d5c330d1-988a-df9e-25b6-be2fc5cb4d1a@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=60956@debbugs.gnu.org \
    --cc=jason.orendorff@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).