From b9950f6f0b226e6e29deea3a32b5c6e4cdd80fd9 Mon Sep 17 00:00:00 2001 From: Eric Danan Date: Tue, 15 Aug 2017 12:53:04 +0200 Subject: [PATCH] allow initial input in cp-ag and cp-rg * counsel-projectile.el: (counsel-projectile-ag-initial-input): new variable (counsel-projectile-ag): use the above var (counsel-projectile-rg-initial-input): new variable (counsel-projectile-rg): use the above var [Closes #43] --- counsel-projectile.el | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/counsel-projectile.el b/counsel-projectile.el index f827136..2ba8017 100644 --- a/counsel-projectile.el +++ b/counsel-projectile.el @@ -208,6 +208,20 @@ BUFFER may be a string or nil." ;;; counsel-projectile-ag +(defvar counsel-projectile-ag-initial-input nil + "Initial minibuffer input for `counsel-projectile-ag'. If non-nil, it should be a form whose evaluation yields the initial input string, e.g. + + (setq counsel-projectile-ag-initial-input + '(projectile-symbol-or-selection-at-point)) + +or + + (setq counsel-projectile-ag-initial-input + '(thing-at-point 'symbol t)) + +Note that you can always insert the value of `(ivy-thing-at-point)' by +hitting \"M-n\" in the minibuffer.") + ;;;###autoload (defun counsel-projectile-ag (&optional options) "Ivy version of `projectile-ag'." @@ -229,7 +243,7 @@ BUFFER may be a string or nil." (concat "--ignore " (shell-quote-argument i))) ignored " ")))) - (counsel-ag nil + (counsel-ag (eval counsel-projectile-ag-initial-input) (projectile-project-root) options (projectile-prepend-project-name "ag"))) @@ -237,6 +251,9 @@ BUFFER may be a string or nil." ;;; counsel-projectile-rg +(defvar counsel-projectile-rg-initial-input nil + "Initial minibuffer input for `counsel-projectile-rg'. See `counsel-projectile-ag-initial-input' for details.") + ;;;###autoload (defun counsel-projectile-rg (&optional options) "Ivy version of `projectile-rg'." @@ -258,7 +275,7 @@ BUFFER may be a string or nil." (concat "--glob " (shell-quote-argument (concat "!" i)))) ignored " ")))) - (counsel-rg nil + (counsel-rg (eval counsel-projectile-rg-initial-input) (projectile-project-root) options (projectile-prepend-project-name "rg")))