Monday, August 08, 2005

Ruby: Install emacs extensions and major modes

Emacs is great. Except when you're trying to install extensions or find help on it. So last time, i had trouble adjusting font size. This time, it was adding ruby syntax highlighting. So here it is!

1. Download ruby-mode.el in the stable-snapshot. It was added in 05-2004 and after. It is located in misc/ruby-mode.el

2. Put the ruby-mode.el file in a directory that's searched by emacs or xemacs. One such directory is ./emacs/site-lisp. If you are on FreeBSD machine it is in /usr/local/share/emacs/site-lisp/.

3. Add the following lines to your .emacs file:


(autoload 'ruby-mode "ruby-mode" "Load ruby-mode")
(add-to-list 'auto-mode-alist '("\\.rb\\'" . ruby-mode))
;; uncomment the next line if you want syntax highlighting
;;(add-hook 'sql-mode-hook 'turn-on-font-lock)

[David Ross, Bruce Murphy, Sergei Gnezdov]

Shouldn't that be: (note the $ rather than \\' on the regexp for the filename and asking for font-lock on ruby-mode)

(autoload 'ruby-mode "ruby-mode" "Load ruby-mode")
(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
;; uncomment the next line if you want syntax highlighting
;;(add-hook 'ruby-mode-hook 'turn-on-font-lock)

No comments:

Post a Comment