Step 1: Why not upgrade emacs?
Did you know emacs finally released a new version?!
If you are using MacPorts, do this for a terminal (non-gui version). Do port variants emacs for other options.
sudo port install -v emacs
Step 2: Download the code
We are going to install our lisp code in ~/.emacs.d/site-lisp which I think is more-or-less standard, but you could use any directory.
export SITE_LISP=~/.emacs.d/site-lisp
mkdir -p $SITE_LISP
svn export http://svn.ruby-lang.org/repos/ruby/trunk/misc ${SITE_LISP}/ruby
emacs -batch -f batch-byte-compile ${SITE_LISP}/ruby
Don't forget that last step! That compiles the lisp code, and will make emacs run faster (handy if you re-indent a large file).
Step 3: Configure your .emacs
Add this to your .emacs. This is a complete rip from RubyGardens's Installing Emacs Extensions, with the exception of the first line.
;; ruby
;; based on http://www.rubygarden.org/Ruby/page/show/InstallingEmacsExtensions
;;
(add-to-list 'load-path "~/.emacs.d/site-lisp/ruby")
(autoload 'ruby-mode "ruby-mode"
"Mode for editing ruby source files")
(add-to-list 'auto-mode-alist '("\\.rb$" . ruby-mode))
(add-to-list 'interpreter-mode-alist '("ruby" . ruby-mode))
(autoload 'run-ruby "inf-ruby"
"Run an inferior Ruby process")
(autoload 'inf-ruby-keys "inf-ruby"
"Set local key defs for inf-ruby in ruby-mode")
(add-hook 'ruby-mode-hook
'(lambda ()
(inf-ruby-keys)))
;; If you have Emacs 19.2x or older, use rubydb2x
(autoload 'rubydb "rubydb3x" "Ruby debugger" t)
;; uncomment the next line if you want syntax highlighting
(add-hook 'ruby-mode-hook 'turn-on-font-lock)
6 comments:
Hey,
Just wanted to thank you for posting this. I've spent all morning trying to get ruby mode to work, and this finally did it for me. Thanks!
-Jacob
Thank you! I was surprised by how little Emacs/Ruby info was available, I believe your page is the only one that clearly tells what needs to happen to turn ruby mode on.
Thanks alot! After reading like a dozen other sites and getting nowhere, this finally worked.
Another satisfied customer. Thank you
My thanks also! This was way too easy! And now back to work with increased ruby productivity ...
Vern
I've spent so much time looking for a decent guide. Yours worked! Thanks!
Post a Comment