[Top][All Lists]

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

Re: Any infrastructure to select one of a few options in Emacs core?

From: Marcin Borkowski
Subject: Re: Any infrastructure to select one of a few options in Emacs core?
Date: Mon, 09 May 2016 20:08:43 +0200
User-agent: mu4e 0.9.13; emacs

On 2016-05-09, at 19:27, Drew Adams <> wrote:

>> > completing-read
>> Yes and no.  I thought about it, and rejected the idea: I want all the
>> options to be visible without pressing TAB.  Also, each option might
>> need more than one line (and the number of lines may vary between
>> options), so I don't like the idea of using minibuffer at all.
> It's still not clear from your description what you mean by "select"
> one of the options.

OK, so let us assume that I want the user to select one of the three
strings: "spam", "eggs" and "emacs".  (Note: in my use case they would
not be string literals.)  Then, I'd like to be able to say, e.g.,
something like this:

(ask-user-for-option "What would you like to eat?" '("spam" "ham" "eggs"))

and have something like

--8<---------------cut here---------------start------------->8---
Wat would you like to eat?

1. spam

2. ham

3. eggs
--8<---------------cut here---------------end--------------->8---

displayed (perhaps in a *temp* buffer or so), and wait for the user to
press 1, 2 or 3.  Then, the above form returns the selected string.

It would probably be also useful to be able to give it e.g. cons cells
with the car being the string and the cdr the value returned in case of
selecting this particular string.  Also, it should be customizable: one
user might like digit keys, another one letters, for instance.  Also,
the choices should be clickable for those poor souls addicted to

In a more advanced scenario, the menu might be "non-modal", i.e. do not
use `read-key' or something like that, but a dynamically crafted mode
(probably descendant of special-mode), in which various keys/clicks would
launch a callback function given to the hypothetical
`ask-user-for-option' with the selected choice as a parameter.


Marcin Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

reply via email to

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