[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 725e19a 170/272: counsel.el (counsel-ag-occur): Add
From: |
Oleh Krehel |
Subject: |
[elpa] master 725e19a 170/272: counsel.el (counsel-ag-occur): Add |
Date: |
Mon, 25 Apr 2016 10:13:23 +0000 |
branch: master
commit 725e19ae80c4fa35fdcec3e22588bf3e95ddafc6
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-ag-occur): Add
Re #423
---
counsel.el | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/counsel.el b/counsel.el
index 53da889..2c0c480 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1229,6 +1229,7 @@ command. %S will be replaced by the regex string. The
default is
:group 'ivy)
(counsel-set-async-exit-code 'counsel-ag 1 "No matches found")
+(ivy-set-occur 'counsel-ag 'counsel-ag-occur)
(defun counsel-ag-function (string)
"Grep in the current directory for STRING."
@@ -1258,6 +1259,27 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
(swiper--cleanup))
:caller 'counsel-ag))
+(defun counsel-ag-occur ()
+ "Generate a custom occur buffer for `counsel-ag'."
+ (ivy-occur-grep-mode)
+ (setq default-directory counsel--git-grep-dir)
+ (let* ((regex (counsel-unquote-regex-parens
+ (setq ivy--old-re
+ (ivy--regex ivy-text))))
+ (cands (split-string
+ (shell-command-to-string
+ (format counsel-ag-base-command (shell-quote-argument
regex)))
+ "\n"
+ t)))
+ ;; Need precise number of header lines for `wgrep' to work.
+ (insert (format "-*- mode:grep; default-directory: %S -*-\n\n\n"
+ default-directory))
+ (insert (format "%d candidates:\n" (length cands)))
+ (ivy--occur-insert-lines
+ (mapcar
+ (lambda (cand) (concat "./" cand))
+ cands))))
+
;;** `counsel-grep'
(defun counsel-grep-function (string)
"Grep in the current directory for STRING."
- [elpa] master 9aa1f5c 156/272: counsel.el (counsel-mode-map): Add counsel-M-x, (continued)
- [elpa] master 9aa1f5c 156/272: counsel.el (counsel-mode-map): Add counsel-M-x, Oleh Krehel, 2016/04/25
- [elpa] master 6757030 225/272: counsel-grep now works with ivy-occur-revert-buffer, Oleh Krehel, 2016/04/25
- [elpa] master 6026caf 174/272: counsel.el (counsel-locate-cmd-es): Add, Oleh Krehel, 2016/04/25
- [elpa] master 7ed5b06 119/272: ivy.el (ivy--preselect-index): Don't use regexp-quote, Oleh Krehel, 2016/04/25
- [elpa] master dcf4957 123/272: counsel.el (counsel--async-command): Add sentinel and filter args, Oleh Krehel, 2016/04/25
- [elpa] master 53ca6ed 065/272: ivy.el (ivy-do-completion-in-region): New defcustom, Oleh Krehel, 2016/04/25
- [elpa] master ca2b47f 240/272: Add timing information to async commands, Oleh Krehel, 2016/04/25
- [elpa] master d544427 093/272: swiper.el (swiper--re-builder): Replace \t with 4 spaces, Oleh Krehel, 2016/04/25
- [elpa] master 1f3ea7d 095/272: ivy.el (ivy-next-history-element): Handle "M-n M-n" better, Oleh Krehel, 2016/04/25
- [elpa] master ab3ad4e 085/272: doc/ivy.org: Add more CUSTOM_ID, Oleh Krehel, 2016/04/25
- [elpa] master 725e19a 170/272: counsel.el (counsel-ag-occur): Add,
Oleh Krehel <=
- [elpa] master ccbf9ef 204/272: Improve counsel-async initial anchoring, Oleh Krehel, 2016/04/25
- [elpa] master 2fb8d86 260/272: ivy.el (ivy-done): Allow ivy-dispatching-done to exit with no cands, Oleh Krehel, 2016/04/25
- [elpa] master 1c68495 145/272: ivy.el (ivy-expand-file-if-directory): New defun, Oleh Krehel, 2016/04/25
- [elpa] master d4fc54b 110/272: ivy-test.el (counsel-unquote-regex-parens): Add test, Oleh Krehel, 2016/04/25
- [elpa] master 5f0d175 172/272: counsel.el (counsel-prompt-function-dir): Make portable, Oleh Krehel, 2016/04/25
- [elpa] master 5765208 185/272: counsel.el (counsel-pt-base-command): Add regex flag, Oleh Krehel, 2016/04/25
- [elpa] master 67ac850 211/272: counsel.el (counsel-M-x): Add help action, Oleh Krehel, 2016/04/25
- [elpa] master 189c093 207/272: counsel.el (counsel-ace-link): New command, Oleh Krehel, 2016/04/25
- [elpa] master 8c2f213 059/272: counsel.el (counsel-yank-pop): Truncate during display, Oleh Krehel, 2016/04/25
- [elpa] master 5c2c1df 166/272: counsel.el (counsel-git-grep-map): Bind "C-c C-m" to counsel-git-grep-switch-cmd, Oleh Krehel, 2016/04/25