* bug#74617: 30.0.92; ffap-menu always displays the *Completions* buffer
@ 2024-11-30 7:02 Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 8:19 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-30 7:02 UTC (permalink / raw)
To: 74617; +Cc: Stefan Monnier
`ffap-menu' automatically displays the *Completions* buffer by calling
`minibuffer-completion-help'. If an alternative minibuffer completion
system like Icomplete or Vertico is used, the *Completions* buffer is
not needed since the candidates are already displayed in the minibuffer.
I propose to either detect these alternative completion systems (e.g.,
by checking the value of the completing-read-function and/or the mode
variables) or to provide a way to disable the call to
`minibuffer-completion-help'.
Since the same problem is present in tmm.el, maybe a generic solution
could be provided by minibuffer.el? Option 1: A function
`minibuffer-completion-help-if-needed' could call
`minibuffer-completion-help' only if no other completion system is
detected. Option 2: A new function
`completing-read-display-help-function' could be added which defaults to
`minibuffer-completion-help' and which could be set to nil/ignore by
alternative completion UIs like Vertico. This function could be used by
tmm/ffap. Option 3: A new variable `minibuffer-inhibit-completion-help'
could be added which is checked by `minibuffer-completion-help' and
which could be set to t by alternative completion UIs.
I am happy to provide a patch for any of these approaches.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#74617: 30.0.92; ffap-menu always displays the *Completions* buffer
2024-11-30 7:02 bug#74617: 30.0.92; ffap-menu always displays the *Completions* buffer Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-11-30 8:19 ` Eli Zaretskii
2024-11-30 8:34 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-11-30 8:19 UTC (permalink / raw)
To: Daniel Mendler; +Cc: 74617, monnier
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Sat, 30 Nov 2024 08:02:20 +0100
> From: Daniel Mendler via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>
> `ffap-menu' automatically displays the *Completions* buffer by calling
> `minibuffer-completion-help'. If an alternative minibuffer completion
> system like Icomplete or Vertico is used, the *Completions* buffer is
> not needed since the candidates are already displayed in the minibuffer.
That's not what I see here. Recipe:
emacs -Q
M-x icomplete-mode RET
C-x C-f nt/INSTALL.W64 RET
M-x ffap-menu RET
I see only the *Completions* buffer, no other display of the
candidates. What did I miss?
> I propose to either detect these alternative completion systems (e.g.,
> by checking the value of the completing-read-function and/or the mode
> variables) or to provide a way to disable the call to
> `minibuffer-completion-help'.
>
> Since the same problem is present in tmm.el, maybe a generic solution
> could be provided by minibuffer.el? Option 1: A function
> `minibuffer-completion-help-if-needed' could call
> `minibuffer-completion-help' only if no other completion system is
> detected. Option 2: A new function
> `completing-read-display-help-function' could be added which defaults to
> `minibuffer-completion-help' and which could be set to nil/ignore by
> alternative completion UIs like Vertico. This function could be used by
> tmm/ffap. Option 3: A new variable `minibuffer-inhibit-completion-help'
> could be added which is checked by `minibuffer-completion-help' and
> which could be set to t by alternative completion UIs.
Option 2 is adding complexity to an already devilishly complex code,
so I like it the least.
But first I think we need to understand the problem better; see above.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#74617: 30.0.92; ffap-menu always displays the *Completions* buffer
2024-11-30 8:19 ` Eli Zaretskii
@ 2024-11-30 8:34 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 9:28 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-30 8:34 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 74617, monnier
Eli Zaretskii <eliz@gnu.org> writes:
>> Cc: Stefan Monnier <monnier@iro.umontreal.ca>
>> Date: Sat, 30 Nov 2024 08:02:20 +0100
>> From: Daniel Mendler via "Bug reports for GNU Emacs,
>> the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
>>
>> `ffap-menu' automatically displays the *Completions* buffer by calling
>> `minibuffer-completion-help'. If an alternative minibuffer completion
>> system like Icomplete or Vertico is used, the *Completions* buffer is
>> not needed since the candidates are already displayed in the minibuffer.
>
> That's not what I see here. Recipe:
>
> emacs -Q
> M-x icomplete-mode RET
> C-x C-f nt/INSTALL.W64 RET
> M-x ffap-menu RET
>
> I see only the *Completions* buffer, no other display of the
> candidates. What did I miss?
Oh, right. I missed that. I think the problem here is that Icomplete
uses a delay (`icomplete-compute-delay'). Other completion UIs don't
have such a delay and show the candidates immediately. This makes the
problem a little more difficult, in particular with respect to auto
detection.
Another alternative to auto detection could be that the completion table
communicates to `completing-read' via metadata that immediate candidate
display is desired. The completion UI could then act accordingly.
Default completion would call `minibuffer-completion-help' and Icomplete
could update immediately, ignoring `icomplete-compute-delay'.
Daniel
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#74617: 30.0.92; ffap-menu always displays the *Completions* buffer
2024-11-30 8:34 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-11-30 9:28 ` Eli Zaretskii
2024-11-30 9:40 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-11-30 9:28 UTC (permalink / raw)
To: Daniel Mendler; +Cc: 74617, monnier
> From: Daniel Mendler <mail@daniel-mendler.de>
> Cc: 74617@debbugs.gnu.org, monnier@iro.umontreal.ca
> Date: Sat, 30 Nov 2024 09:34:11 +0100
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> > emacs -Q
> > M-x icomplete-mode RET
> > C-x C-f nt/INSTALL.W64 RET
> > M-x ffap-menu RET
> >
> > I see only the *Completions* buffer, no other display of the
> > candidates. What did I miss?
>
> Oh, right. I missed that. I think the problem here is that Icomplete
> uses a delay (`icomplete-compute-delay'). Other completion UIs don't
> have such a delay and show the candidates immediately. This makes the
> problem a little more difficult, in particular with respect to auto
> detection.
Alternatively, we could consider the cases where more than one
completion list is shown a bug in the mode which shows the completions
even though the application already did. IOW, instead of considering
this a problem of the command the user invokes, consider this a bug in
the non-default completion UI currently in effect. It is basically a
flaw in the design of those completion UIs.
> Another alternative to auto detection could be that the completion table
> communicates to `completing-read' via metadata that immediate candidate
> display is desired. The completion UI could then act accordingly.
> Default completion would call `minibuffer-completion-help' and Icomplete
> could update immediately, ignoring `icomplete-compute-delay'.
This sounds too indirect to me, it could cause unintended adverse
consequences, especially in nested scenarios.
There's a simpler alternative: we could say we don't care, as long as
only a few alternative UIs have this issue. It isn't a catastrophe.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#74617: 30.0.92; ffap-menu always displays the *Completions* buffer
2024-11-30 9:28 ` Eli Zaretskii
@ 2024-11-30 9:40 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 12:30 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-30 9:40 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 74617, monnier
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Daniel Mendler <mail@daniel-mendler.de>
>> Cc: 74617@debbugs.gnu.org, monnier@iro.umontreal.ca
>> Date: Sat, 30 Nov 2024 09:34:11 +0100
>>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>> > emacs -Q
>> > M-x icomplete-mode RET
>> > C-x C-f nt/INSTALL.W64 RET
>> > M-x ffap-menu RET
>> >
>> > I see only the *Completions* buffer, no other display of the
>> > candidates. What did I miss?
>>
>> Oh, right. I missed that. I think the problem here is that Icomplete
>> uses a delay (`icomplete-compute-delay'). Other completion UIs don't
>> have such a delay and show the candidates immediately. This makes the
>> problem a little more difficult, in particular with respect to auto
>> detection.
>
> Alternatively, we could consider the cases where more than one
> completion list is shown a bug in the mode which shows the completions
> even though the application already did. IOW, instead of considering
> this a problem of the command the user invokes, consider this a bug in
> the non-default completion UI currently in effect. It is basically a
> flaw in the design of those completion UIs.
I see it differently. The problem is in the tmm and ffap commands which
lead to a mixture of completion UIs. Even if another completion UI is in
effect, the default completion UI is called by tmm and ffap, bypassing
the `completing-read' abstraction. It is not the responsibility of
alternative completion UIs to work around this. Mixing multiple
completion UIs is not ideal since it will lead to an incoherent UI and
also to conflicts in how the user interacts with the minibuffer.
>> Another alternative to auto detection could be that the completion table
>> communicates to `completing-read' via metadata that immediate candidate
>> display is desired. The completion UI could then act accordingly.
>> Default completion would call `minibuffer-completion-help' and Icomplete
>> could update immediately, ignoring `icomplete-compute-delay'.
>
> This sounds too indirect to me, it could cause unintended adverse
> consequences, especially in nested scenarios.
By using the completion metadata as part of the completion table, the
effect on nested scenarios is explicitly avoided. Problems with nesting
only occur if a variable is let-bound around `completing-read'.
> There's a simpler alternative: we could say we don't care, as long as
> only a few alternative UIs have this issue. It isn't a catastrophe.
I care. But I do agree with you that the issues are minor and far from a
catastrophe.
The pattern where completion commands want to display candidates
immediately is not uncommon. There are ffap, tmm and multiple
third-party packages which have such a requirement. So I suggest to not
necessarily treat "immediate candidate display" as a bug report, but
rather as a feature request for `completing-read'.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#74617: 30.0.92; ffap-menu always displays the *Completions* buffer
2024-11-30 9:40 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-11-30 12:30 ` Eli Zaretskii
2024-11-30 16:25 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-11-30 12:30 UTC (permalink / raw)
To: Daniel Mendler; +Cc: 74617, monnier
> From: Daniel Mendler <mail@daniel-mendler.de>
> Cc: 74617@debbugs.gnu.org, monnier@iro.umontreal.ca
> Date: Sat, 30 Nov 2024 10:40:05 +0100
>
> Eli Zaretskii <eliz@gnu.org> writes:
> > Alternatively, we could consider the cases where more than one
> > completion list is shown a bug in the mode which shows the completions
> > even though the application already did. IOW, instead of considering
> > this a problem of the command the user invokes, consider this a bug in
> > the non-default completion UI currently in effect. It is basically a
> > flaw in the design of those completion UIs.
>
> I see it differently. The problem is in the tmm and ffap commands which
> lead to a mixture of completion UIs. Even if another completion UI is in
> effect, the default completion UI is called by tmm and ffap, bypassing
> the `completing-read' abstraction.
I don't understand: ffap-menu calls completing-read, so what
abstraction does it bypass, and how?
> It is not the responsibility of
> alternative completion UIs to work around this.
Work around what?
> Mixing multiple
> completion UIs is not ideal since it will lead to an incoherent UI and
> also to conflicts in how the user interacts with the minibuffer.
The question is: who should pay attention and understand that "the
other" completion is being called?
> >> Another alternative to auto detection could be that the completion table
> >> communicates to `completing-read' via metadata that immediate candidate
> >> display is desired. The completion UI could then act accordingly.
> >> Default completion would call `minibuffer-completion-help' and Icomplete
> >> could update immediately, ignoring `icomplete-compute-delay'.
> >
> > This sounds too indirect to me, it could cause unintended adverse
> > consequences, especially in nested scenarios.
>
> By using the completion metadata as part of the completion table, the
> effect on nested scenarios is explicitly avoided. Problems with nesting
> only occur if a variable is let-bound around `completing-read'.
You assume that the completion table is never passed to inner levels?
Is that assumption solid?
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#74617: 30.0.92; ffap-menu always displays the *Completions* buffer
2024-11-30 12:30 ` Eli Zaretskii
@ 2024-11-30 16:25 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 16:59 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-30 16:25 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 74617, monnier
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Daniel Mendler <mail@daniel-mendler.de>
>> Cc: 74617@debbugs.gnu.org, monnier@iro.umontreal.ca
>> Date: Sat, 30 Nov 2024 10:40:05 +0100
>>
>> Eli Zaretskii <eliz@gnu.org> writes:
>> > Alternatively, we could consider the cases where more than one
>> > completion list is shown a bug in the mode which shows the completions
>> > even though the application already did. IOW, instead of considering
>> > this a problem of the command the user invokes, consider this a bug in
>> > the non-default completion UI currently in effect. It is basically a
>> > flaw in the design of those completion UIs.
>>
>> I see it differently. The problem is in the tmm and ffap commands which
>> lead to a mixture of completion UIs. Even if another completion UI is in
>> effect, the default completion UI is called by tmm and ffap, bypassing
>> the `completing-read' abstraction.
>
> I don't understand: ffap-menu calls completing-read, so what
> abstraction does it bypass, and how?
It also calls `minibuffer-completion-help' which belongs to the default
completion UI but not strictly to the abstract `completing-read' API.
Unfortunately the API boundaries are not clearly defined. In principle
one could separate the generic `completing-read' code from the default
completion UI code. This could help keeping the complexity of the
completion code in check. Right now the default completion UI code is
scattered across minibuffer.el and simple.el.
>> It is not the responsibility of
>> alternative completion UIs to work around this.
>
> Work around what?
Hiding the *Completions* buffer. It should not be shown in the first
place if the user replaced the `completing-read-function' with something
else by turning on the mode of an alternative UI.
>> >> Another alternative to auto detection could be that the completion table
>> >> communicates to `completing-read' via metadata that immediate candidate
>> >> display is desired. The completion UI could then act accordingly.
>> >> Default completion would call `minibuffer-completion-help' and Icomplete
>> >> could update immediately, ignoring `icomplete-compute-delay'.
>> >
>> > This sounds too indirect to me, it could cause unintended adverse
>> > consequences, especially in nested scenarios.
>>
>> By using the completion metadata as part of the completion table, the
>> effect on nested scenarios is explicitly avoided. Problems with nesting
>> only occur if a variable is let-bound around `completing-read'.
>
> You assume that the completion table is never passed to inner levels?
> Is that assumption solid?
Yes, as far as I can tell. Completion can work well in recursive
minibuffers, such that the inner completion session does not interfere
with the outer session. Stefan even changed the scope of the
`minibuffer-completion-table' variables a while ago, such that it is
only bound buffer-locally in the minibuffer. Earlier it was let-bound
around the `read-from-minibuffer' call. (Of course it is still possible
to access the completion table by reading the buffer local variable from
the minibuffer directly, but this doesn't happen accidentally.)
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#74617: 30.0.92; ffap-menu always displays the *Completions* buffer
2024-11-30 16:25 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-11-30 16:59 ` Eli Zaretskii
2024-11-30 17:18 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2024-11-30 16:59 UTC (permalink / raw)
To: Daniel Mendler; +Cc: 74617, monnier
> From: Daniel Mendler <mail@daniel-mendler.de>
> Cc: 74617@debbugs.gnu.org, monnier@iro.umontreal.ca
> Date: Sat, 30 Nov 2024 17:25:07 +0100
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
> >> I see it differently. The problem is in the tmm and ffap commands which
> >> lead to a mixture of completion UIs. Even if another completion UI is in
> >> effect, the default completion UI is called by tmm and ffap, bypassing
> >> the `completing-read' abstraction.
> >
> > I don't understand: ffap-menu calls completing-read, so what
> > abstraction does it bypass, and how?
>
> It also calls `minibuffer-completion-help' which belongs to the default
> completion UI but not strictly to the abstract `completing-read' API.
So the problem is this single line?
(let ((minibuffer-setup-hook 'minibuffer-completion-help))
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#74617: 30.0.92; ffap-menu always displays the *Completions* buffer
2024-11-30 16:59 ` Eli Zaretskii
@ 2024-11-30 17:18 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
0 siblings, 0 replies; 9+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-30 17:18 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 74617, monnier
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Daniel Mendler <mail@daniel-mendler.de>
>> Cc: 74617@debbugs.gnu.org, monnier@iro.umontreal.ca
>> Date: Sat, 30 Nov 2024 17:25:07 +0100
>>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>> >> I see it differently. The problem is in the tmm and ffap commands which
>> >> lead to a mixture of completion UIs. Even if another completion UI is in
>> >> effect, the default completion UI is called by tmm and ffap, bypassing
>> >> the `completing-read' abstraction.
>> >
>> > I don't understand: ffap-menu calls completing-read, so what
>> > abstraction does it bypass, and how?
>>
>> It also calls `minibuffer-completion-help' which belongs to the default
>> completion UI but not strictly to the abstract `completing-read' API.
>
> So the problem is this single line?
>
> (let ((minibuffer-setup-hook 'minibuffer-completion-help))
Yes.
But maybe it makes sense to tackle the "immediate candidate display
problem" more generally. It would be great to get Stefan's input on
this.
For example in my osm.el package I have the following code to implement
immediate display of candidates. The lambda implements the
auto-detection, which I don't find particularly elegant.
(minibuffer-with-setup-hook
(lambda ()
(when (and (eq completing-read-function #'completing-read-default)
(not (bound-and-true-p vertico-mode))
(not (bound-and-true-p icomplete-mode)))
(let ((message-log-max nil)
(inhibit-message t))
;; Show matches immediately for default completion.
(minibuffer-completion-help))))
(completing-read ...))
Initially I had forgotten the call to `minibuffer-completion-help' since
most of them time I use a completion UI which displays the candidates
automatically anyway. Then Richard reported the bug, that `osm-search'
doesn't work conveniently in Emacs by default. Furthermore in my jinx.el
package I have almost exactly the same code in `jinx--correct-setup',
which is used like this:
(minibuffer-with-setup-hook
#'jinx--correct-setup
(completing-read ...))
Daniel
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-11-30 17:18 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-30 7:02 bug#74617: 30.0.92; ffap-menu always displays the *Completions* buffer Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 8:19 ` Eli Zaretskii
2024-11-30 8:34 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 9:28 ` Eli Zaretskii
2024-11-30 9:40 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 12:30 ` Eli Zaretskii
2024-11-30 16:25 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 16:59 ` Eli Zaretskii
2024-11-30 17:18 ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
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).