In reference to indent ruby code on the fly in emacs, how do I make a minor mode fire up automatically after a major mode is entered?

Basically, when I open a Ruby file (which opens in ruby-mode), I would like electric-indent-mode to start up automatically.

Also, I tried installing ruby-end but it is not working. I copied the ruby-end.rb into ~/.emacs.d and added the following into init.el:

(add-to-list 'load-path "ruby-end")
(require 'ruby-end)

I also ruby-end.pl and I get the same error. Here is the result of --debug-init's error:

Debugger entered--Lisp error: (file-error "Cannot open load file" "ruby-end")
2   require(ruby-end)
3   eval-buffer(#<buffer  *load*> nil "/Users/nayef/.emacs.d/init.el" nil t)  ; Reading at buffer position 1392
4   load-with-code-conversion("/Users/nayef/.emacs.d/init.el" "/Users/nayef/.emacs.d/init.el" t t)
5   load("/Users/nayef/.emacs.d/init" t t)
6   #[0 "^H\205\262^@     \306=\203^Q^@\307^H\310Q\202;^@ \311=\204^^^@\307^H\312Q\202;^@\313\307\314\315#\203*^@\316\202;^@\313\307\314\317#\203:^@\320\nB^R$
7   command-line()
8   normal-top-level()

Any ideas? Does anyone have pointers on Ruby on Rails development in Emacs? I use command-line based text Emacs 24.2.1.

有帮助吗?

解决方案

electric-indent-mode is a global minor mode (i.e. it applies to all buffers in all modes), so just enable it once in your .emacs, no need to play around with hooks.

其他提示

To solve the specific problem you're having here, load-path should contain directories, not file paths. So, try this:

(add-to-list 'load-path (expand-file-name "~/.emacs.d"))
(require 'ruby-end)

By the way, I still prefer the older ruby-electric.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top