tags:

views:

34

answers:

1

Hi,

I use (global-hl-line-mode) to enable hl-line-mode, But i want to use it in certain mode like cc-mode, so i add this line to mode-hook, (setq hl-line-mode t), it doesn't work, i enable hl-line-mode use M-x, it shows disabled, which means at first, it's really enabled, but i can't see any highlight.

Same problem occurs to linum-mode, maybe there are others. Anyone knows what's wrong with it?

Thanks.

+2  A: 

In general, it's a good idea to turn the mode on through the function call, rather than just setting the variable. The function call will set the variable for you, and likely do some other work.

Try this:

(add-hook 'c-mode-common-hook 
          (lambda () (hl-line-mode 1)
                     (linum-mode 1)))
Trey Jackson