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

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

[elpa] master f4bd3a4 055/167: counsel.el (counsel-ag): Add initial-dire


From: Oleh Krehel
Subject: [elpa] master f4bd3a4 055/167: counsel.el (counsel-ag): Add initial-directory
Date: Tue, 08 Dec 2015 10:49:52 +0000

branch: master
commit f4bd3a49bd009fe2e20bc2cfc83616bc9168a64b
Author: Jon Miller <address@hidden>
Commit: Jon Miller <address@hidden>

    counsel.el (counsel-ag): Add initial-directory
    
    Support alternative initial directory which helps other packages call
    this function with their unique starting directory.
---
 counsel.el |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/counsel.el b/counsel.el
index 5d5263b..25f1f44 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1040,18 +1040,19 @@ Usable with `ivy-resume', `ivy-next-line-and-call' and
   "Grep in the current directory for STRING."
   (if (< (length string) 3)
       (counsel-more-chars 3)
-    (let ((regex (counsel-unquote-regex-parens
+    (let ((default-directory counsel--git-grep-dir)
+          (regex (counsel-unquote-regex-parens
                   (setq ivy--old-re
                         (ivy--regex string)))))
       (counsel--async-command
        (format "ag --noheading --nocolor %S" regex))
       nil)))
 
-(defun counsel-ag (&optional initial-input)
+(defun counsel-ag (&optional initial-input initial-directory)
   "Grep for a string in the current directory using ag.
 INITIAL-INPUT can be given as the initial minibuffer input."
   (interactive)
-  (setq counsel--git-grep-dir default-directory)
+  (setq counsel--git-grep-dir (or initial-directory default-directory))
   (ivy-read "ag: " 'counsel-ag-function
             :initial-input initial-input
             :dynamic-collection t



reply via email to

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