From: Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Completion with different values and displayed things
Date: Sat, 16 Mar 2024 11:33:47 -0400 [thread overview]
Message-ID: <jwvo7begps2.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: 87h6h6iy4s.fsf@mbork.pl
> I want my completion to:
> - complete on :name
> - display also :description (there could be two different "things" with
> the same :name's but different :description's)
The completion mechanism "funnels" everything through the string the
users type (either directly or via completion), so if completion in only
based on `:name`s (i.e. the strings the user can enter will only ever
take the form of one of the `:name`s), then there is no way for the users
to specify which of several entries they meant if those entries share
the same `:name`.
IOW, make sure the thing on which they complete is unique.
Also, the completion API doesn't conveniently let you display just the
`:description`: you can use the `annotation` metadata (see
`completion-metadata`) to *add* the `:description` to the thing on which
the users complete (e.g. the `:name`), but not to replace it.
As for returning the `:id`, just do it manually after the call to
`completing-read` by searching for the matching entry and extracting its
`:id`.
Stefan
prev parent reply other threads:[~2024-03-16 15:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-16 4:44 Completion with different values and displayed things mbork
2024-03-16 15:33 ` Stefan Monnier via Users list for the GNU Emacs text editor [this message]
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=jwvo7begps2.fsf-monnier+emacs@gnu.org \
--to=help-gnu-emacs@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.