[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e38b23c 091/348: Make counsel-ag extensible
From: |
Oleh Krehel |
Subject: |
[elpa] master e38b23c 091/348: Make counsel-ag extensible |
Date: |
Sat, 8 Apr 2017 11:03:34 -0400 (EDT) |
branch: master
commit e38b23c83db53cb6d83e66137ec4b382a38e61bb
Author: Kaushal Modi <address@hidden>
Commit: Kaushal Modi <address@hidden>
Make counsel-ag extensible
---
counsel.el | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/counsel.el b/counsel.el
index e48a94a..04270dd 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1428,10 +1428,10 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
(define-key map (kbd "M-q") 'counsel-git-grep-query-replace)
map))
-(defcustom counsel-ag-base-command "ag --nocolor --nogroup %s -- ."
- "Format string to use in `cousel-ag-function' to construct the
-command. %S will be replaced by the regex string. The default is
-\"ag --nocolor --nogroup %s -- .\"."
+(defcustom counsel-ag-base-command "ag --nocolor --nogroup %s"
+ "Format string to use in `counsel-ag-function' to construct the
+command. The %s will be replaced by optional extra ag arguments followed by the
+regex string. The default is \"ag --nocolor --nogroup %s\"."
:type 'string
:group 'ivy)
@@ -1439,22 +1439,31 @@ command. %S will be replaced by the regex string. The
default is
(ivy-set-occur 'counsel-ag 'counsel-ag-occur)
(ivy-set-display-transformer 'counsel-ag 'counsel-git-grep-transformer)
-(defun counsel-ag-function (string)
- "Grep in the current directory for STRING."
+(defun counsel-ag-function (string extra-ag-args)
+ "Grep in the current directory for STRING.
+If non-nil, EXTRA-AG-ARGS string is appended to `counsel-ag-base-command'."
+ (when (null extra-ag-args)
+ (setq extra-ag-args ""))
(if (< (length string) 3)
(counsel-more-chars 3)
(let ((default-directory counsel--git-grep-dir)
(regex (counsel-unquote-regex-parens
(setq ivy--old-re
(ivy--regex string)))))
- (counsel--async-command
- (format counsel-ag-base-command (shell-quote-argument regex)))
+ (let ((ag-cmd (format counsel-ag-base-command
+ (concat extra-ag-args
+ " -- "
+ (shell-quote-argument regex)))))
+ (counsel--async-command ag-cmd))
nil)))
;;;###autoload
-(defun counsel-ag (&optional initial-input initial-directory)
+(defun counsel-ag (&optional initial-input initial-directory extra-ag-args
ag-prompt)
"Grep for a string in the current directory using ag.
-INITIAL-INPUT can be given as the initial minibuffer input."
+INITIAL-INPUT can be given as the initial minibuffer input.
+INITIAL-DIRECTORY, if non-nil, is used as the root directory for search.
+EXTRA-AG-ARGS string, if non-nil, is appended to `counsel-ag-base-command'.
+AG-PROMPT, if non-nil, is passed as `ivy-read' prompt argument. "
(interactive
(list nil
(when current-prefix-arg
@@ -1463,8 +1472,9 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
" in directory: ")))))
(ivy-set-prompt 'counsel-ag counsel-prompt-function)
(setq counsel--git-grep-dir (or initial-directory default-directory))
- (ivy-read (car (split-string counsel-ag-base-command))
- 'counsel-ag-function
+ (ivy-read (or ag-prompt (car (split-string counsel-ag-base-command)))
+ (lambda (string)
+ (counsel-ag-function string extra-ag-args))
:initial-input initial-input
:dynamic-collection t
:keymap counsel-ag-map
- [elpa] master 7280e19 050/348: ivy.el (ivy-completion-common-length): Fix double insert bug, (continued)
- [elpa] master 7280e19 050/348: ivy.el (ivy-completion-common-length): Fix double insert bug, Oleh Krehel, 2017/04/08
- [elpa] master 288723e 065/348: counsel.el (counsel-set-variable): Allow new symbols, Oleh Krehel, 2017/04/08
- [elpa] master fe32959 066/348: ivy.el (ivy--actionp): Fix lambda being considered a list of actions, Oleh Krehel, 2017/04/08
- [elpa] master b3cca57 057/348: Make ivy prompt face overriding modular, Oleh Krehel, 2017/04/08
- [elpa] master 6067454 068/348: Improve readability of imenu candidates, Oleh Krehel, 2017/04/08
- [elpa] master a300514 071/348: counsel.el (hydra-keyboard-quit): Declare function, Oleh Krehel, 2017/04/08
- [elpa] master e54aa18 067/348: Add prefix arg for action functions, Oleh Krehel, 2017/04/08
- [elpa] master 2ee5618 085/348: ivy.el: Add face customizations to ivy-switch-buffer, Oleh Krehel, 2017/04/08
- [elpa] master fe93cc6 084/348: counsel.el (counsel-M-x): Fix interaction with repeat, Oleh Krehel, 2017/04/08
- [elpa] master aaad354 088/348: counsel.el (counsel-find-file): Switch directory with "M-o b", Oleh Krehel, 2017/04/08
- [elpa] master e38b23c 091/348: Make counsel-ag extensible,
Oleh Krehel <=
- [elpa] master 4dbd8c3 090/348: counsel.el (counsel-semantic): Fix let paren, Oleh Krehel, 2017/04/08
- [elpa] master 2e3cd39 099/348: Support custom command for counsel-git, Oleh Krehel, 2017/04/08
- [elpa] master 94e22bf 096/348: counsel.el (counsel-describe-face): New command, Oleh Krehel, 2017/04/08
- [elpa] master a627164 092/348: Mention that ivy-format-function is the variable described, Oleh Krehel, 2017/04/08
- [elpa] master 0d77775 103/348: README.md: Add a FAQ section, Oleh Krehel, 2017/04/08
- [elpa] master 17b59b2 105/348: Documenting how to generate texinfo, Oleh Krehel, 2017/04/08
- [elpa] master ed61b04 016/348: Fix problems introduced by "(ivy--filter): Recompute index after sort", Oleh Krehel, 2017/04/08
- [elpa] master d3c8028 023/348: ivy.el (ivy--sorted-files): Add a safety work-around, Oleh Krehel, 2017/04/08
- [elpa] master 4a2f0d4 026/348: Remove needless code, Oleh Krehel, 2017/04/08
- [elpa] master 12145d7 030/348: ivy.el (ivy-completion-in-region-action): Remove string props, Oleh Krehel, 2017/04/08