30
Jan 09Unique shell helper for Emacs
To launch a shell in Emacs, you can use M-x shell. However, when you want to launch another one, you have to name the second shell. More…
To launch a shell in Emacs, you can use M-x shell. However, when you want to launch another one, you have to name the second shell. More…
I needed to batch compile some files recently, and I had to lookup how to do this with Aquamacs. It’s pretty simple. If Aquamacs is at /Applications/Aquamacs, then this will work:
/Applications/Aquamacs\ Emacs.app/Contents/MacOS/Aquamacs\ Emacs -nw -batch -f batch-byte-compile /path/to/elisp-file.el
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 ""))))
For some simple analysis I’m doing, I needed a routine to calculate squared Euclidean distance in Ruby on two hashes. The squared Euclidean distance d2 between two n-dimensional vectors x1 and x2 is:
I needed this calculation for values corresponding to the intersection of the set of keys for two hashes. I came up with a couple of ways to do this.