[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#33595: 26; Have `try-completion' or `completion--done' run abnormal

From: Stefan Monnier
Subject: bug#33595: 26; Have `try-completion' or `completion--done' run abnormal hook if sole completion
Date: Wed, 02 Jan 2019 10:27:58 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> More concretely, do you expect a hook function places on this variable
>> to apply for "any completion table" or would it be specific to
>> a particular completion table?
> The former.  At least I don't see how this has anything to
> do with what kind of completion is used or how it's done.

Not sure what you mean by "kind of completion" but a completion table
describes the "kind" of completion in the sense of describing the set of
possible completions (i.e. either a set of function names, or a set of
file names, or ...).

In your example, the hook function calls `describe-function` so it only
makes sense when the completion table is a set of function names, an
becomes absurd when it's a set of file names, or Git revisions, ...

So in your example, your hook function is very tightly linked to the
completion table.  I still don't understand this example well enough to
understand if/how it's linked to the UI (e.g. what should happen if the
user happens to use, say, ido-ubiquitous to complete his function names).

>> The example you give in `my-describe-function` gives me the impression
>> that those would inevitably be tightly linked to the completion table.
>> So instead of a hook variable, it would probably make more sense to add
>> a new `completion-extra-properties` alongside to :exit-function.
> No, I don't think that's relevant.

What do you mean by "relevant"?  It would require the code to be a bit
different but you could get the exact same behavior with it.

>> PS: I'm not sure I completely understand the intended behavior of
>>     `my-describe-function`, but I get the impression that for this
>>     particular example, a maybe even better approach is to use
>>     minibuffer-with-setup-hook to set a post-command-hook that calls
>>     describe-function whenever the minibuffer names a valid function
>>     (whether we get there via completion or plain typing, and regardless
>>     if it's the sole completion).
> No, that's something else.  This is not about describing
> everything that shows up in the minibuffer.  It's about
> a user asking to do something with a (full) completion - on
> demand.  Something defined by the person who wrote the code
> calling for completion.  Something specific for the command
> that is asking for user input, or at least for its candidates.

One part I don't fully understand is why this code wants to call
`describe-function` only and exactly when the user hits TAB and it
completes to an sole match.  Why should the user not want to see that
same result when typing the name explicitly instead of completing to it?
Why should the user not want to see the same result when completing to
an exact-but-not-sole match?

Another thing I don't understand about your example is: what is the user
expected to do after hitting TAB (which completed to a sole match)?
The only thing left to do seems to be RET but that's redundant since
`describe-function` was already called.

> [To be clear about one thing: This is not at all for _me_, as
> it has no effect with my setup, which uses Icicles, which (1)
> completes and uses TAB differently and (2) has a different
> mechanism for optionally doing something when there is a sole
> completion.  I just thought/think that this might be useful
> for some users (and it is simple).]

It's not as simple as it seems: if the user goes to some other buffer in
the middle of the completion, your completion-sole-match-functions will
not wreak havoc in unrelated completions.

> When TAB tells you that there is only one completion for your
> input (and completes to it), you can hit RET to choose that
> completion (act on it).  But in some cases you might want to
> first, or instead, take some other action on it - in particular,
> maybe get some more info about it.  This lets you do that.

Why only in that specific case?

> Hitting TAB again at that point does nothing now - it's a no-op.
> If this hook were bound it would instead do something.

Ah, so you want this hook to be run when TAB is hit a second time, in
which case it normally does nothing (tho that depends on the config, it
may also display the *Completions* buffer)?

I think I'm beginning to understand.  But I think it belongs in the
completion data (i.e. alongside :exit-function).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]