Clean way to perform commands in the Emacs minibuffer
- by Christopher Monsanto
Consider the following example: I want to read a file using ido from the minibuffer, but merge in all of the directories I use often. I can't just execute
(ido-find-file)
(ido-merge-work-directories)
Because the second sexp will only execute after the user is finished selecting the file. The question then is: what is the best/cleanest way to execute commands in the minibuffer's command loop?
The only way I know to do this is to bind my desired command to a key sequence, and add that sequence to unread-command-events so the key runs once we enter the minibuffer command loop:
(setq unread-command-events (append (listify-key-sequence (kbd "M-s")) unread-command-events)) ; std key-binding for ido-merge-work-directories
(ido-find-file)
But that is very hacky, and I would like to know if there is a better solution.
Thanks!