GNU bug report logs -
#48073
27.2; [Eglot] Don't bind `completion-styles' buffer locally?
Previous Next
Reported by: Augusto Stoffel <arstoffel <at> gmail.com>
Date: Tue, 27 Apr 2021 19:21:01 UTC
Severity: normal
Found in version 27.2
Done: João Távora <joaotavora <at> gmail.com>
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 48073 in the body.
You can then email your comments to 48073 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
joaotavora <at> gmail.com, bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Tue, 27 Apr 2021 19:21:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Augusto Stoffel <arstoffel <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
joaotavora <at> gmail.com, bug-gnu-emacs <at> gnu.org
.
(Tue, 27 Apr 2021 19:21:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Binding `completion-styles' buffer locally can lead to problems on
alternative completion UIs, say if the minibuffer is involved (this used
to happen with Consult's compeltion in region until recently).
It seems that a more appropriate way to override the completion style
would be to include a category in the completion table metadata, and add
a corresponding entry to `completion-category-defaults', which can be
done globally.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Tue, 27 Apr 2021 19:33:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 48073 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Tue, Apr 27, 2021 at 8:21 PM Augusto Stoffel <arstoffel <at> gmail.com> wrote:
> Binding `completion-styles' buffer locally can lead to problems on
> alternative completion UIs, say if the minibuffer is involved (this used
> to happen with Consult's compeltion in region until recently).
>
> It seems that a more appropriate way to override the completion style
> would be to include a category in the completion table metadata, and add
> a corresponding entry to `completion-category-defaults', which can be
> done globally.
>
Hi Augusto,
Yes, I think you are right about this. And then Eglot's completion table
would use
use a category that points to the style? Is that the idea? The end goal
is not to
lose flex-style completion for LSP-servers.
If so, can you draft a patch and attach it to your reply? By the way,
thanks for
inaugurating the Emacs bug tracker for Eglot bugs.
Also CCint Stefan Monnier since he usually has insight about this.
João
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Tue, 27 Apr 2021 20:39:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 48073 <at> debbugs.gnu.org (full text, mbox):
>> Binding `completion-styles' buffer locally can lead to problems on
>> alternative completion UIs, say if the minibuffer is involved (this used
>> to happen with Consult's compeltion in region until recently).
Indeed; another reason it's problematic is that it's a user-config, so
changing it programatically will sooner or later interfere in
undesirable ways.
>> It seems that a more appropriate way to override the completion style
>> would be to include a category in the completion table metadata, and add
>> a corresponding entry to `completion-category-defaults', which can be
>> done globally.
That's right. The advantage being also that the user can additionally
override that default style with `completion-category-overrides'.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Tue, 27 Apr 2021 21:02:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 48073 <at> debbugs.gnu.org (full text, mbox):
> Binding `completion-styles' buffer locally can lead to problems on
> alternative completion UIs, say if the minibuffer is involved (this
> used to happen with Consult's compeltion in region until recently).
>
> It seems that a more appropriate way to override the completion style
> would be to include a category in the completion table metadata, and
> add a corresponding entry to `completion-category-defaults', which can be
> done globally.
1. I can't speak to what you say in your first paragraph,
other than to say that I'm not surprised that this can
cause problems.
I expect (but will be relieved if it's not the case)
that making global minibuffer variables buffer-local to
the minibuffer will break behavior in my "alternative
completion UI", which, I think, relies on not only code
but users interactively to be able to access, and even
change, the values of such variables (that is, without
having to wrap such access in `with-current-buffer' for
the current minibuffer buffer).
2. But I think I disagree with what you say in your 2nd
paragraph. It should be possible for not only an
"alternative completion UI" to change `completion-style'
without recourse to modifying the completion table
(metadata or in any other way), but also for a user to
modify `completion-style' on the fly.
The completion table should, in general, define the
domain of possible completions, which are matchable
by user input. In general, that domain can remain
constant even when `completion-style' is changed.
The domain defines what can be matched; the style
defines how domain elements can be matched.
It's true that a "completion table" can be a function
that, in effect, performs matching of user input as
well as defining the set of possible matches - together
in one operation. But that's only one case. (It's
general, because the function can also make use of a
non-varying domain. But it need not do so.)
In my "alternative completion UI" users can, in general,
switch among `completion-styles' interactively, anytime
during completion. If a `completion-style' gets, in
effect, baked into a given completion table for the
duration then that feature becomes impossible (I think,
but at least not easy) to make available.
Just one, non-expert, opinion.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Tue, 27 Apr 2021 21:12:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 48073 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Tue, Apr 27, 2021 at 9:38 PM Stefan Monnier <monnier <at> iro.umontreal.ca>
wrote:
>
>
> >> It seems that a more appropriate way to override the completion style
> >> would be to include a category in the completion table metadata, and
add
> >> a corresponding entry to `completion-category-defaults', which can be
> >> done globally.
>
> That's right. The advantage being also that the user can additionally
> override that default style with `completion-category-overrides'.
>
>
> Stefan
Thanks. But can you confirm my hypothesis that it is possible to make
its completion table function in the `flex` style automatically, by
- having Eglot add an entry to completion-category-defaults or
completion-category-overrides (which one?)
- having Eglot point to that entry in its completion table?
I.e. I'm only getting rid of the buffer-local hack if there's a viable
alternative (I think there is, but some confirmation would be ideal).
João
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Tue, 27 Apr 2021 21:54:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 48073 <at> debbugs.gnu.org (full text, mbox):
On Tue, Apr 27, 2021 at 10:28 PM Drew Adams <drew.adams <at> oracle.com> wrote:
> 1. I can't speak to what you say in your first paragraph,
> other than to say that I'm not surprised that this can
> cause problems.
>
> I expect (but will be relieved if it's not the case)
> that making global minibuffer variables buffer-local to
> the minibuffer will break behavior in my "alternative
Not to the minibuffer. To the general buffer. if your alternative
thing breaks like this, it will probably also break when the user
sets it legitimately.
In fact, I wonder if this is not also the case with the other UIs
that Augusto was having trouble with.
What I'm looking for is for a completion table-- a source
of completions -- to strongly suggest a completion style,
in case there's no explicit override by the user.
(Your other points kinda make sense, maybe, I didn't read
through all of them)
PS: Have you tried Eglot? I wonder if Icicles works with it. I admit
I've never tried Icicles myself, last time I tried was about 2006, but
i didn't even know how to load extensions very well.
Cheers,
João
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Tue, 27 Apr 2021 22:07:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 48073 <at> debbugs.gnu.org (full text, mbox):
> > 1. I can't speak to what you say in your first paragraph,
> > other than to say that I'm not surprised that this can
> > cause problems.
> >
> > I expect (but will be relieved if it's not the case)
> > that making global minibuffer variables buffer-local to
> > the minibuffer will break behavior in my "alternative
>
> Not to the minibuffer. To the general buffer. if your alternative
> thing breaks like this, it will probably also break when the user
> sets it legitimately.
Apologies for not following this thread more closely.
I thought this was about (connected to) the proposal
to make the global minibuffer variables, such as
`minibuffer-completion-table' buffer-local to the
minibuffer buffer.
> PS: Have you tried Eglot? I wonder if Icicles works with it. I admit
> I've never tried Icicles myself, last time I tried was about 2006, but
> i didn't even know how to load extensions very well.
No, I haven't tried Eglot. And it's quite likely that
Icicles doesn't work with it. I don't really have much
time for maintaining stuff, let alone time to experiment.
Sorry.
I don't claim that Icicles is at all typical wrt how it
uses the minibuffer completion table (or other things).
Not at all. More and more things change in Emacs, so
that my code works less and less. I used to find the
time and the will to try to keep afloat. I no longer do.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Tue, 27 Apr 2021 22:12:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 48073 <at> debbugs.gnu.org (full text, mbox):
On Tue, Apr 27, 2021 at 11:06 PM Drew Adams <drew.adams <at> oracle.com> wrote:
> Apologies for not following this thread more closely.
> I thought this was about (connected to) the proposal
> to make the global minibuffer variables, such as
> `minibuffer-completion-table' buffer-local to the
> minibuffer buffer.
No prob! Don't know anything about that other one.
> > PS: Have you tried Eglot? I wonder if Icicles works with it. I admit
> > I've never tried Icicles myself, last time I tried was about 2006, but
> > i didn't even know how to load extensions very well.
>
> No, I haven't tried Eglot. And it's quite likely that
> Icicles doesn't work with it.
Why do you say that? Does Icicles support the "normal"
completion tables that come with Emacs?
> I don't claim that Icicles is at all typical wrt how it
> uses the minibuffer completion table (or other things).
> Not at all. More and more things change in Emacs, so
> that my code works less and less. I used to find the
> time and the will to try to keep afloat. I no longer do.
How gloomy and beautiful. You should come to Portugal
to write odes of decadence to the Atlantic ocean.
João
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Tue, 27 Apr 2021 22:14:01 GMT)
Full text and
rfc822 format available.
Message #29 received at 48073 <at> debbugs.gnu.org (full text, mbox):
> How gloomy and beautiful. You should come to Portugal
> to write odes of decadence to the Atlantic ocean.
...in suitably pompous French, of course.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Tue, 27 Apr 2021 22:38:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 48073 <at> debbugs.gnu.org (full text, mbox):
>> >> It seems that a more appropriate way to override the completion style
>> >> would be to include a category in the completion table metadata, and
> add
>> >> a corresponding entry to `completion-category-defaults', which can be
>> >> done globally.
>>
>> That's right. The advantage being also that the user can additionally
>> override that default style with `completion-category-overrides'.
>>
>>
>> Stefan
>
>
> Thanks. But can you confirm my hypothesis that it is possible to make
> its completion table function in the `flex` style automatically,
Yes.
> - having Eglot add an entry to completion-category-defaults or
> completion-category-overrides (which one?)
`completion-category-overrides` is a user config. Don't touch it.
> - having Eglot point to that entry in its completion table?
There's no real notion of "point to", but it can use a completion-table
whose `category` says `eglot` and then use a corresponding entry in
`completion-category-defaults`, yes.
And those rare users who don't like `flex` (or who want the new
`mind-reader` completion style instead) can override it in their
`completion-category-overrides`.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Tue, 27 Apr 2021 22:43:02 GMT)
Full text and
rfc822 format available.
Message #35 received at 48073 <at> debbugs.gnu.org (full text, mbox):
On Tue, Apr 27, 2021 at 11:37 PM Stefan Monnier
<monnier <at> iro.umontreal.ca> wrote:
> There's no real notion of "point to", but it can use a completion-table
> whose `category` says `eglot` and then use a corresponding entry in
> `completion-category-defaults`, yes.
Cool, that's exactly what I meant "point to". And should
`completion-category-defaults` be affected globally, or buffer-locally?
(the table will only ever be useful in Eglot-managed buffers)
> And those rare users who don't like `flex` (or who want the new
> `mind-reader` completion style instead) can override it in their
> `completion-category-overrides`.
Great but you forgot the patch for the mind-reader completion style.
João (stealing Stefan's "forgot the patch" wisecrack)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Tue, 27 Apr 2021 23:14:01 GMT)
Full text and
rfc822 format available.
Message #38 received at 48073 <at> debbugs.gnu.org (full text, mbox):
>> There's no real notion of "point to", but it can use a completion-table
>> whose `category` says `eglot` and then use a corresponding entry in
>> `completion-category-defaults`, yes.
>
> Cool, that's exactly what I meant "point to". And should
> `completion-category-defaults` be affected globally, or buffer-locally?
> (the table will only ever be useful in Eglot-managed buffers)
I think you can just do it globally when loading Eglot (assuming you use
a category name that "belongs to Eglot").
>> And those rare users who don't like `flex` (or who want the new
>> `mind-reader` completion style instead) can override it in their
>> `completion-category-overrides`.
> Great but you forgot the patch for the mind-reader completion style.
I still have some bootstrapping problems with it, sorry.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Wed, 28 Apr 2021 07:01:02 GMT)
Full text and
rfc822 format available.
Message #41 received at 48073 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Here is a patch setting `completion-category-defaults'.
[0001-Add-a-completion-category-defaults-entry.patch (text/x-patch, inline)]
From e9d877c9c7203ce999a935cdbc36c619255cf63c Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel <at> gmail.com>
Date: Wed, 28 Apr 2021 08:50:10 +0200
Subject: [PATCH] Add a completion-category-defaults entry
Setting `completion-styles' buffer locally is harder to customize and
can break some completion UIs
* eglot.el: Add a completion-category-defaults entry, if applicable.
* eglot.el (eglot--managed-mode): Don't set `completion-styles'
buffer-locally.
* eglot.el (eglot-completion-at-point): Add style metadata to
completion table.
---
eglot.el | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/eglot.el b/eglot.el
index 3348054..122a76b 100644
--- a/eglot.el
+++ b/eglot.el
@@ -222,6 +222,10 @@ let the buffer grow forever."
:type '(choice (const :tag "Don't show confirmation prompt" nil)
(symbol :tag "Show confirmation prompt" 'confirm)))
+;; Customizable via `completion-category-overrides'.
+(when (assoc 'flex completion-styles-alist)
+ (add-to-list 'completion-category-defaults '(eglot (styles flex basic))))
+
;;; Constants
;;;
@@ -1421,8 +1425,6 @@ Use `eglot-managed-p' to determine if current buffer is managed.")
(eglot--setq-saving flymake-diagnostic-functions '(eglot-flymake-backend))
(eglot--setq-saving company-backends '(company-capf))
(eglot--setq-saving company-tooltip-align-annotations t)
- (when (assoc 'flex completion-styles-alist)
- (eglot--setq-saving completion-styles '(flex basic)))
(unless (eglot--stay-out-of-p 'imenu)
(add-function :before-until (local 'imenu-create-index-function)
#'eglot-imenu))
@@ -2166,7 +2168,8 @@ is not active."
(get-text-property 0 'eglot--lsp-item c)
:sortText)
"")))))
- (metadata `(metadata . ((display-sort-function . ,sort-completions))))
+ (metadata `(metadata (category . eglot)
+ (display-sort-function . ,sort-completions)))
resp items (cached-proxies :none)
(proxies
(lambda ()
--
2.30.2
Reply sent
to
João Távora <joaotavora <at> gmail.com>
:
You have taken responsibility.
(Wed, 28 Apr 2021 12:04:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Augusto Stoffel <arstoffel <at> gmail.com>
:
bug acknowledged by developer.
(Wed, 28 Apr 2021 12:04:01 GMT)
Full text and
rfc822 format available.
Message #46 received at 48073-done <at> debbugs.gnu.org (full text, mbox):
Augusto Stoffel <arstoffel <at> gmail.com> writes:
> Here is a patch setting `completion-category-defaults'.
>
> From e9d877c9c7203ce999a935cdbc36c619255cf63c Mon Sep 17 00:00:00 2001
> From: Augusto Stoffel <arstoffel <at> gmail.com>
> Date: Wed, 28 Apr 2021 08:50:10 +0200
> Subject: [PATCH] Add a completion-category-defaults entry
Thanks. Pushed to Eglot's upstream. Closing this bug report.
João
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Wed, 28 Apr 2021 16:11:01 GMT)
Full text and
rfc822 format available.
Message #49 received at 48073 <at> debbugs.gnu.org (full text, mbox):
> > No, I haven't tried Eglot. And it's quite likely that
> > Icicles doesn't work with it.
>
> Why do you say that? Does Icicles support the "normal"
> completion tables that come with Emacs?
Yes, it does.
> > I don't claim that Icicles is at all typical wrt how it
> > uses the minibuffer completion table (or other things).
> > Not at all. More and more things change in Emacs, so
> > that my code works less and less. I used to find the
> > time and the will to try to keep afloat. I no longer do.
>
> How gloomy and beautiful. You should come to Portugal
> to write odes of decadence to the Atlantic ocean.
> ...in suitably pompous French, of course.
Sounds creative.
Speaking of gloomy (but not so beautiful): More and
more things are changing in the ocean too, alas. ;-)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#48073
; Package
emacs
.
(Wed, 28 Apr 2021 16:14:01 GMT)
Full text and
rfc822 format available.
Message #52 received at 48073 <at> debbugs.gnu.org (full text, mbox):
On Wed, Apr 28, 2021 at 5:10 PM Drew Adams <drew.adams <at> oracle.com> wrote:
>
> > > No, I haven't tried Eglot. And it's quite likely that
> > > Icicles doesn't work with it.
> >
> > Why do you say that? Does Icicles support the "normal"
> > completion tables that come with Emacs?
>
> Yes, it does.
Then, in theory, it should also work with Eglot.
I'll try to test someday, and bug you for help
> Speaking of gloomy (but not so beautiful): More and
> more things are changing in the ocean too, alas. ;-)
sad indeed. Then join a local environmental protection
group, maybe
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 27 May 2021 11:24:07 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 333 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.