From 8b7404bf7577cd5744fcb078bb0c5214822c37e5 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 4 Sep 2018 04:11:32 +0200 Subject: [PATCH] Refactor hl-line eob fix in Emacs 26+ --- core/core-ui.el | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/core-ui.el b/core/core-ui.el index 0a018fd8d..bb596db38 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -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 ;; the rest of the window after eob. This is the fix. - (unless (get 'display-line-numbers 'nlinum) + (when EMACS26+ (defun doom--line-range () (cons (line-beginning-position) - (cond ((save-excursion - (goto-char (line-end-position)) - (and (eobp) (not (bolp)))) + (cond ((let ((eol (line-end-position))) + (and (= eol (point-max)) + (/= eol (line-beginning-position)))) (1- (line-end-position))) - ((or (eobp) (save-excursion (forward-line) (eobp))) + ((or (eobp) + (= (line-end-position 2) (point-max))) (line-end-position)) ((line-beginning-position 2))))) (setq hl-line-range-function #'doom--line-range))