如何在指定模式下禁用hl-line功能

luo*_*bin 6 emacs elisp

我使用以下代码在全局范围内启用hl-mode.

(global-hl-line-mode t) 
Run Code Online (Sandbox Code Playgroud)

在指定模式下关闭hl-line功能.我使用以下代码执行此操作.

(add-hook 'org-mode-hook (lambda () (global-hl-line-mode 0)))
Run Code Online (Sandbox Code Playgroud)

但它关闭了全球范围的hl-line功能.

如何在指定模式下禁用hl-line功能?

Dai*_*rod 9

Commentary 源文件的部分中经常包含信息和文档.

[...]
;; 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.
[...]
Run Code Online (Sandbox Code Playgroud)

因此,你可以把这样的东西放在你的.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)))
...
Run Code Online (Sandbox Code Playgroud)