I'm writing an Emacs minor mode, and in it I use completing-read
to let the user choose from a large set of search results. They're different each time, so it's likely the user won't know what one they want without looking at the list. For that reason, I'd like to show a temporary buffer with all the completions immediately instead of waiting for the user to hit Tab, but it's not obvious to me how to do so. Is there a way, and what is it?
You can get that by using minibuffer-with-setup-hook
and adding minibuffer-complete
to the setup hook, like so:
(setq tmp '("cat" "dog" "fish"))
(minibuffer-with-setup-hook 'minibuffer-complete
(completing-read (concat "Pick one ("
(mapconcat 'identity (all-completions "" tmp) " ")
"): ")
tmp))
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