[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b39f383 125/184: counsel.el (counsel-git-grep-occur): Re-u
From: |
Oleh Krehel |
Subject: |
[elpa] master b39f383 125/184: counsel.el (counsel-git-grep-occur): Re-use counsel-grep-like-occur |
Date: |
Wed, 16 Oct 2019 13:15:04 -0400 (EDT) |
branch: master
commit b39f3832c0fb8f6a9016e272d8ea96ebaa73d9f5
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-git-grep-occur): Re-use counsel-grep-like-occur
---
counsel.el | 43 +++++++++++++++++--------------------------
1 file changed, 17 insertions(+), 26 deletions(-)
diff --git a/counsel.el b/counsel.el
index 2b6e471..b313d86 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1541,16 +1541,8 @@ When CMD is non-nil, prompt for a specific \"git grep\"
command."
(setq str (replace-match "" t t str 1))))
str)
-(defun counsel-git-grep-occur ()
- "Generate a custom occur buffer for `counsel-git-grep'.
-When REVERT is non-nil, regenerate the current *ivy-occur* buffer."
- (unless (eq major-mode 'ivy-occur-grep-mode)
- (ivy-occur-grep-mode)
- (setq default-directory (ivy-state-directory ivy-last)))
- (setq ivy-text
- (and (string-match "\"\\(.*\\)\"" (buffer-name))
- (match-string 1 (buffer-name))))
- (let* ((regex (funcall ivy--regex-function ivy-text))
+(defun counsel--git-grep-occur-cmd (input)
+ (let* ((regex (funcall ivy--regex-function input))
(positive-pattern (replace-regexp-in-string
;; git-grep can't handle .*?
"\\.\\*\\?" ".*"
@@ -1561,16 +1553,12 @@ When REVERT is non-nil, regenerate the current
*ivy-occur* buffer."
(and (null (cdr x))
(format "| grep -v %s" (car x))))
regex
- " ")))
- (cmd (concat (format counsel-git-grep-cmd positive-pattern)
negative-patterns))
- cands)
- (setq cands (counsel--split-string (shell-command-to-string cmd)))
- ;; 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 #'counsel--normalize-grep-match cands))))
+ " "))))
+ (concat (format counsel-git-grep-cmd positive-pattern) negative-patterns)))
+
+(defun counsel-git-grep-occur ()
+ "Generate a custom occur buffer for `counsel-git-grep'."
+ (counsel-grep-like-occur #'counsel--git-grep-occur-cmd))
(defun counsel-git-grep-query-replace ()
"Start `query-replace' with string to replace from last search string."
@@ -2858,14 +2846,17 @@ Works for `counsel-git-grep', `counsel-ag', etc."
(setq ivy-text
(and (string-match "\"\\(.*\\)\"" (buffer-name))
(match-string 1 (buffer-name))))
- (let* ((command-args (counsel--split-command-args ivy-text))
- (regex (counsel--grep-regex (cdr command-args)))
- (switches (concat (car command-args)
- (counsel--ag-extra-switches regex)))
- (cmd (format cmd-template
+ (let* ((cmd
+ (if (functionp cmd-template)
+ (funcall cmd-template ivy-text)
+ (let* ((command-args (counsel--split-command-args ivy-text))
+ (regex (counsel--grep-regex (cdr command-args)))
+ (switches (concat (car command-args)
+ (counsel--ag-extra-switches regex))))
+ (format cmd-template
(concat
switches
- (shell-quote-argument regex))))
+ (shell-quote-argument regex))))))
(cands (counsel--split-string (shell-command-to-string cmd))))
;; Need precise number of header lines for `wgrep' to work.
(insert (format "-*- mode:grep; default-directory: %S -*-\n\n\n"
- [elpa] master 09507fc 109/184: counsel.el (counsel-mark-ring): Fix highlight line of selected candidate, (continued)
- [elpa] master 09507fc 109/184: counsel.el (counsel-mark-ring): Fix highlight line of selected candidate, Oleh Krehel, 2019/10/16
- [elpa] master 46db1b9 107/184: counsel.el (counsel-mark-ring): Add customize variable to sort or not, Oleh Krehel, 2019/10/16
- [elpa] master c0aa563 112/184: ivy.el (ivy-occur): Set up next-error-function, Oleh Krehel, 2019/10/16
- [elpa] master 1a74a21 110/184: ivy-occur: setup for next-error., Oleh Krehel, 2019/10/16
- [elpa] master 30adc93 115/184: Add actions to counsel-switch-buffer, Oleh Krehel, 2019/10/16
- [elpa] master 892e44a 079/184: doc: Add full text of licences, Oleh Krehel, 2019/10/16
- [elpa] master 4645e89 121/184: swiper.el (swiper-action-copy): Add and bind to "M-o w", Oleh Krehel, 2019/10/16
- [elpa] master 77997ea 120/184: counsel.el (counsel-M-x-transformer): Handle read-only strings, Oleh Krehel, 2019/10/16
- [elpa] master 1984068 122/184: doc/ivy.org: Update GFDL license to no Invariant Sections, Oleh Krehel, 2019/10/16
- [elpa] master 881cbc5 130/184: counsel.el (counsel-google-function): Use request in async mode, Oleh Krehel, 2019/10/16
- [elpa] master b39f383 125/184: counsel.el (counsel-git-grep-occur): Re-use counsel-grep-like-occur,
Oleh Krehel <=
- [elpa] master c9f1889 136/184: swiper.el (swiper--query-replace-setup): Fix "^$" issue, Oleh Krehel, 2019/10/16
- [elpa] master b9bb7c6 140/184: ivy.el (ivy-configure): New function to configure many things at once, Oleh Krehel, 2019/10/16
- [elpa] master e3dabec 143/184: counsel.el: Use ivy-configure :unwind-fn, Oleh Krehel, 2019/10/16
- [elpa] master f16ac0e 148/184: ivy.el (ivy--format): Set case-fold-search, Oleh Krehel, 2019/10/16
- [elpa] master 501ac71 151/184: ivy.el (ivy-occur-revert-buffer): Re-use ivy-highlight-grep-commands, Oleh Krehel, 2019/10/16
- [elpa] master 6b0c41b 167/184: ivy.el (ivy-sort-file-function-using-ido): Make obsolete, Oleh Krehel, 2019/10/16
- [elpa] master 22cc602 160/184: counsel.el (counsel-find-symbol): Should not show up in counsel-M-x, Oleh Krehel, 2019/10/16
- [elpa] master b85f857 166/184: .github/FUNDING.yml: Add github, Oleh Krehel, 2019/10/16
- [elpa] master 722250c 162/184: counsel.el (counsel-imenu-action): Handle nil case, Oleh Krehel, 2019/10/16
- [elpa] master 9970ae6 180/184: counsel.el (counsel-read-directory-name): Add, Oleh Krehel, 2019/10/16