Making The Emacs Minibuffer Recursive

Mickey, over at Mastering Emacs, has a great post on Executing Shell Commands in Emacs and does his usual excellent job of explaining the fine points of his subject matter. I’ve written about some of this material here, but there’s lot of stuff I haven’t covered so you should definitely go read the post.

One of the things that was new to me was recursive minibuffers. What that means is that you can interrupt what you’re doing in the minibuffer to run some other command and then use it’s output in the original command. The need to do this doesn’t come up often—at least for me—but when it does it’s frustrating not to be able to do it. By default, the recursion is turned off but all you need do to enable it is to add

(setq enable-recursive-minibuffers t)

to your .emacs or init.el file.

Here’s a (slightly contrived) example of how you might use the capability. Suppose you’re one of those annoying bloggers who, unlike me, has a backlog of posts ready to publish and that you keep their file names in a file called scheduled. You want to load the top file into Emacs so that you can publish it with org2blog. You type 【Ctrl+x Ctrl+f】 to call find-file but realize you don’t know the first file on the list. You can load its name into the minibuffer for find-file (or ido-find-file) by typing 【Ctrl+u Meta+!】 and then head -1 scheduled. As Mickey explains, the output of most shell commands will have a newline at the end so you’ll need to delete it before pressing 【Return】.

Mickey gives another example of its use but I don’t want to step on his post by reiterating it here so, again, you should go read his post. If you have an interesting use case for this capability, leave a comment.

This entry was posted in General and tagged . Bookmark the permalink.