I have an Elisp function which takes one argument (so far so good). This one argument is supposed to be an item from a list, and nothing else.
Is there a way I can display the list in kind of a "selection buffer" (like dired), where the user can navigate to the item and select it by hitting enter, instead of having to type out the string manually?
The usual way to do that is via completing-read
. You can then use a minibuffer-with-setup-hook
where you call minibuffer-completion-help
so as to pop up a *Completions*
buffer right away, so the user can click on his choice.
What you are looking for is completing-read
:
(defun foo (arg)
(interactive (list (completing-read ...)))
....)
If I understood the question correctly, you are looking for something like this:
(defun foo (list)
(interactive)
(let ((arg (ido-completing-read "Select from list: " list))))
...)
The selection process is not like dired, but it is common for emacs users to select from a list using ido
or other similar alternatives. You can narrow your search, move between alternatives and a long etc. Type M-x customize-group RET ido if you want to have a feeling of what preferences you may customize.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With