Use global-hl-line-mode instead of hl-line
It's easier for users to remove one hook than to remove four, and Emacs users tend to expect global-hl-line-mode, but not hl-line-mode.
This commit is contained in:
parent
f40a2e1ed7
commit
472ec52481
1 changed files with 17 additions and 1 deletions
|
@ -391,8 +391,24 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original
|
|||
|
||||
(use-package! hl-line
|
||||
;; Highlights the current line
|
||||
:hook ((prog-mode text-mode conf-mode special-mode) . hl-line-mode)
|
||||
:hook (doom-first-buffer . global-hl-line-mode)
|
||||
:init
|
||||
(defvar global-hl-line-modes '(prog-mode text-mode conf-mode special-mode)
|
||||
"What modes to enable `hl-line-mode' in.")
|
||||
:config
|
||||
;; HACK I reimplement `global-hl-line-mode' so we can white/blacklist modes in
|
||||
;; `global-hl-line-modes' _and_ so we can use `global-hl-line-mode',
|
||||
;; which users expect to control hl-line in Emacs.
|
||||
(define-globalized-minor-mode global-hl-line-mode hl-line-mode
|
||||
(lambda ()
|
||||
(and (not hl-line-mode)
|
||||
(cond ((null global-hl-line-modes) nil)
|
||||
((eq global-hl-line-modes t))
|
||||
((eq (car global-hl-line-modes) 'not)
|
||||
(not (derived-mode-p global-hl-line-modes)))
|
||||
((apply #'derived-mode-p global-hl-line-modes)))
|
||||
(hl-line-mode +1))))
|
||||
|
||||
;; Not having to render the hl-line overlay in multiple buffers offers a tiny
|
||||
;; performance boost. I also don't need to see it in other buffers.
|
||||
(setq hl-line-sticky-flag nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue