branch: master
commit ce516073e5e4359b88f98610bae9b157945eb8e8
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
Allow to cancel "M-q" with "C-g"
swiper.el (swiper-query-replace): If the TO argument to
`perform-replace' isn't read, don't exit minibuffer.
If the user called `swiper-query-replace' and isn't happy with the
current input being the FROM arg of `perform-replace', it's possible to
cancel with "C-g", and edit the input once again.
---
swiper.el | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/swiper.el b/swiper.el
index a57004f..cb8e91b 100644
--- a/swiper.el
+++ b/swiper.el
@@ -83,16 +83,15 @@
(interactive)
(if (null (window-minibuffer-p))
(user-error "Should only be called in the minibuffer through
`swiper-map'")
- (delete-minibuffer-contents)
- (setq ivy--action
- (lambda ()
- (let ((from (ivy--regex ivy-text)))
- (perform-replace
- from
- (query-replace-read-to from "Query replace" t)
- t t t))))
- (swiper--cleanup)
- (exit-minibuffer)))
+ (let* ((from (ivy--regex ivy-text))
+ (to (query-replace-read-to from "Query replace" t)))
+ (delete-minibuffer-contents)
+ (setq ivy--action
+ (lambda ()
+ (perform-replace from to
+ t t t)))
+ (swiper--cleanup)
+ (exit-minibuffer))))
(defvar swiper--window nil
"Store the current window.")