Clean way to perform commands in the Emacs minibuffer

Posted by Christopher Monsanto on Stack Overflow See other posts from Stack Overflow or by Christopher Monsanto
Published on 2012-07-08T05:35:05Z Indexed on 2012/07/08 21:15 UTC
Read the original article Hit count: 304

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about emacs

Related posts about elisp