Reputation: 303
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?
Upvotes: 8
Views: 1978
Reputation: 1027
write the following line in your dotEmacs file, and use f5 to toggle the hl-line-mode
(global-set-key [f5] 'hl-line-mode)
Upvotes: 0
Reputation: 5030
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)))
...
Upvotes: 14
Reputation: 17707
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.
Upvotes: 1