 
If you're like me, you'll usually have a lot of buffers open in emacs. To
quickly switch between them, you press C-x b (Ctrl-X and b), and type
the beginning of buffer name. This is made much more convenient with
e.g. ido (see Switching Buffers) or icicles. They allow you switch to a
buffer by typing just some characters appearing anywhere in the buffer name,
autocompletion etc.
The question for today is: what to do if am not searching for a buffer or file, but for some emacs command?
Often, I search for a certain command, ie. the ones that come after
M-x. After typing M-x there's autocompletion if you know the beginning
of the command… but maybe I remember only it was something with string,
but exactly how? Was it replace-string or string-replace?
For these deep problems, there is smex (think: search-M-x). smex brings
ido-style completion to choosing commands.
After installing the smex package, you can put something like the following in your .emacs:
(setq smex-save-file "~/.emacs.d/smex.save") ;; keep my ~/ clean (require 'smex) (smex-initialize) (global-set-key (kbd "M-X") 'smex)
As you can see, I have set the keybinding to M-X, that is (for most people)
Alt-Shift-x; of course you could override the normal M-x
('execute-extended-command', note the small x), but usually the normal
completion is fine.
Admittedly, smex serves a niche use-case, but I still use it a couple of
times a day.
[ Note that packages like icicles and anything can do similar things; they
do much more as well, and I haven't had the chance to play with those in
detail, so for the time being I stay with smex. ]
 

