0

I use global-autopair-mode, but with Ruby the ruby-electric-mode provides better autopairing.

I'm a n00b to Emacs and Lisp, so I would have thought you could do something like:

(add-hook 'ruby-mode-hook
          (lambda ()
             (autopair-mode nil)
             (ruby-electric-mode t))

This however doesn't work. Is there a way to disable global modes within a major-mode hook?

Currently I'm using the last solution posted here, but it's not very neat and clean.

Community
  • 1
  • 1
jimeh
  • 1,391
  • 1
  • 16
  • 32
  • 1
    Duplicate of [automatically disable a global minor mode for a specific major mode](http://stackoverflow.com/questions/6837511/automatically-disable-a-global-minor-mode-for-a-specific-major-mode) – phils Jul 28 '11 at 12:23
  • Please see https://stackoverflow.com/a/34660219/2402577 – alper Aug 01 '22 at 12:31

2 Answers2

5

autopair mode honors autopair-dont-activate, used like so:

(add-hook 'ruby-mode-hook
          (lambda ()
             (setq autopair-dont-activate t)
             (ruby-electric-mode t))
phils
  • 71,335
  • 11
  • 153
  • 198
jtahlborn
  • 52,909
  • 5
  • 76
  • 118
0

Try replacing (autopair-mode nil) with (autopair-mode -1).

Victor Deryagin
  • 11,895
  • 1
  • 29
  • 38