Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show all completions immediately in completing-read?

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?

like image 630
JasonFruit Avatar asked Sep 11 '25 19:09

JasonFruit


1 Answers

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))
like image 132
Trey Jackson Avatar answered Sep 13 '25 16:09

Trey Jackson