help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Completion with different values and displayed things


From: Stefan Monnier
Subject: Re: Completion with different values and displayed things
Date: Sat, 16 Mar 2024 11:33:47 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

> 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




reply via email to

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