A Solution to EmacsGolf 4

EmacsGolf 4 didn’t generate a lot of interest, apparently. What little discussion there was centered on why you would want to perform the given transformations rather than how to do so. Nevertheless, the honor of Emacs users everywhere is at stake here so I offer the following solution using multiple-cursors.

Ctrl+n Ctrl+n Ctrl+f move to first defvar
Ctrl+* invoke multiple cursors on defvar
Ctrl+e move to end of line
Ctrl+BackSpace Ctrl+BackSpace kill variable name
Ctrl+y yank it back
SPC n i l add nil
Ctrl+n Ctrl+a beginning of second line
Meta+( wrap list in parens
s e t q SPC add setq
Ctrl+y add variable name
Ctrl+d delete extra space
Ctrl+n down to third line
Ctrl+x Ctrl+t interchange second and third lines
Ctrl+p Ctrl+p up to second line
Meta+^ join with first
Return exit multiple cursors

That 29 keystrokes. If you’re not using multiple-cursors (why not?!) you could use almost the same keystrokes with a macro. Substitute 【F3】 for 【Ctrl+*】 and 【Ctrl+3 Ctrl+n F4】 for 【Return】. Then use 【Meta+0 F4】 to run the macro on the rest of the buffer.

Surely the Irreal heavy hitters can do better than my 29. If you can, leave a comment. It’s not too late.

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