(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 (_)
(declare-function mc/create-fake-cursor-at-point "ext:multiple-cursors-core")
(declare-function multiple-cursors-mode "ext:multiple-cursors-core")
-;;;###autoload
(defun swiper-mc ()
+ "Create a fake cursor for each `swiper' candidate."
(interactive)
(unless (require 'multiple-cursors nil t)
(error "multiple-cursors isn't installed"))
+ (unless (window-minibuffer-p)
+ (error "Call me only from `swiper'"))
(let ((cands (nreverse ivy--old-cands)))
(unless (string= ivy-text "")
(ivy-exit-with-action