From 86625d3d428232b1e804ef0a51685c3f22daefe0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 1 Jun 2020 18:33:25 -0400 Subject: [PATCH] "Fix" hl-line bleeding into buffer bg When its face is remapped (e.g. by solaire-mode). Unfortunately, this means highlighting on the 2nd-to-last line becomes janky, but this is the lesser evil of the two. Upgrade to 27 people! Also, don't do anything if solaire-mode isn't enabled. --- modules/ui/doom/config.el | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/modules/ui/doom/config.el b/modules/ui/doom/config.el index f893495fd..fcfcb32a4 100644 --- a/modules/ui/doom/config.el +++ b/modules/ui/doom/config.el @@ -45,22 +45,29 @@ ;; considered an unreal buffer, so solaire-mode must be restored. (add-hook 'org-capture-mode-hook #'turn-on-solaire-mode) + ;; DEPRECATED No longer needed in Emacs 27+ (unless EMACS27+ - ;; On Emacs <=26, when point is on the last line and solaire-mode is - ;; remapping the hl-line face, hl-line's highlight bleeds into the rest of - ;; the window after eob. On Emacs 27 this no longer happens. + ;; HACK On Emacs <=26, when point is on the last (or second to last) line + ;; and solaire-mode is remapping the hl-line face, hl-line's highlight + ;; bleeds into the rest of the window after eob. On Emacs 27 this no + ;; longer happens. This tries to fix it for 26 users, but it imposes + ;; another problem: the 2nd-to-last line will only be highlighted up to + ;; the (n-1)th character, but I think that is the lesser evil. (defun +doom--line-range-fn () - (let ((bol (line-beginning-position)) - (eol (line-end-position)) - (pmax (point-max))) - (cons bol - (cond ((and (= eol pmax) - (/= eol bol)) - (1- eol)) - ((or (eobp) - (= eol pmax)) - eol) - ((line-beginning-position 2)))))) + (if solaire-mode + (let ((bol (line-beginning-position)) + (eol (line-end-position)) + (eob (point-max))) + (cond ((or (= bol eob) + (= (1+ eol) eob)) + nil) + ((= eol eob) + (cons bol eol)) + ((eobp) + (cons bol eol)) + ((cons bol (line-beginning-position 2))))) + (cons (line-beginning-position) + (line-beginning-position 2)))) (setq hl-line-range-function #'+doom--line-range-fn) ;; HACK The fringe cannot have a buffer-local remapping on Emacs <= 26, so