Need some help setting up ruby mode

F

francisrammeloo

Hi all,

I'm an emacs newbie but would like to use the editor for ruby coding.

I have downloaded "ruby-mode.el" and I don't know what to do with it!

I worked my way through the emacs built-in tutorial. I know how to use
modes, but I can't find any information about how to ADD modes to
emacs.

I understand that this may be difficult to explain on the newsgroup.
Any link to helpful information is welcome too!


Best regards,
Francis


PS: Perhaps my basic question is: how do I set up emacs for ruby coding?
 
J

Jim Menard

Hi all,

I'm an emacs newbie but would like to use the editor for ruby coding.

I have downloaded "ruby-mode.el" and I don't know what to do with it!

I worked my way through the emacs built-in tutorial. I know how to use
modes, but I can't find any information about how to ADD modes to
emacs.

I understand that this may be difficult to explain on the newsgroup.
Any link to helpful information is welcome too!

Put ruby-mode.el somewhere where Emacs can find it. I have a directory where
I put that kind of thing, "~/lib/elisp". In my .emacs file I added

(add-to-list 'load-path "~/lib/elisp")

so it can find all of my .el files. Next, add

(autoload 'ruby-mode "ruby-mode" "Ruby mode" t nil)
(autoload 'inf-ruby "inf-ruby" "Ruby inferior process (irb)" t nil)
(setq interpreter-mode-alist (append '(("ruby" . ruby-mode))
interpreter-mode-alist))
(setq auto-mode-alist
(append '(("\\.rbw?$" . ruby-mode)
("\\.rhtml$" . html-mode)
("\\.gem\\(spec\\)?$" . ruby-mode)
("[Rr]akefile" . ruby-mode))
auto-mode-alist))

and optionally a ruby-mode-hook for yourself. Here is a subset of mine:

(setq ruby-mode-hook
(lambda ()
(define-key ruby-mode-map "\r" 'newline-and-indent)
(define-key ruby-mode-map "\M-\C-h" 'backward-kill-word)
(setq c-tab-always-indent nil)
(abbrev-mode t)
(font-lock-mode 1)))

Jim
 
F

francisrammeloo

I can find my emacs file. Am I supposed to create it myself? I'm using
Windows XP and GNU Emacs 21.3.1.
 
J

Jim Menard

I can find my emacs file. Am I supposed to create it myself? I'm using
Windows XP and GNU Emacs 21.3.1.

I set the environment variable HOME to point to my home directory, then I
created the file .emacs in that directory. If you don't use HOME, then I
think you need to put .emacs in the emacs-XX.Y directory itself.

Jim
 
F

francisrammeloo

Ok I found out that I can create a file called _emacs in C:\
Emacs now reads this file at startup.

Thank you Jim, I copy/pasted the lisp code you posted and now I can
select "M-x ruby-mode".

The problem now is that this doesn't change anything. There is no
syntax highlighting.

Is there something missing?
 
J

Jim Menard

Ok I found out that I can create a file called _emacs in C:\
Emacs now reads this file at startup.

Thank you Jim, I copy/pasted the lisp code you posted and now I can
select "M-x ruby-mode".

The problem now is that this doesn't change anything. There is no
syntax highlighting.

Is there something missing?

(global-font-lock-mode t) ; always turn on, where available

; Provide "M-x flfb" as a shortcut
(defalias 'flfb 'font-lock-fontify-buffer)


Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top