emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 5c2c1df 166/272: counsel.el (counsel-git-grep-map): Bind "


From: Oleh Krehel
Subject: [elpa] master 5c2c1df 166/272: counsel.el (counsel-git-grep-map): Bind "C-c C-m" to counsel-git-grep-switch-cmd
Date: Mon, 25 Apr 2016 10:13:23 +0000

branch: master
commit 5c2c1df8cbd3f73e328086ded4bb684940aa6f32
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-git-grep-map): Bind "C-c C-m" to 
counsel-git-grep-switch-cmd
    
    * counsel.el (counsel-git-grep-switch-cmd): New command.
    
    The initial command always runs on all files.
    
    To run only on *.el files, "C-c C-m" followed by "M-i" -- *.el.
    To run on *.c and *.h files, "C-c C-m" followed by "M-i" -- *.c *.h.
    To switch to all files again, "C-c C-m" and select the appropriate
    entry.
    
    Re #420
---
 counsel.el |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/counsel.el b/counsel.el
index f1ede40..2c6c54c 100644
--- a/counsel.el
+++ b/counsel.el
@@ -683,6 +683,7 @@ Describe the selected candidate."
   (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)
+    (define-key map (kbd "C-c C-m") 'counsel-git-grep-switch-cmd)
     map))
 
 (ivy-set-occur 'counsel-git-grep 'counsel-git-grep-occur)
@@ -800,6 +801,18 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
               :history 'counsel-git-grep-history
               :caller 'counsel-git-grep)))
 
+(defun counsel-git-grep-switch-cmd ()
+  "Set `counsel-git-grep-cmd' to a different value."
+  (interactive)
+  (setq counsel-git-grep-cmd
+        (ivy-read "cmd: " counsel-git-grep-cmd-history
+                  :history 'counsel-git-grep-cmd-history))
+  (setq counsel-git-grep-cmd-history
+        (delete-dups counsel-git-grep-cmd-history))
+  (unless (ivy-state-dynamic-collection ivy-last)
+    (setq ivy--all-candidates
+          (all-completions "" 'counsel-git-grep-function))))
+
 (defvar counsel-gg-state nil
   "The current state of candidates / count sync.")
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]