]> code.delx.au - gnu-emacs-elpa/blobdiff - swiper.el
Fix remapping commit c9b6e0
[gnu-emacs-elpa] / swiper.el
index b52d0fe8481c61dd56f48d6dfede44a227e84282..b6b4c84d3e6fe8556e4c97ffbab557f622df5fb1 100644 (file)
--- a/swiper.el
+++ b/swiper.el
       (user-error "Should only be called in the minibuffer through `swiper-map'")
     (let* ((enable-recursive-minibuffers t)
            (from (ivy--regex ivy-text))
-           (to (query-replace-read-to from "Query replace" t)))
+           (to (minibuffer-with-setup-hook
+                   (lambda ()
+                     (setq minibuffer-default
+                           (if (string-match "\\`\\\\_<\\(.*\\)\\\\_>\\'" ivy-text)
+                               (match-string 1 ivy-text)
+                             ivy-text)))
+                 (read-from-minibuffer (format "Query replace %s with: " from)))))
       (swiper--cleanup)
       (ivy-exit-with-action
        (lambda (_)
@@ -294,8 +300,7 @@ numbers; replaces calculating the width from buffer line count."
                            (buffer-substring
                             (point)
                             (line-end-position)))))))
-              (when (eq major-mode 'twittering-mode)
-                (remove-text-properties 0 (length str) '(field) str))
+              (remove-text-properties 0 (length str) '(field) str)
               (put-text-property 0 1 'display
                                  (format swiper--format-spec
                                          (cl-incf line-number))
@@ -317,7 +322,8 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
 (declare-function string-trim-right "subr-x")
 
 (defun swiper-occur (&optional revert)
-  "Generate a custom occur buffer for `swiper'."
+  "Generate a custom occur buffer for `swiper'.
+When REVERT is non-nil, regenerate the current *ivy-occur* buffer."
   (let* ((buffer (ivy-state-buffer ivy-last))
          (fname (propertize
                  (with-ivy-window
@@ -339,11 +345,12 @@ When non-nil, INITIAL-INPUT is the initial search pattern."
                  (if (null revert)
                      ivy--old-cands
                    (setq ivy--old-re nil)
-                   (ivy--filter
-                    (progn (string-match "\"\\(.*\\)\"" (buffer-name))
-                           (match-string 1 (buffer-name)))
-                    (with-current-buffer buffer
-                      (swiper--candidates)))))))
+                   (let ((ivy--regex-function 'swiper--re-builder))
+                     (ivy--filter
+                      (progn (string-match "\"\\(.*\\)\"" (buffer-name))
+                             (match-string 1 (buffer-name)))
+                      (with-current-buffer buffer
+                        (swiper--candidates))))))))
     (unless (eq major-mode 'ivy-occur-grep-mode)
       (ivy-occur-grep-mode)
       (font-lock-mode -1))