]> code.delx.au - gnu-emacs-elpa/commitdiff
swiper.el (swiper--add-overlays): Make bounds optional
authorOleh Krehel <ohwoeowho@gmail.com>
Tue, 21 Apr 2015 13:09:23 +0000 (15:09 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Tue, 21 Apr 2015 13:09:23 +0000 (15:09 +0200)
swiper.el

index b46702bf5c6c503008cde56959b3177cb94f096d..f123c7327d0352b3a3e55fa56fb85e2ff40e8477 100644 (file)
--- a/swiper.el
+++ b/swiper.el
@@ -236,8 +236,9 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
           (recenter)))
       (swiper--add-overlays re))))
 
-(defun swiper--add-overlays (re)
-  "Add overlays for RE regexp in visible part of the current buffer."
+(defun swiper--add-overlays (re &optional beg end)
+  "Add overlays for RE regexp in visible part of the current buffer.
+BEG and END, when specified, are the point bounds."
   (let ((ov (make-overlay
              (line-beginning-position)
              (1+ (line-end-position)))))
@@ -245,12 +246,12 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
     (overlay-put ov 'window swiper--window)
     (push ov swiper--overlays))
   (let* ((wh (window-height))
-         (beg (save-excursion
-                (forward-line (- wh))
-                (point)))
-         (end (save-excursion
-                (forward-line wh)
-                (point))))
+         (beg (or beg (save-excursion
+                        (forward-line (- wh))
+                        (point))))
+         (end (or end (save-excursion
+                        (forward-line wh)
+                        (point)))))
     (when (>= (length re) swiper-min-highlight)
       (save-excursion
         (goto-char beg)