Refactor hl-line eob fix in Emacs 26+

This commit is contained in:
Henrik Lissner 2018-09-04 04:11:32 +02:00
parent 48c77b1126
commit 8b7404bf75
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -159,14 +159,15 @@ shorter major mode name in the mode-line. See `doom|set-mode-name'.")
;; On Emacs 26+, when point is on the last line, hl-line highlights bleed into ;; On Emacs 26+, when point is on the last line, hl-line highlights bleed into
;; the rest of the window after eob. This is the fix. ;; the rest of the window after eob. This is the fix.
(unless (get 'display-line-numbers 'nlinum) (when EMACS26+
(defun doom--line-range () (defun doom--line-range ()
(cons (line-beginning-position) (cons (line-beginning-position)
(cond ((save-excursion (cond ((let ((eol (line-end-position)))
(goto-char (line-end-position)) (and (= eol (point-max))
(and (eobp) (not (bolp)))) (/= eol (line-beginning-position))))
(1- (line-end-position))) (1- (line-end-position)))
((or (eobp) (save-excursion (forward-line) (eobp))) ((or (eobp)
(= (line-end-position 2) (point-max)))
(line-end-position)) (line-end-position))
((line-beginning-position 2))))) ((line-beginning-position 2)))))
(setq hl-line-range-function #'doom--line-range)) (setq hl-line-range-function #'doom--line-range))