[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d7a1fda 143/348: swiper.el (swiper-all): "M-q" calls query
From: |
Oleh Krehel |
Subject: |
[elpa] master d7a1fda 143/348: swiper.el (swiper-all): "M-q" calls query-replace |
Date: |
Sat, 8 Apr 2017 11:03:44 -0400 (EDT) |
branch: master
commit d7a1fdadfaf2ff89ecdd3ea9195f04cb2f8b8c9e
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
swiper.el (swiper-all): "M-q" calls query-replace
* swiper.el (swiper-all-query-replace): New defun.
(swiper-all-map): New keymap.
(swiper-all): Update prompt, use `swiper-all-map'.
Fixes #623
---
swiper.el | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/swiper.el b/swiper.el
index 3a96907..ca84b26 100644
--- a/swiper.el
+++ b/swiper.el
@@ -114,6 +114,28 @@
(perform-replace from to
t t nil)))))))
+(defun swiper-all-query-replace ()
+ "Start `query-replace' with string to replace from last search string."
+ (interactive)
+ (if (null (window-minibuffer-p))
+ (user-error
+ "Should only be called in the minibuffer through `swiper-all-map'")
+ (let* ((enable-recursive-minibuffers t)
+ (from (ivy--regex ivy-text))
+ (to (query-replace-read-to from "Query replace" t)))
+ (swiper--cleanup)
+ (ivy-exit-with-action
+ (lambda (_)
+ (let ((wnd-conf (current-window-configuration))
+ (inhibit-message t))
+ (unwind-protect
+ (dolist (cand ivy--old-cands)
+ (let ((buffer (get-text-property 0 'buffer cand)))
+ (switch-to-buffer buffer)
+ (goto-char (point-min))
+ (perform-replace from to t t nil)))
+ (set-window-configuration wnd-conf))))))))
+
(defvar avy-background)
(defvar avy-all-windows)
(defvar avy-style)
@@ -640,7 +662,6 @@ WND, when specified is the window."
re
regexp-search-ring-max)))))
-;; (define-key isearch-mode-map (kbd "C-o") 'swiper-from-isearch)
(defun swiper-from-isearch ()
"Invoke `swiper' from isearch."
(interactive)
@@ -779,16 +800,23 @@ Run `swiper' for those buffers."
cands
"\n")))
+(defvar swiper-all-map
+ (let ((map (make-sparse-keymap)))
+ (define-key map (kbd "M-q") 'swiper-all-query-replace)
+ map)
+ "Keymap for `swiper-all'.")
+
(defun swiper-all ()
"Run `swiper' for all opened buffers."
(interactive)
(let ((ivy-format-function #'swiper--all-format-function))
- (ivy-read "Swiper: " 'swiper-all-function
+ (ivy-read "swiper-all: " 'swiper-all-function
:action 'swiper-all-action
:unwind #'swiper--cleanup
:update-fn (lambda ()
(swiper-all-action ivy--current))
:dynamic-collection t
+ :keymap swiper-all-map
:caller 'swiper-multi)))
(defun swiper-all-action (x)
- [elpa] master 482c3e9 279/348: counsel.el (counsel-ace-link): Use `cdr' for action., (continued)
- [elpa] master 482c3e9 279/348: counsel.el (counsel-ace-link): Use `cdr' for action., Oleh Krehel, 2017/04/08
- [elpa] master e4c248a 278/348: doc/ivy.org: Update package names in ELPA/MELPA, Oleh Krehel, 2017/04/08
- [elpa] master 6e6738c 294/348: counsel.el (counsel-git-grep-cmd-default): Use '%s' quoting, Oleh Krehel, 2017/04/08
- [elpa] master d4e5d79 290/348: counsel.el (counsel-package): Fix sorting issue, Oleh Krehel, 2017/04/08
- [elpa] master 15f89f7 295/348: ivy.el (ivy-minibuffer-map): Bind "C-v" and scroll-up-command, Oleh Krehel, 2017/04/08
- [elpa] master ab6561f 321/348: ivy.el: Use set-ivy-index instead of setq ivy--index, Oleh Krehel, 2017/04/08
- [elpa] master 45383fe 330/348: ivy-overlay.el (ivy-display-function-overlay): Put overlay at symbol start, Oleh Krehel, 2017/04/08
- [elpa] master 1d32ceb 332/348: counsel.el (counsel-irony): New command, Oleh Krehel, 2017/04/08
- [elpa] master ace01d5 347/348: ivy.el (ivy-immediate-done): Fix for rgrep, Oleh Krehel, 2017/04/08
- [elpa] master 2f5bfc0 144/348: counsel.el (counsel-dpkg): New command, Oleh Krehel, 2017/04/08
- [elpa] master d7a1fda 143/348: swiper.el (swiper-all): "M-q" calls query-replace,
Oleh Krehel <=
- [elpa] master 5a4ede4 130/348: Fix swiper-all for ivy--regex-ignore-order, Oleh Krehel, 2017/04/08
- [elpa] master 5787780 137/348: Makefile (plain): Print version, Oleh Krehel, 2017/04/08
- [elpa] master 72784c1 149/348: counsel.el (counsel-imenu): Force rescan if requested, Oleh Krehel, 2017/04/08
- [elpa] master 01b0195 306/348: Correct Circe major-modes in ...-font-lock-exclude, Oleh Krehel, 2017/04/08
- [elpa] master 94a466f 341/348: ivy.el: Clean up whitespace, Oleh Krehel, 2017/04/08
- [elpa] master 1220781 131/348: counsel.el (counsel-find-file): Speed up opening remotes, Oleh Krehel, 2017/04/08
- [elpa] master 63dd0d3 134/348: counsel.el (counsel-git-grep-proj-function): Use greedy regex, Oleh Krehel, 2017/04/08
- [elpa] master d41212e 172/348: ivy.el (ivy--insert-minibuffer): Handle empty string, Oleh Krehel, 2017/04/08
- [elpa] master 8632f33 175/348: counsel.el: Update description comment., Oleh Krehel, 2017/04/08
- [elpa] master 89a6830 186/348: counsel.el (counsel-at-git-issue-p): Fix for newer magit, Oleh Krehel, 2017/04/08