{"id":1097,"date":"2013-08-30T14:43:44","date_gmt":"2013-08-30T21:43:44","guid":{"rendered":"http:\/\/zackmdavis.net\/blog\/?p=1097"},"modified":"2013-08-30T14:43:44","modified_gmt":"2013-08-30T21:43:44","slug":"doend-macros-for-emacs","status":"publish","type":"post","link":"http:\/\/zackmdavis.net\/blog\/2013\/08\/doend-macros-for-emacs\/","title":{"rendered":"do\/end Macros for Emacs"},"content":{"rendered":"<p>Dear reader, Ruby is a pretty okay programming language, but I have to say I feel ambivalent about the use of <code>do<\/code> and <code>end<\/code> as block delimiters. (Contrast to braces in C\/Java\/<em>&amp;c.<\/em> or indentation in Python.) <em>Three<\/em> keystrokes just to close a block?! Scandalous!<\/p>\n<p>Or <em>maybe<\/em> ... <em>not<\/em>-so-scandalous. For two or three <em>characters<\/em> need not imply two or three <em>keystrokes<\/em>; one need only configure one's editor with convenient bindings for the insertion of <code>do<\/code> and <code>end<\/code>. For example, pasting the following code into one's Emacs init file assigns <code>M-[<\/code> (respectively <code>M-]<\/code>) to insert the text <code>do<\/code> (respectively <code>end<\/code>), much as one would type <code>Shift-[<\/code> (respectively <code>Shift-]<\/code>) for an open- (respectively close-) brace, except with Alt (&quot;Meta&quot; in Emacs parlance) instead of Shift\u2014<\/p>\n<pre><code>(fset 'block-do\r\n   \"do\")\r\n(global-set-key (kbd \"M-[\") 'block-do)\r\n\r\n(fset 'block-end\r\n   \"end\")\r\n(global-set-key (kbd \"M-]\") 'block-end)\r\n<\/code><\/pre>\n<p>I guess this would also be useful for like, Lua.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dear reader, Ruby is a pretty okay programming language, but I have to say I feel ambivalent about the use of do and end as block delimiters. (Contrast to braces in C\/Java\/&amp;c. or indentation in Python.) Three keystrokes just to &hellip; <a href=\"http:\/\/zackmdavis.net\/blog\/2013\/08\/doend-macros-for-emacs\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[40,64],"_links":{"self":[{"href":"http:\/\/zackmdavis.net\/blog\/wp-json\/wp\/v2\/posts\/1097"}],"collection":[{"href":"http:\/\/zackmdavis.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zackmdavis.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zackmdavis.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/zackmdavis.net\/blog\/wp-json\/wp\/v2\/comments?post=1097"}],"version-history":[{"count":9,"href":"http:\/\/zackmdavis.net\/blog\/wp-json\/wp\/v2\/posts\/1097\/revisions"}],"predecessor-version":[{"id":1106,"href":"http:\/\/zackmdavis.net\/blog\/wp-json\/wp\/v2\/posts\/1097\/revisions\/1106"}],"wp:attachment":[{"href":"http:\/\/zackmdavis.net\/blog\/wp-json\/wp\/v2\/media?parent=1097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zackmdavis.net\/blog\/wp-json\/wp\/v2\/categories?post=1097"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zackmdavis.net\/blog\/wp-json\/wp\/v2\/tags?post=1097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}