Repeating Things In Emacs, and stop envying Vim...

I really, really like Emacs. Vim has a "repeat the last set of commands since a mode switch" by arrowing around and pressing "."

That seems to beat Emacs macros. I suppose it is an implicit macro. Since Emacs is (more) modeless, no such implicit capability exists without the chore of recording and repeating a macro.

But then I found out about dot-mode, that takes a stab at doing just that: see http://www.wyrick.org/source/elisp/dot-mode/ repeat.el

Also, a "dot-mode" like feature is built into Emacs 20+ via:

Ctrl-x z

This puts you into "repeat mode" (nee' vi-dot-mode) and repeatedly hitting "z" thereafter repeats the last command. It's not too useful because (unlike the dot-mode pointed above), it records motion keystrokes too. Thus, when you repeat, you repeat the very last "command", which, at least for my mode of usage, is typically an arrow-down. :-( The dot-mode you sent over does a better job. It only recalls commands that actually change the buffer.

But for my usage patterns it seemed more plausible to just make it easier to record a macro by remapping the macro start/end/run keys:

(define-key global-map [(control ?,)] 'call-last-kbd-macro) (define-key global-map [(control ?9)] 'start-kbd-macro) ; start macro recording (define-key global-map [(control ?0)] 'end-kbd-macro) ; stop macro recording

So now I press Ctrl-9 to start recording of a macro, Ctrl-0 to end recording of a macro and Ctrl-, to run the last recorded macro. This feels a lot better to use than "Ctrl-x shift-9 <do stuff> Ctrl-x shift-0" and then "Ctrl-x e" to run it.

Defining easier macro keys is a must, your brain is already full enough when creating and executing macros that the default 3-4 key combos are way too much. I've also used these for while:

(global-set-key [(f5)] 'start-kbd-macro) (global-set-key [(control f5)] 'end-kbd-macro) (global-set-key [(f6)] 'call-last-kbd-macro) (global-set-key [(control f6)] 'name-last-kbd-macro) (global-set-key [(control shift f6)] 'insert-kbd-macro)

The last two I use rarely and don't usually remember, but they help save (and edit) an important macro that's worth keeping.

Bottom line: try repeat.el!