{"id":1702,"date":"2013-02-15T05:22:00","date_gmt":"2013-02-15T10:22:00","guid":{"rendered":"http:\/\/irreal.org\/blog\/?p=1702"},"modified":"2013-02-15T05:23:47","modified_gmt":"2013-02-15T10:23:47","slug":"remarks-on-emacsgolf-challenge-1","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=1702","title":{"rendered":"Remarks on EmacsGolf Challenge 1"},"content":{"rendered":"<p>Apparently I was a bit sloppy with my wording because everyone missed the fact that there was a second part to this challenge. Every line that started with an \u201copen figure\u201d was supposed to be deleted. That was just a matter of deleting every other line and is easily done with a macro in 5 keystrokes.<\/p>\n<p>My original solution was<\/p>\n<table border=\"2\" frame=\"hsides\" rules=\"groups\" cellspacing=\"0\" cellpadding=\"6\">\n<colgroup>\n<col class=\"left\" \/>\n<col class=\"left\" \/> <\/colgroup>\n<tbody>\n<tr class=\"tr-odd\">\n<td class=\"left\">\u3010<kbd>F3<\/kbd>\u3011<\/td>\n<td class=\"left\">start macro<\/td>\n<\/tr>\n<tr class=\"tr-even\">\n<td class=\"left\">\u3010<kbd>Ctrl<\/kbd>+<kbd>f<\/kbd>\u3011<\/td>\n<td class=\"left\">move to \u201cputhash\u201d<\/td>\n<\/tr>\n<tr class=\"tr-odd\">\n<td class=\"left\">\u3010<kbd>Meta<\/kbd>+<kbd>Shift<\/kbd>+<kbd>f<\/kbd>\u3011<\/td>\n<td class=\"left\">select \u201cputhash\u201d<\/td>\n<\/tr>\n<tr class=\"tr-even\">\n<td class=\"left\"><code>xmsi-add-cycle<\/code><\/td>\n<td class=\"left\">replace<\/td>\n<\/tr>\n<tr class=\"tr-odd\">\n<td class=\"left\">\u3010<kbd>Ctrl<\/kbd>+<kbd>f<\/kbd>\u3011<\/td>\n<td class=\"left\">move after space<\/td>\n<\/tr>\n<tr class=\"tr-even\">\n<td class=\"left\"><code>[<\/code><\/td>\n<td class=\"left\"><\/td>\n<\/tr>\n<tr class=\"tr-odd\">\n<td class=\"left\">\u3010<kbd>Ctrl<\/kbd>+<kbd>7<\/kbd> <kbd>Ctrl<\/kbd>+<kbd>f<\/kbd>\u3011<\/td>\n<td class=\"left\">move after strings<\/td>\n<\/tr>\n<tr class=\"tr-even\">\n<td class=\"left\"><code>]<\/code><\/td>\n<td class=\"left\"><\/td>\n<\/tr>\n<tr class=\"tr-odd\">\n<td class=\"left\">\u3010<kbd>Meta<\/kbd>+<kbd>d<\/kbd> <kbd>Meta<\/kbd>+<kbd>d<\/kbd>\u3011<\/td>\n<td class=\"left\">delete \u201cxmsi-abrvs\u201d<\/td>\n<\/tr>\n<tr class=\"tr-even\">\n<td class=\"left\">\u3010<kbd>Ctrl<\/kbd>+<kbd>n<\/kbd>\u3011<\/td>\n<td class=\"left\">move to next line<\/td>\n<\/tr>\n<tr class=\"tr-odd\">\n<td class=\"left\">\u3010<kbd>Ctrl<\/kbd>+<kbd>Shift<\/kbd>+<kbd>Delete<\/kbd>\u3011<\/td>\n<td class=\"left\">delete entire line<\/td>\n<\/tr>\n<tr class=\"tr-even\">\n<td class=\"left\">\u3010<kbd>Meta<\/kbd>+<kbd>0<\/kbd> <kbd>F4<\/kbd>\u3011<\/td>\n<td class=\"left\">end macro and execute<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>That&#8217;s 28 keystrokes (not 29; I think I shaved off another by combining the end macro and execute). Notice that deleting the extra lines takes only two additional keystrokes. If you don&#8217;t worry about deleting the lines, you can do a bit better with <code>multiple-cursors<\/code> but then you have to use a macro to get rid of those lines. At least I couldn&#8217;t figure out a way to do it from within <code>multiple-cursors<\/code>.<\/p>\n<p>Magnar Sveen had a nice trick to shave off two more keystrokes by using <code>hippie-expand<\/code>. I tried to integrate that into my solution but after the first time it picked up <code>xmsi-add-cycle<\/code> instead of <code>xmsi-abrvs<\/code> which resulted in cascading <code>-add<\/code>s on subsequent lines. Magnar uses a custom function that looks for the nearest match so his <code>hippie-expand<\/code> trick might have worked with a macro for him.<\/p>\n<p>Fuco had a nice approach using his <code>smartparens<\/code> package. If anyone else has some good tricks it&#8217;s not too late to leave a comment.<\/p>\n<p>If you want to contribute a challenge (please do!) you can mail it to challenges at the domain of this blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apparently I was a bit sloppy with my wording because everyone missed the fact that there was a second part to this challenge. Every line that started with an \u201copen figure\u201d was supposed to be deleted. That was just a &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=1702\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18,57],"class_list":["post-1702","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs","tag-emacsgolf"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1702"}],"version-history":[{"count":2,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1702\/revisions"}],"predecessor-version":[{"id":1704,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1702\/revisions\/1704"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}