04
Sep 08Emacs Lisp – Block Commenting Ruby Code
These days I’m working to become proficient in Emacs (I’ve recently switched from Vim, as Greg mentioned on his blog). With that comes all kinds of things like org-mode, yasnippet, and lots of keyboard combinations.
A part of this current effort I’m learning Emacs Lisp right now. There’s probably a better way to do block comment cycling in Ruby, but this was good practice on writing some simple elisp functions.
(defun ruby-comment-region () "In Ruby, comment out the current region with =begin/=end statements." (interactive) (save-excursion (goto-char (point)) (insert "=end") (goto-char (mark)) (insert "=begin\n"))) (defun ruby-uncomment-region () "In Ruby, uncomment the current region -- remove =begin/=end statements." (interactive) (save-excursion (if (re-search-backward "^=begin") (replace-match "")) (if (re-search-forward "^=end") (replace-match ""))))
September 4th, 2008 at 11:12 pm
judas!!
September 5th, 2008 at 7:25 am
I know I know, it’s terrible. I still call it Escape-Meta-Alt-Ctrl-Shift. Of course, my VAX/VMS coworkers said the same thing when I left EDT for Vim!