GNU bug report logs -
#79290
30.2; eglot-alternatives doesn't support re-use of same program with different subcommands
Previous Next
To reply to this bug, email your comments to 79290 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79290
; Package
emacs
.
(Fri, 22 Aug 2025 15:39:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Doug Davis <ddavis <at> ddavis.io>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 22 Aug 2025 15:39:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
When writing an `eglot-alternatives' that looks like this:
(add-to-list 'eglot-server-programs
`(python-base-mode
. ,(eglot-alternatives '(("basedpyright-langserver" "--stdio")
("uv" "run" "pyright-langserver" "--stdio")
("uv" "run" "ty" "server")
"jedi-language-server"
("pyright-langserver" "--stdio")))))
an invocation of M-x eglot will fail to show the second instance of
using uv in the resulting list that appears to be passed on to
`completing-read'. (Notice the repeated use of `uv run`
https://docs.astral.sh/uv/reference/cli/#uv-run)
more info: the benefit of using `uv run` unloads the burden of using
emacs to property setup a virtual environment; uv automatically handles
running the correct installation of the invoked subcommand.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79290
; Package
emacs
.
(Sat, 23 Aug 2025 13:01:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 79290 <at> debbugs.gnu.org (full text, mbox):
> From: Doug Davis <ddavis <at> ddavis.io>
> Date: Fri, 22 Aug 2025 10:37:38 -0500
>
> When writing an `eglot-alternatives' that looks like this:
>
> (add-to-list 'eglot-server-programs
> `(python-base-mode
> . ,(eglot-alternatives '(("basedpyright-langserver" "--stdio")
> ("uv" "run" "pyright-langserver" "--stdio")
> ("uv" "run" "ty" "server")
> "jedi-language-server"
> ("pyright-langserver" "--stdio")))))
>
> an invocation of M-x eglot will fail to show the second instance of
> using uv in the resulting list that appears to be passed on to
> `completing-read'. (Notice the repeated use of `uv run`
> https://docs.astral.sh/uv/reference/cli/#uv-run)
>
> more info: the benefit of using `uv run` unloads the burden of using
> emacs to property setup a virtual environment; uv automatically handles
> running the correct installation of the invoked subcommand.
João, any comments or suggestions?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79290
; Package
emacs
.
(Sat, 23 Aug 2025 14:20:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 79290 <at> debbugs.gnu.org (full text, mbox):
>> From: Doug Davis <ddavis <at> ddavis.io>
>> Date: Fri, 22 Aug 2025 10:37:38 -0500
>>
>> When writing an `eglot-alternatives' that looks like this:
>>
>> (add-to-list 'eglot-server-programs
>> `(python-base-mode
>> . ,(eglot-alternatives '(("basedpyright-langserver" "--stdio")
>> ("uv" "run" "pyright-langserver" "--stdio")
>> ("uv" "run" "ty" "server")
>> "jedi-language-server"
>> ("pyright-langserver" "--stdio")))))
>>
>> an invocation of M-x eglot will fail to show the second instance of
>> using uv in the resulting list that appears to be passed on to
>> `completing-read'. (Notice the repeated use of `uv run`
>> https://docs.astral.sh/uv/reference/cli/#uv-run)
>>
>> more info: the benefit of using `uv run` unloads the burden of using
>> emacs to property setup a virtual environment; uv automatically handles
>> running the correct installation of the invoked subcommand.
Maybe an element of ALTERNATIVES of eglot-alternatives (or the CONTACT
of eglot-server-programs) cloud have an additional property named :title
or :label (similarly to the existing :initializationOptions) to be used
in the completing-read call of eglot-alternatives.
As a workaround, Doug can create two symlinks named
uv-pyright-langserver and an uv-ty pointing to uv.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79290
; Package
emacs
.
(Sat, 23 Aug 2025 17:39:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 79290 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: Doug Davis <ddavis <at> ddavis.io>
>> Date: Fri, 22 Aug 2025 10:37:38 -0500
>>
>> When writing an `eglot-alternatives' that looks like this:
>>
>> (add-to-list 'eglot-server-programs
>> `(python-base-mode
>> . ,(eglot-alternatives '(("basedpyright-langserver" "--stdio")
>> ("uv" "run" "pyright-langserver" "--stdio")
>> ("uv" "run" "ty" "server")
>> "jedi-language-server"
>> ("pyright-langserver" "--stdio")))))
>>
>> an invocation of M-x eglot will fail to show the second instance of
>> using uv in the resulting list that appears to be passed on to
>> `completing-read'. (Notice the repeated use of `uv run`
>> https://docs.astral.sh/uv/reference/cli/#uv-run)
>>
>> more info: the benefit of using `uv run` unloads the burden of using
>> emacs to property setup a virtual environment; uv automatically handles
>> running the correct installation of the invoked subcommand.
>
> João, any comments or suggestions?
Below is a patch on master that resolves
("server-program" "arg1" "arg2")
to appear as
"server-program arg1 arg2"
in the completing read; just an idea
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 29e6c269fdf..d97624a33b9 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -214,7 +214,7 @@ eglot-alternatives
(let ((found (eglot--executable-find
(car a) t)))
(and found
- (cons (car a) (cons found (cdr a))))))
+ (cons (mapconcat #'identity a " ") (cons found (cdr a))))))
listified))
(available (remove nil augmented)))
(cond ((cdr available)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79290
; Package
emacs
.
(Sun, 24 Aug 2025 12:40:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 79290 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Sat, Aug 23, 2025 at 6:38 PM Doug Davis <ddavis <at> ddavis.io> wrote:
> >> an invocation of M-x eglot will fail to show the second instance of
> >> using uv in the resulting list that appears to be passed on to
> >> `completing-read'. (Notice the repeated use of `uv run`
> >> https://docs.astral.sh/uv/reference/cli/#uv-run)
> >>
> >> more info: the benefit of using `uv run` unloads the burden of using
> >> emacs to property setup a virtual environment; uv automatically handles
> >> running the correct installation of the invoked subcommand.
> >
> > João, any comments or suggestions?
>
No many:
I run python servers myself and find that a simple handrolled "virtual
environment" helper that sets exec-path, process-environment, and PATH
works fine 99% of the time (if not 100% of the time) for my python
programming
needs, admittedly not very complex. This includes eglot. Attached my
50-line
zenv.el in case is useful to anyone, though not related to this issue.
> Below is a patch on master that resolves
>
> ("server-program" "arg1" "arg2")
>
> to appear as
>
> "server-program arg1 arg2"
>
> in the completing read; just an idea
>
I don't fully understand the issue, but I don't have anything against
these quality-of-life patches if, and this is a big IF, they are small and
very well tested. I'm thinking about C-u M-x eglot, and other interactive
scenarios. eglot-server-program's syntax is crammed to the max
already. Related to this, Philip K. had a good idea about
eglot-alternatives,
to make it "less functional", but I can't remember what it was exactly.
João
[Message part 2 (text/html, inline)]
[zenv.el (text/x-emacs-lisp, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79290
; Package
emacs
.
(Sun, 24 Aug 2025 12:50:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 79290 <at> debbugs.gnu.org (full text, mbox):
> From: João Távora <joaotavora <at> gmail.com>
> Date: Sun, 24 Aug 2025 13:40:41 +0100
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 79290 <at> debbugs.gnu.org
>
> On Sat, Aug 23, 2025 at 6:38 PM Doug Davis <ddavis <at> ddavis.io> wrote:
>
> >> an invocation of M-x eglot will fail to show the second instance of
> >> using uv in the resulting list that appears to be passed on to
> >> `completing-read'. (Notice the repeated use of `uv run`
> >> https://docs.astral.sh/uv/reference/cli/#uv-run)
> >>
> >> more info: the benefit of using `uv run` unloads the burden of using
> >> emacs to property setup a virtual environment; uv automatically handles
> >> running the correct installation of the invoked subcommand.
> >
> > João, any comments or suggestions?
>
> No many:
>
> I run python servers myself and find that a simple handrolled "virtual
> environment" helper that sets exec-path, process-environment, and PATH
> works fine 99% of the time (if not 100% of the time) for my python programming
> needs, admittedly not very complex. This includes eglot. Attached my 50-line
> zenv.el in case is useful to anyone, though not related to this issue.
>
> Below is a patch on master that resolves
>
> ("server-program" "arg1" "arg2")
>
> to appear as
>
> "server-program arg1 arg2"
>
> in the completing read; just an idea
>
> I don't fully understand the issue, but I don't have anything against
> these quality-of-life patches if, and this is a big IF, they are small and
> very well tested. I'm thinking about C-u M-x eglot, and other interactive
> scenarios. eglot-server-program's syntax is crammed to the max
> already. Related to this, Philip K. had a good idea about eglot-alternatives,
> to make it "less functional", but I can't remember what it was exactly.
Philip, do you remember?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79290
; Package
emacs
.
(Sun, 24 Aug 2025 19:27:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 79290 <at> debbugs.gnu.org (full text, mbox):
João Távora <joaotavora <at> gmail.com> writes:
> On Sat, Aug 23, 2025 at 6:38 PM Doug Davis <ddavis <at> ddavis.io> wrote:
>
>> >> an invocation of M-x eglot will fail to show the second instance of
>> >> using uv in the resulting list that appears to be passed on to
>> >> `completing-read'. (Notice the repeated use of `uv run`
>> >> https://docs.astral.sh/uv/reference/cli/#uv-run)
>> >>
>> >> more info: the benefit of using `uv run` unloads the burden of using
>> >> emacs to property setup a virtual environment; uv automatically handles
>> >> running the correct installation of the invoked subcommand.
>> >
>> > João, any comments or suggestions?
>>
>
> No many:
>
> I run python servers myself and find that a simple handrolled "virtual
> environment" helper that sets exec-path, process-environment, and PATH
> works fine 99% of the time (if not 100% of the time) for my python
> programming needs, admittedly not very complex. This includes eglot.
I can't argue with your point above (the pyvenv package solves this very
well, I've used it for many years). I've typically leaned on
.dir-locals.el or some function of my own (added to python mode hook)
that finds and activates a virtualenv in a project. Using uv to launch
an LSP server with `uv run <program>` just eliminates the need to worry
about virtualenvs completely (uv automatically handles all venv
creation/discovery).
> Attached my 50-line zenv.el in case is useful to anyone, though not
> related to this issue.
>
>> Below is a patch on master that resolves
>>
>> ("server-program" "arg1" "arg2")
>>
>> to appear as
>>
>> "server-program arg1 arg2"
>>
>> in the completing read; just an idea
>>
>
> I don't fully understand the issue
IMO the core of the issue is that completing-read is getting a list of
programs, where each the program is resolved from (car a) where a is
typically the entries of a list like:
'(("uv" "run" "program1")
("uv" "run" "program2")
("program3"))
So then the list passed to completing-read is '("uv" "uv" "program3")
And completing-read just ignores repeated input; e.g.
(completing-read "pick:" '("uv" "uv" "program3") ...)
will only show "uv" and "program3"; so my diff from my previous reply
just concats the lists to make the completing-read call:
(completing-read "pick:" '("uv run program1"
"uv run program2"
"program3") ...)
that is, with all unique entries.
>
>, but I don't have anything against
> these quality-of-life patches if, and this is a big IF, they are small and
> very well tested. I'm thinking about C-u M-x eglot, and other interactive
> scenarios. eglot-server-program's syntax is crammed to the max
> already. Related to this, Philip K. had a good idea about
> eglot-alternatives,
> to make it "less functional", but I can't remember what it was exactly.
I'd completely understand if this QOL change is beyond the scope of some
other larger work on eglot (also, I've personally never used C-u M-x
eglot, but it appears to work fine with the diff from my previous reply,
which has been working fine for me and my plain M-x eglot usage).
cheers
Doug
>
> João
> [4. text/x-emacs-lisp; zenv.el]...
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#79290
; Package
emacs
.
(Sun, 24 Aug 2025 21:17:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 79290 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> From: João Távora <joaotavora <at> gmail.com>
>> Date: Sun, 24 Aug 2025 13:40:41 +0100
>> Cc: Eli Zaretskii <eliz <at> gnu.org>, 79290 <at> debbugs.gnu.org
>>
>> On Sat, Aug 23, 2025 at 6:38 PM Doug Davis <ddavis <at> ddavis.io> wrote:
>>
>> >> an invocation of M-x eglot will fail to show the second instance of
>> >> using uv in the resulting list that appears to be passed on to
>> >> `completing-read'. (Notice the repeated use of `uv run`
>> >> https://docs.astral.sh/uv/reference/cli/#uv-run)
>> >>
>> >> more info: the benefit of using `uv run` unloads the burden of using
>> >> emacs to property setup a virtual environment; uv automatically handles
>> >> running the correct installation of the invoked subcommand.
>> >
>> > João, any comments or suggestions?
>>
>> No many:
>>
>> I run python servers myself and find that a simple handrolled "virtual
>> environment" helper that sets exec-path, process-environment, and PATH
>> works fine 99% of the time (if not 100% of the time) for my python programming
>> needs, admittedly not very complex. This includes eglot. Attached my 50-line
>> zenv.el in case is useful to anyone, though not related to this issue.
>>
>> Below is a patch on master that resolves
>>
>> ("server-program" "arg1" "arg2")
>>
>> to appear as
>>
>> "server-program arg1 arg2"
>>
>> in the completing read; just an idea
>>
>> I don't fully understand the issue, but I don't have anything against
>> these quality-of-life patches if, and this is a big IF, they are small and
>> very well tested. I'm thinking about C-u M-x eglot, and other interactive
>> scenarios. eglot-server-program's syntax is crammed to the max
>> already. Related to this, Philip K. had a good idea about eglot-alternatives,
>> to make it "less functional", but I can't remember what it was exactly.
>
> Philip, do you remember?
The best I could find in my backlog was this message
yhetil.org/emacs-devel/87o6zc86dk.fsf <at> posteo.net/. This was an attempt
to move the contents of `eglot-server-programs' out of Eglot and into
their related major-modes. I never completed it (which reminds me once
more that I should maintain a list of these kinds of initiatives
somewhere), but João mentioned that he found the usage of arrays to
denote alternative commands to start the LSP servers interesting, as
opposed to injecting `eglot-alternatives' calls using quasi-quoting. My
idea here was just to allow configuring the variable without having to
load eglot.el. I didn't have the time to follow up on the entire bug
report to evaluate how relevant this hack is to the bug report at hand.
This bug report was last modified 26 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.