Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable hl-line feature in specified mode

Tags:

emacs

elisp

i enable hl-mode in global scope with the following code.

(global-hl-line-mode t) 

to turn off hl-line feature in a specified mode. i do it with the following code.

(add-hook 'org-mode-hook (lambda () (global-hl-line-mode 0)))

but it turns off the hl-line feature for global scope.

how to disable hl-line feature in a specified mode?

like image 574
luozengbin Avatar asked Apr 03 '12 09:04

luozengbin


2 Answers

There is often information and documentation in the Commentary section in the source file.

[...]
;; You could make variable `global-hl-line-mode' buffer-local and set
;; it to nil to avoid highlighting specific buffers, when the global
;; mode is used.
[...]

Thus, you can put something like this in your .emacs.

(global-hl-line-mode)
(make-variable-buffer-local 'global-hl-line-mode)
(add-hook 'some-mode-hook (lambda () (setq global-hl-line-mode nil)))
...
like image 148
Daimrod Avatar answered Sep 20 '22 21:09

Daimrod


use hl-line-mode insted of global-hl-line-mode.

EDIT: You're right. This doesn't work.

The commentary says that the global-mode isn't meant to be used. I take it to mean that you can't selectively disable it once enabled.

I enable the hl-line-mode in major-mode hooks where I need it.

like image 36
event_jr Avatar answered Sep 19 '22 21:09

event_jr