all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Drew Adams <drew.adams@oracle.com>
Cc: 33595@debbugs.gnu.org
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	[thread overview]
Message-ID: <jwv36qb5c9q.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <13f934bf-e79c-47cb-88a5-7ee58cdc9242@default> (Drew Adams's message of "Tue, 1 Jan 2019 23:11:49 -0800 (PST)")

>> 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).


        Stefan





  reply	other threads:[~2019-01-02 15:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-03  4:07 bug#33595: 26; Have `try-completion' or `completion--done' run abnormal hook if sole completion Drew Adams
2018-12-03 18:52 ` bug#33595: [PATCH] " Drew Adams
2018-12-28 18:56   ` Drew Adams
2018-12-29  8:08     ` Eli Zaretskii
2019-01-02  1:23       ` Stefan Monnier
2019-01-02  4:41 ` Stefan Monnier
2019-01-02  7:11   ` Drew Adams
2019-01-02 15:27     ` Stefan Monnier [this message]
2019-01-02 16:20       ` Drew Adams
2019-01-03  3:15         ` Stefan Monnier

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

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

  git send-email \
    --in-reply-to=jwv36qb5c9q.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=33595@debbugs.gnu.org \
    --cc=drew.adams@oracle.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.