LinuxHappy's Weblog

Failures and Successes of Linux-based Development

Ruby syntax highlighting in emacs

Posted by linuxhappy on February 2, 2008

Found this awesome link for getting ruby syntax highlighting in emacs and seems to work swell in for Ubuntu 7.10.

sudo cp inf-ruby.el /usr/local/share/emacs/22.1/site-lisp/.
sudo cp ruby-mode.el /usr/local/share/emacs/22.1/site-lisp/.

then… copy and paste this into your ~/.emacs file

;loads ruby mode when a .rb file is opened.
(autoload 'ruby-mode "ruby-mode" "Major mode for editing ruby scripts." t)
(setq auto-mode-alist  (cons '(".rb$" . ruby-mode) auto-mode-alist))
(setq auto-mode-alist  (cons '(".rhtml$" . html-mode) auto-mode-alist))

Now you’re on your way to open your .rb files (assuming font-lock-mode is on) with syntax highlighting!
(Alt-x font-lock-mode)

About these ads

5 Responses to “Ruby syntax highlighting in emacs”

  1. G.Zeballos said

    Thanks for the info but you should know if you haven’t noticed already, that the blog template is truncating your code up there in such a way that if you are not careful with the select you could end up missing parts of the code and addresses (at least on my browser display setup). Just a note for your fellow readers to double check your addresses and commands.
    Thanks again

  2. jon said

    Thanks for this.

    In Ubuntu the directory you need to copy the files to has changed to /usr/local/share/emacs/site-lisp/.

  3. [...] This blog post is useful just get inf-ruby.el and ruby-mode.el then just copy paste this to our ~/.emacs file [...]

  4. ryan said

    This is definitely a useful tidbid. Something else to keep in mind (if you’re on a shared hosting service or don’t have access to the sudo command) is that you can put the .el files in whatever directory you like, you’ll just have to make sure to tell emacs to look there.

    if you save the files to your ~/.emacs.d/ directory, simply add the following line to your .emacs file

    (add-to-list ‘load-path “~/.emacs.d/”)

  5. [...] Posted in Uncategorized by Arie Kusuma Atmaja on September 12, 2009 This blog post is useful just get inf-ruby.el and ruby-mode.el then just copy paste this to our ~/.emacs [...]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: