From 28d0d4c2e9c72f821a33a55e06ff9c9f6686e00e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 10 Sep 2024 19:36:11 -0400 Subject: [PATCH] fix(indent-guides): bars on blank lines breaking line motions Ref: jdtsmith/indent-bars#22 --- modules/ui/indent-guides/config.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/ui/indent-guides/config.el b/modules/ui/indent-guides/config.el index 24c3c3733..6f086aca9 100644 --- a/modules/ui/indent-guides/config.el +++ b/modules/ui/indent-guides/config.el @@ -63,6 +63,23 @@ be enabled. If any function returns non-nil, the mode will not be activated." (defun +indent-guides-in-childframe-p () (frame-parameter nil 'parent-frame))) + ;; HACK: The way `indent-bars-display-on-blank-lines' functions, it places + ;; text properties with a display property containing a newline, which + ;; confuses `move-to-column'. This breaks `next-line' and `evil-next-line' + ;; without this advice (See jdtsmith/indent-bars#22). Advising + ;; `line-move-to-column' isn't enough for `move-to-column' calls in various + ;; Evil operators (`evil-delete', `evil-change', etc). + (defadvice! +indent-guides--prevent-passing-newline-a (fn col &rest args) + :around #'move-to-column + (if-let* ((indent-bars-mode) + (indent-bars-display-on-blank-lines) + (nlp (line-end-position)) + (dprop (get-text-property nlp 'display)) + ((seq-contains-p dprop ?\n)) + ((> col (- nlp (point))))) + (goto-char nlp) + (apply fn col args))) + ;; HACK: `indent-bars-mode' interactions with some packages poorly, often ;; flooding whole sections of the buffer with indent guides. This section is ;; dedicated to fixing interop with those packages.