emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master be716a1 08/12: swiper.el (swiper--add-overlays): Update ar


From: Oleh Krehel
Subject: [elpa] master be716a1 08/12: swiper.el (swiper--add-overlays): Update arglist
Date: Tue, 21 Apr 2015 12:09:22 +0000

branch: master
commit be716a1f2408fa0e58cf08c9e2612b098e6f0ab1
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    swiper.el (swiper--add-overlays): Update arglist
    
    * swiper.el (swiper--update-input-ivy): Update.
    (swiper--add-overlays): Take only the regexp as the argument.
    Figure out the bounds by itself.
---
 swiper.el |   83 ++++++++++++++++++++++++++++++-------------------------------
 1 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/swiper.el b/swiper.el
index 1afd056..b46702b 100644
--- a/swiper.el
+++ b/swiper.el
@@ -234,48 +234,47 @@ When non-nil, INITIAL-INPUT is the initial search 
pattern."
         (unless (and (>= (point) (window-start))
                      (<= (point) (window-end swiper--window t)))
           (recenter)))
-      (let ((ov (make-overlay
-                 (line-beginning-position)
-                 (1+ (line-end-position)))))
-        (overlay-put ov 'face 'swiper-line-face)
-        (overlay-put ov 'window swiper--window)
-        (push ov swiper--overlays))
-      (let ((wh (window-height)))
-        (swiper--add-overlays
-         re
-         (save-excursion
-           (forward-line (- wh))
-           (point))
-         (save-excursion
-           (forward-line wh)
-           (point)))))))
-
-(defun swiper--add-overlays (re beg end)
-  "Add overlays for RE regexp in current buffer between BEG and END."
-  (when (>= (length re) swiper-min-highlight)
-    (save-excursion
-      (goto-char beg)
-      ;; RE can become an invalid regexp
-      (while (and (ignore-errors (re-search-forward re end t))
-                  (> (- (match-end 0) (match-beginning 0)) 0))
-        (let ((i 0))
-          (while (<= i ivy--subexps)
-            (when (match-beginning i)
-              (let ((overlay (make-overlay (match-beginning i)
-                                           (match-end i)))
-                    (face
-                     (cond ((zerop ivy--subexps)
-                            (cl-caddr swiper-faces))
-                           ((zerop i)
-                            (car swiper-faces))
-                           (t
-                            (nth (1+ (mod (1- i) (1- (length swiper-faces))))
-                                 swiper-faces)))))
-                (push overlay swiper--overlays)
-                (overlay-put overlay 'face face)
-                (overlay-put overlay 'window swiper--window)
-                (overlay-put overlay 'priority i)))
-            (cl-incf i)))))))
+      (swiper--add-overlays re))))
+
+(defun swiper--add-overlays (re)
+  "Add overlays for RE regexp in visible part of the current buffer."
+  (let ((ov (make-overlay
+             (line-beginning-position)
+             (1+ (line-end-position)))))
+    (overlay-put ov 'face 'swiper-line-face)
+    (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))))
+    (when (>= (length re) swiper-min-highlight)
+      (save-excursion
+        (goto-char beg)
+        ;; RE can become an invalid regexp
+        (while (and (ignore-errors (re-search-forward re end t))
+                    (> (- (match-end 0) (match-beginning 0)) 0))
+          (let ((i 0))
+            (while (<= i ivy--subexps)
+              (when (match-beginning i)
+                (let ((overlay (make-overlay (match-beginning i)
+                                             (match-end i)))
+                      (face
+                       (cond ((zerop ivy--subexps)
+                              (cl-caddr swiper-faces))
+                             ((zerop i)
+                              (car swiper-faces))
+                             (t
+                              (nth (1+ (mod (1- i) (1- (length swiper-faces))))
+                                   swiper-faces)))))
+                  (push overlay swiper--overlays)
+                  (overlay-put overlay 'face face)
+                  (overlay-put overlay 'window swiper--window)
+                  (overlay-put overlay 'priority i)))
+              (cl-incf i))))))))
 
 (defun swiper--action (x input)
   "Goto line X and search for INPUT."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]