unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: mbork@mbork.pl
To: Help Gnu Emacs mailing list <help-gnu-emacs@gnu.org>
Subject: Completion with different values and displayed things
Date: Sat, 16 Mar 2024 05:44:35 +0100	[thread overview]
Message-ID: <87h6h6iy4s.fsf@mbork.pl> (raw)

Hi all!

I have a list of "things" and I need to use `completing-read' (or
another completion mechanism) to enable the user to select one of them.
Here's the problem.  Every "thing" has, say, three things, like
(:name "Thing" :description "The important thing" :id 1337)
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)
- and return :id

I use Ivy, but I'd prefer to make this work with any completion
framework (or even with Emacs vanilla completion).

Does Emacs has anything like this?  More or less, I'd like an equivalent
of HTML's <select> where displayed thing is different than the "value"
attribute.  It is important though to use some sort of completion
instead of e.g. displaying all options annotated by numbers/letters and
letting the user type the number or a letter associated with the one
they want - there are too many of them for this to be comfortable.

TIA,

-- 
Marcin Borkowski
https://mbork.pl
https://crimsonelevendelightpetrichor.net/



             reply	other threads:[~2024-03-16  4:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-16  4:44 mbork [this message]
2024-03-16 15:33 ` Completion with different values and displayed things Stefan Monnier via Users list for the GNU Emacs text editor

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87h6h6iy4s.fsf@mbork.pl \
    --to=mbork@mbork.pl \
    --cc=help-gnu-emacs@gnu.org \
    /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.
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).