当前位置: 动力学知识库 > 问答 > 编程问答 >

Can't use (setq *-mode) instead of (global-*-mode) in Emacs

问题描述:

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.

网友答案:

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)))
分享给朋友:
您可能感兴趣的文章:
随机阅读: