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

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

[elpa] externals/ivy-hydra 1020a77 026/395: swiper.el (swiper-query-repl


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra 1020a77 026/395: swiper.el (swiper-query-replace): Show matched groups in preview
Date: Thu, 25 Feb 2021 08:31:23 -0500 (EST)

branch: externals/ivy-hydra
commit 1020a777c59c6e0208b19940d94e12faba06a280
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Oleh Krehel <ohwoeowho@gmail.com>

    swiper.el (swiper-query-replace): Show matched groups in preview
    
    Only works when there are no spaces in the search string.
    
    Fixes #2289
---
 swiper.el | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/swiper.el b/swiper.el
index 19d1073..3ef52dc 100644
--- a/swiper.el
+++ b/swiper.el
@@ -158,7 +158,11 @@ Treated as non-nil when searching backwards."
        (propertize
         (if (stringp lisp)
             lisp
-          ivy-text)
+          (set-match-data (overlay-get ov 'md))
+          (condition-case nil
+              (with-current-buffer (nth 4 (overlay-get ov 'md))
+                (match-substitute-replacement ivy-text))
+            (error ivy-text)))
         'face 'error)))))
 
 (defun swiper--query-replace-cleanup ()
@@ -174,13 +178,14 @@ Treated as non-nil when searching backwards."
         (while (and (re-search-forward re end t)
                     (not (eobp)))
           (let ((ov (make-overlay (1- (match-end 0)) (match-end 0)))
-                (md (match-data)))
+                (md (match-data t)))
             (overlay-put
              ov 'matches
              (mapcar
               (lambda (x)
                 (list `(match-string ,x) (match-string x)))
               (number-sequence 0 (1- (/ (length md) 2)))))
+            (overlay-put ov 'md md)
             (push ov swiper--query-replace-overlays))
           (unless (> (match-end 0) (match-beginning 0))
             (forward-char)))))))



reply via email to

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