2

in my init.el file I have the following:

(global-linum-mode 1)
(add-hook 'term-mode-hook (lambda () (linum-mode))) 

However, when I enter ansi-term-mode linum mode is still on.

I have also tried

(add-hook 'ansi-term-mode-hook (lambda () (linum-mode))) 

and

(add-hook 'term-mode-hook (lambda () (linum-mode nil))) 

Does anyone have any idea how to turn off linum mode for ansi-term-mode only?

  • Did you try (linum-mode -1) ? – YoungFrog Oct 13 '15 at 21:38
  • @YoungFrog yes to no avail. – Startec Oct 14 '15 at 3:31
  • @Startec Just to be clear, you need to have (global-linum-mode 1) (add-hook 'term-mode-hook (lambda () (linum-mode -1))), then restart emacs to see the effect. Note the -1. – Kaushal Modi Jan 11 '16 at 16:02
  • This question gets asked over and over, with the description and title being about the specific mode. Someone (TM) please edit this to replace it by a (Community) generic question that is posed as is the SO duplicate automatically disable a global minor mode for a specific major mode. – Drew Nov 24 '17 at 18:15
1

Refer to the duplicate question on StackOverflow:

automatically disable a global minor mode for a specific major mode


This was converted to a comment when it's a perfectly sensible answer (seeing as how we can't close for duplication across SE sites), so this text is just to prevent that from happening...

0

You can also do something like this:

(add-hook 'after-change-major-mode-hook
            '(lambda ()
               (linum-mode (if (or (equal major-mode 'text-mode) (equal major-mode 'term-mode) (equal major-mode 'help-mode)) 0 1))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.