Need some help setting up ruby mode

Discussion in 'Ruby' started by francisrammeloo@hotmail.com, Aug 10, 2005.

  1. Guest

    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?
    , Aug 10, 2005
    #1
    1. Advertising

  2. Jim Menard Guest

    wrote:
    > 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
    --
    Jim Menard, , http://www.io.com/~jimm
    "I am sure that like Java, [C#] will be a 'no pointer' language, where the
    most common runtime error will be a 'NULL pointer exception'."
    -- Jerry Kott, in comp.lang.smalltalk
    Jim Menard, Aug 10, 2005
    #2
    1. Advertising

  3. Guest

    I can find my emacs file. Am I supposed to create it myself? I'm using
    Windows XP and GNU Emacs 21.3.1.
    , Aug 10, 2005
    #3
  4. Jim Menard Guest

    wrote:
    > 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
    --
    Jim Menard, , http://www.io.com/~jimm
    "I am sure that like Java, [C#] will be a 'no pointer' language, where the
    most common runtime error will be a 'NULL pointer exception'."
    -- Jerry Kott, in comp.lang.smalltalk
    Jim Menard, Aug 10, 2005
    #4
  5. Guest

    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?
    , Aug 10, 2005
    #5
  6. Jim Menard Guest

    wrote:
    > 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
    --
    Jim Menard, , http://www.io.com/~jimm
    "I am sure that like Java, [C#] will be a 'no pointer' language, where the
    most common runtime error will be a 'NULL pointer exception'."
    -- Jerry Kott, in comp.lang.smalltalk
    Jim Menard, Aug 10, 2005
    #6
  7. Guest

    Thanks Jim, it works now!


    Best regards,
    Francis
    , Aug 10, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John J Lee
    Replies:
    3
    Views:
    470
    bruno at modulix
    Dec 1, 2005
  2. Edward Loper
    Replies:
    0
    Views:
    457
    Edward Loper
    Aug 7, 2007
  3. John J Lee
    Replies:
    0
    Views:
    511
    John J Lee
    Aug 7, 2007
  4. Edward Loper

    mmm-mode, python-mode and doctest-mode?

    Edward Loper, Aug 9, 2007, in forum: Python
    Replies:
    0
    Views:
    425
    Edward Loper
    Aug 9, 2007
  5. Neal Becker
    Replies:
    0
    Views:
    376
    Neal Becker
    Aug 9, 2007
Loading...

Share This Page