5

I have linum-mode enabled globally in my Emacs configuration. Being enabled globally means it is also applied to the speedbar which is undesirable.

The only suggestion I found for this issue, was in the archived Emacs help mailing list, which suggests the following speedbar-mode-hook:

(add-hook 'speedbar-mode-hook (lambda () (linum-mode -1)))

Unfortunately adding this to my configuration doesn't have the desired effect and the speedbar still has line numbers.

Edit: the above add-hook seems to work correctly after all, at least for Emacs >= 24.3. Leaving question for reference purposes since there isn't any other relating to this matter on StackOverflow.

Pedro Romano
  • 10,973
  • 4
  • 46
  • 50
  • 1
    Your add-hook should have the intended effect if you use Emacs-24.4 (maybe even already 24.3, can't remember exactly when I made that change). – Stefan Jan 16 '14 at 15:14
  • I must have changed the place in my `.emacs` where I put the `add-hook`, because now it is indeed working with Emacs-24.3. Thanks for the confirmantion @Stefan. – Pedro Romano Jan 16 '14 at 20:07

1 Answers1

5

You can use speedbar-before-popup-hook hook for achieving what you want:

(add-hook 'speedbar-before-popup-hook (lambda () (linum-mode -1)))

I am not sure why the generic mode hook is not working, though.

juanleon
  • 9,220
  • 30
  • 41
  • 2
    The reason the mode hook doesn't work is http://stackoverflow.com/questions/6837511/automatically-disable-a-global-minor-mode-for-a-specific-major-mode/6839968#6839968 – phils Jan 16 '14 at 12:04
  • Thanks for the pointer. Since speedbar define the hook, I would say that speedbar code is misleading not to say buggy. – juanleon Jan 16 '14 at 13:04
  • I am accepting this as a possible alternative for Emacs < 24.3, since with 24.3, `speedbar-mode-hook` seems to be working correctly after all. – Pedro Romano Jan 16 '14 at 20:09