Remarks on EmacsGolf 2

There were a lot of good solutions to this challenge. I thought the interesting part would be switching the character entries in the table. If you are just before the first character pair vector, you can do that in 5 keystrokes with

F3 start keyboard macro
Meta+f forward to just after A
Meta+t switch characters
Meta+0 for the whole table…
F4 …execute the macro

It turns out, however, that the rest of the problem—what I thought of as “grunt work”—has some lessons to teach us too. Fuco has a nice trick for transposing “latin” and “gothic”: he makes use of the fact that a 0 argument to transpose words will transpose the words at or after the point and mark. I vaguely knew that but had never seen it used. Fuco also has a solution using multiple-cursors that solves the challenge in 22 keystrokes. In both solutions he makes use of his smartparens package. I’m not currently using it but it looks pretty nice so I’m going to look into it a bit more.

Jorge has a very nice solution in 21 keystrokes. Phil refines that a bit and gets it down to 17.

Xah Lee has a solution using query-replace-regexp that gets it done in 18 keystrokes using some of the customizations to his .emacs file.

Lee has sent me another proposed challenge, which I’ll post in a bit, but we shouldn’t make him do all the work or have all the fun. If you enjoy working on EmacsGolf challenges, please send your own challenges to challenges at the domain of this blog.

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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>