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
是全局次要模式(即,它适用于所有模式中的所有缓冲区),因此只需在.emacs中启用它一次,而无需使用钩子。
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
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.