]> code.delx.au - gnu-emacs-elpa/commitdiff
counsel.el (counsel-pt): Add
authorjustbur <justin@burkett.cc>
Mon, 14 Mar 2016 14:37:03 +0000 (10:37 -0400)
committerjustbur <justin@burkett.cc>
Mon, 14 Mar 2016 14:40:39 +0000 (10:40 -0400)
counsel.el (counsel-pt-base-command): Used in place of
counsel-ag-base-command for counsel-pt.

counsel.el

index 81097b84056bd367ab37d561e421b2e6dc056f4f..39365975ec4650d07e7c8ff314e988f5705e6b82 100644 (file)
@@ -1295,9 +1295,12 @@ INITIAL-INPUT can be given as the initial minibuffer input."
   (interactive
    (list nil
          (when current-prefix-arg
-           (read-directory-name "ag in directory: "))))
+           (read-directory-name (concat
+                                 (car (split-string counsel-ag-base-command))
+                                 " in directory: ")))))
   (setq counsel--git-grep-dir (or initial-directory default-directory))
-  (ivy-read (funcall counsel-prompt-function "ag")
+  (ivy-read (funcall counsel-prompt-function
+                     (car (split-string counsel-ag-base-command)))
             'counsel-ag-function
             :initial-input initial-input
             :dynamic-collection t
@@ -1329,6 +1332,23 @@ INITIAL-INPUT can be given as the initial minibuffer input."
       (lambda (cand) (concat "./" cand))
       cands))))
 
+;;** `counsel-pt'
+(defcustom counsel-pt-base-command "pt --nocolor --nogroup %s -- ."
+  "Used to in place of `counsel-ag-base-command' to search with
+pt using `counsel-ag'."
+  :type 'string
+  :group 'ivy)
+
+;;;###autoload
+(defun counsel-pt (&optional initial-input initial-directory)
+  "Grep for a string in the current directory using pt.
+This uses `counsel-ag' with `counsel-pt-base-command' replacing
+`counsel-ag-base-command'. INITIAL-INPUT can be given as the
+initial minibuffer input."
+  (interactive)
+  (let ((counsel-ag-base-command counsel-pt-base-command))
+    (call-interactively 'counsel-ag)))
+
 ;;** `counsel-grep'
 (defun counsel-grep-function (string)
   "Grep in the current directory for STRING."