0

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.

4

2 回答 2

0

要解决您在这里遇到的具体问题,load-path应该包含目录,而不是文件路径。所以,试试这个:

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

顺便说一句,我还是更喜欢旧的ruby-electric

于 2013-01-15T19:54:11.407 回答
0

electric-indent-mode是一种全局次要模式(即它适用于所有模式中的所有缓冲区),因此只需在 .emacs 中启用一次,无需使用钩子。

于 2013-01-15T14:27:22.437 回答