2

Every time I open my file, I have to M-x ruby-mode to get emacs to do the syntax highlighting I want. The file is a .erb so it doesn't recognize the ruby right away.

Is there a Unix command to start emacs in ruby mode when I'm opening a file? I know about the -f option but it doesn't seem to work when I'm opening a file. If I type emacs -f ruby-mode myFile it doesn't work.

kevin
  • 933
  • 1
  • 12
  • 20

2 Answers2

7

Have you tried adding to your dotfile:

(add-to-list 'auto-mode-alist '("\\.erb\\'" . ruby-mode))
user673592
  • 2,090
  • 1
  • 22
  • 37
  • 1
    When Emacs is started, it normally tries to load a Lisp program from an initialization file, or init file for short. This file, if it exists, specifies how to initialize Emacs for you. Emacs looks for your init file using the filenames ~/.emacs, ~/.emacs.el, or ~/.emacs.d/init.el; you can choose to use any one of these three names. Here, ~/ stands for your home directory. – raju-bitter Aug 22 '12 at 19:12
  • This may also prove useful: http://stackoverflow.com/questions/10545437/how-to-disable-the-beep-in-emacs-on-windows/10545955#10545955 – phils Aug 22 '12 at 21:58
2

The simplest solution is if you put a ruby comment to the beginning of the file which specifies its mode:

# -*- ruby -*-
Tom
  • 7,515
  • 7
  • 38
  • 54