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]
This commit is contained in:
Eric Danan 2017-08-15 12:53:04 +02:00
parent d55966f113
commit b9950f6f0b

View file

@ -208,6 +208,20 @@ BUFFER may be a string or nil."
;;; counsel-projectile-ag ;;; 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 ;;;###autoload
(defun counsel-projectile-ag (&optional options) (defun counsel-projectile-ag (&optional options)
"Ivy version of `projectile-ag'." "Ivy version of `projectile-ag'."
@ -229,7 +243,7 @@ BUFFER may be a string or nil."
(concat "--ignore " (shell-quote-argument i))) (concat "--ignore " (shell-quote-argument i)))
ignored ignored
" ")))) " "))))
(counsel-ag nil (counsel-ag (eval counsel-projectile-ag-initial-input)
(projectile-project-root) (projectile-project-root)
options options
(projectile-prepend-project-name "ag"))) (projectile-prepend-project-name "ag")))
@ -237,6 +251,9 @@ BUFFER may be a string or nil."
;;; counsel-projectile-rg ;;; 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 ;;;###autoload
(defun counsel-projectile-rg (&optional options) (defun counsel-projectile-rg (&optional options)
"Ivy version of `projectile-rg'." "Ivy version of `projectile-rg'."
@ -258,7 +275,7 @@ BUFFER may be a string or nil."
(concat "--glob " (shell-quote-argument (concat "!" i)))) (concat "--glob " (shell-quote-argument (concat "!" i))))
ignored ignored
" ")))) " "))))
(counsel-rg nil (counsel-rg (eval counsel-projectile-rg-initial-input)
(projectile-project-root) (projectile-project-root)
options options
(projectile-prepend-project-name "rg"))) (projectile-prepend-project-name "rg")))