branch: externals/pulsar
commit b852b1dc654cfd3abf567e2727372d4df6318490
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>

    Define a helper function to get the line boundaries
    
    We want to use our other helper functions instead of using
    line-beginning-position and line-end-position. Those are okay, but
    they are not exactly what we are looking for, as we also want to
    extend the highlight to the edge of the window. For the beginning
    position, we have to consider the context as, for example, in the
    minibuffer we want something else as the beginning than in a regular
    buffer.
    
    The pulsar--start and pulsar--end can probably be simplified as well.
    I will need to review them at some point.
---
 pulsar.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/pulsar.el b/pulsar.el
index 180bb0ae5b..24c5eac1c3 100644
--- a/pulsar.el
+++ b/pulsar.el
@@ -369,6 +369,11 @@ default completion setup)."
       (line-beginning-position 1)
     (line-beginning-position 2)))
 
+(defun pulsar--get-line-boundaries ()
+  "Return cons cell of line beginning and end positions.
+If possible, make the end be 1+ its value, so that the highlight can be
+extended to the edge of the window."
+  (cons (pulsar--start) (pulsar--end)))
 
 (defun pulsar--create-pulse (locus face)
   "Create a pulse spanning the LOCUS using FACE.
@@ -543,7 +548,7 @@ related."
    (list
     (if (region-active-p)
         (cons (region-beginning) (region-end))
-      (cons (line-beginning-position) (line-end-position)))))
+      (pulsar--get-line-boundaries))))
   (pcase-let* ((`(,beg . ,end) locus)
                (overlay (make-overlay beg end)))
     (overlay-put overlay 'face pulsar-highlight-face)
@@ -579,7 +584,7 @@ Set a permanent highlight with 
`pulsar-highlight-permanently'."
      ((region-active-p)
       (cons (region-beginning) (region-end)))
      (t
-      (cons (line-beginning-position) (line-end-position))))))
+      (pulsar--get-line-boundaries)))))
   (if-let* ((overlays (pulsar--permanent-p locus)))
       (dolist (overlay overlays) (delete-overlay overlay))
     (user-error "No Pulsar permanent highlights found")))
@@ -598,7 +603,7 @@ line."
      ((region-active-p)
       (cons (region-beginning) (region-end)))
      (t
-      (cons (line-beginning-position) (line-end-position))))))
+      (pulsar--get-line-boundaries)))))
   (if-let* ((overlays (pulsar--permanent-p locus)))
       (dolist (overlay overlays) (delete-overlay overlay))
     (pulsar-highlight-permanently locus)))

Reply via email to