So, you just executed a complex, wonderful emacs command using the minibuffer and you’re so excited that need to immediately write it down, lest you forget. As you may already know, you don’t need pen and paper for that. Emacs will do it for you: just press
C-x ESC ESC (that is,
repeat-complex-command) and you’ll see an Elisp form in your minibuffer that reproduces your last command (
C-h w C-x ESC ESC for more details). Now
C-a C-k and you got it in the kill-ring, ready to be yanked in one of your configuration files.
I don’t use this trick that much because over the years more and more emacs automatisms are recorded either in my nervous system or my config files. Except for one thing: defining keybindings. There’re a bunch of ways to define a keybinding in emacs, and i’m never sure what’s the right one when there’re special keys involved. The solution is to define the key interactively with
M-x global-set-key. Once i’m done, i play
C-x ESC ESC and presto: an elisp snippet to yank in my .emacs appears in the minibuffer.