Pregunta

I am pretty new to emacs and I have installed a 'starter kit' for Ruby on Rails, which works nicely. However, I am also developing in PHP and the starter brings about some problems.

I want to switch off some of the minor modes when editing all files other than ruby files.

in my .emacs file I have:

(add-to-list 'load-path "~/.emacs.d/plugins/ruby-block")
(require 'ruby-block)

If I comment this out then the minor disappears for all files so I tried adding a hook (although I am a complete beginner so this might be the wrong approach) like so:

(add-hook 'ruby-mode-hook (lambda () (add-to-list 'load-path "~/.emacs.d/plugins/ruby-block")))
(add-hook 'ruby-mode-hook (lambda () (require 'ruby-block)))

I also tried using the event hook to call a function and moving the lines above into a function but still couldn't get this to work.

I would really appreciate any help removing the ruby-block minor from all files other than .rb

¿Fue útil?

Solución

I had used ruby-block-mode, but I had remove it.

here is what I setting for ruby-block-mode, give it a try:

(eval-after-load 'ruby-mode
  '(progn
    (require 'ruby-block)
    (ruby-block-mode t)
    (setq ruby-block-highlight-toggle t)))

Otros consejos

Even though the two lines you mention are necessary for the minor-modes (btw: which?) to work, they are not responsible for turning the minor-modes on. The first one:

(add-to-list 'load-path "~/.emacs.d/plugins/ruby-block")

just extends a path-variable, i.e., where Emacs will look for code to load, while the second one:

(require 'ruby-block)

reads some library code, i.e., mostly function definitions.

The actual mode invocation would probably look more like this:

(ruby-block-mode t)

You were on the right path with using the 'ruby-mode-hook but you don't have to worry about the load-path nor the (require...). They can stay as they are, i.e., no need to comment them out. Instead, find the actual invocation of the minor mode and put it in your (lambda ()...) declaration and you should be fine.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top