[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 70f6055 077/167: counsel.el (counsel-git-grep-query-replac
From: |
Oleh Krehel |
Subject: |
[elpa] master 70f6055 077/167: counsel.el (counsel-git-grep-query-replace): Add and bind to "M-q" |
Date: |
Tue, 08 Dec 2015 10:50:00 +0000 |
branch: master
commit 70f60554c634c05e449f1f29051fd14329313812
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-git-grep-query-replace): Add and bind to "M-q"
* counsel.el (counsel-git-grep-map): Bind "M-q" to
`counsel-git-grep-query-replace'.
(counsel-git-grep-query-replace): New command. Perform `query-replace'
on all matches of git-grep in all buffers.
---
counsel.el | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/counsel.el b/counsel.el
index eab1a3c..3694aa6 100644
--- a/counsel.el
+++ b/counsel.el
@@ -375,8 +375,33 @@
(defvar counsel-git-grep-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-l") 'counsel-git-grep-recenter)
+ (define-key map (kbd "M-q") 'counsel-git-grep-query-replace)
map))
+(defun counsel-git-grep-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
`counsel-git-grep-map'")
+ (let* ((enable-recursive-minibuffers t)
+ (from (ivy--regex ivy-text))
+ (to (query-replace-read-to from "Query replace" t)))
+ (let (done-buffers)
+ (dolist (cand ivy--old-cands)
+ (when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" cand)
+ (with-ivy-window
+ (let ((file-name (match-string-no-properties 1 cand)))
+ (setq file-name (expand-file-name file-name
counsel--git-grep-dir))
+ (unless (member file-name done-buffers)
+ (push file-name done-buffers)
+ (find-file file-name)
+ (goto-char (point-min)))
+ (perform-replace from to t t nil))))))
+ (delete-minibuffer-contents)
+ (swiper--cleanup)
+ (exit-minibuffer))))
+
(defun counsel-git-grep-recenter ()
(interactive)
(with-ivy-window
- [elpa] master 71695df 065/167: "C-j" should not stop completion for a pasted file path, (continued)
- [elpa] master 71695df 065/167: "C-j" should not stop completion for a pasted file path, Oleh Krehel, 2015/12/08
- [elpa] master dfd6204 064/167: Fix pasting file paths on Windows, Oleh Krehel, 2015/12/08
- [elpa] master 1af25f6 067/167: swiper.el (swiper-font-lock-ensure): Amend exception list, Oleh Krehel, 2015/12/08
- [elpa] master 5f22310 069/167: counsel.el (counsel-git): Update default-directory, Oleh Krehel, 2015/12/08
- [elpa] master 4a04d6e 031/167: Default ivy-display-style to 'fancy for Emacs>=24.5, Oleh Krehel, 2015/12/08
- [elpa] master 3ae4f1a 052/167: ivy-test.el (swiper--re-builder): Update, Oleh Krehel, 2015/12/08
- [elpa] master 713fd6d 049/167: Try to fix the previous commit, Oleh Krehel, 2015/12/08
- [elpa] master 297f48a 074/167: ivy.el: "M-n" should prefer url at point to symbol at point, Oleh Krehel, 2015/12/08
- [elpa] master 0e6c13b 076/167: swiper.el (swiper-font-lock-ensure): Exclude eems-stream-mode, Oleh Krehel, 2015/12/08
- [elpa] master f5b8bf2 079/167: Highlight modified file buffers with 'ivy-modified-buffer face, Oleh Krehel, 2015/12/08
- [elpa] master 70f6055 077/167: counsel.el (counsel-git-grep-query-replace): Add and bind to "M-q",
Oleh Krehel <=
- [elpa] master 86d0884 087/167: fix 1-too-far scrolling issue, Oleh Krehel, 2015/12/08
- [elpa] master 16ccb0f 084/167: swiper.el (swiper-font-lock-ensure): Exclude debbugs-gnu-mode, Oleh Krehel, 2015/12/08
- [elpa] master d41cc69 086/167: Pulse after ivy-occur-press, Oleh Krehel, 2015/12/08
- [elpa] master c6cc3f9 089/167: counsel.el (counsel-rhythmbox): Add :caller, Oleh Krehel, 2015/12/08
- [elpa] master 2f1133a 083/167: ivy.el (ivy-occur): Add and bind to "C-c o", Oleh Krehel, 2015/12/08
- [elpa] master 2797a9b 090/167: ivy.el (ivy-minibuffer-map): Bind "C-M-a" to ivy-read-action, Oleh Krehel, 2015/12/08
- [elpa] master 564e235 091/167: ivy.el (ivy-occur-press): Extend with-ivy-window, Oleh Krehel, 2015/12/08
- [elpa] master e9ba89e 085/167: Make ivy work with enable-recursive-minibuffers, Oleh Krehel, 2015/12/08
- [elpa] master 7a069be 088/167: ivy.el (ivy-occur-press): Work with counsel-rhythmbox, Oleh Krehel, 2015/12/08
- [elpa] master 32025e5 098/167: Add a better ivy-occur pulse to swiper and counsel-git-grep, Oleh Krehel, 2015/12/08