[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 4adc074 06/22: Fix the default-directory for `counsel-git-
From: |
Oleh Krehel |
Subject: |
[elpa] master 4adc074 06/22: Fix the default-directory for `counsel-git-grep' |
Date: |
Wed, 22 Apr 2015 19:51:47 +0000 |
branch: master
commit 4adc07474f7fb0feb608327483bb47f6724925bd
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Fix the default-directory for `counsel-git-grep'
* counsel.el (counsel--git-grep-dir): New defvar.
(counsel-git-grep-count): Update.
(counsel-git-grep-function): Update.
(counsel-git-grep): Update.
---
counsel.el | 27 ++++++++++++++++-----------
1 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/counsel.el b/counsel.el
index e00bc59..5a2ac72 100644
--- a/counsel.el
+++ b/counsel.el
@@ -181,11 +181,15 @@
(when file
(find-file file))))
+(defvar counsel--git-grep-dir nil
+ "Store the base git directory.")
+
(defun counsel-git-grep-count (str)
"Quickly count the amount of git grep STR matches."
- (let ((out (shell-command-to-string
- (format "git grep -i -c '%s' | sed 's/.*:\\(.*\\)/\\1/g' | awk
'{s+=$1} END {print s}'"
- (ivy--regex str)))))
+ (let* ((default-directory counsel--git-grep-dir)
+ (out (shell-command-to-string
+ (format "git grep -i -c '%s' | sed 's/.*:\\(.*\\)/\\1/g' | awk
'{s+=$1} END {print s}'"
+ (ivy--regex str)))))
(string-to-number out)))
(defvar counsel--git-grep-count nil
@@ -199,14 +203,15 @@
(setq ivy--full-length counsel--git-grep-count)
(list ""
(format "%d chars more" (- 3 (length ivy-text)))))
- (let ((cmd (format "git --no-pager grep --full-name -n --no-color -i -e
\"%s\""
- (ivy--regex string t)))
- res)
+ (let* ((default-directory counsel--git-grep-dir)
+ (cmd (format "git --no-pager grep --full-name -n --no-color -i -e
\"%s\""
+ (ivy--regex string t)))
+ res)
(if (<= counsel--git-grep-count 20000)
(progn
(setq res (shell-command-to-string cmd))
(setq ivy--full-length nil))
- (setq res (shell-command-to-string (concat cmd " | head -n 5000")))
+ (setq res (shell-command-to-string (concat cmd " | head -n 2000")))
(setq ivy--full-length (counsel-git-grep-count ivy-text)))
(split-string res "\n" t))))
@@ -214,14 +219,14 @@
"Grep for a string in the current git repository."
(interactive)
(unwind-protect
- (let* ((counsel--git-grep-count (counsel-git-grep-count ""))
+ (let* ((counsel--git-grep-dir (locate-dominating-file
+ default-directory ".git"))
+ (counsel--git-grep-count (counsel-git-grep-count ""))
(ivy--dynamic-function (when (> counsel--git-grep-count 20000)
'counsel-git-grep-function))
- (git-dir (locate-dominating-file
- default-directory ".git"))
(ivy--persistent-action (lambda (x)
(setq lst (split-string x ":"))
- (find-file (expand-file-name (car lst)
git-dir))
+ (find-file (expand-file-name (car lst)
counsel--git-grep-dir))
(goto-char (point-min))
(forward-line (1- (string-to-number
(cadr lst))))
(setq swiper--window (selected-window))
- [elpa] master updated (e86b27e -> c7a6156), Oleh Krehel, 2015/04/22
- [elpa] master dea7858 01/22: counsel.el (counsel-git-grep-count): Ignore case, Oleh Krehel, 2015/04/22
- [elpa] master c6652b2 02/22: swiper.el (swiper--add-overlays): Make bounds optional, Oleh Krehel, 2015/04/22
- [elpa] master 769023b 03/22: ivy.el (ivy-read): Use initial-input when completing files, Oleh Krehel, 2015/04/22
- [elpa] master 12c25a0 04/22: ivy.el (ivy-read): Don't add the `default-directory', Oleh Krehel, 2015/04/22
- [elpa] master 37d371c 05/22: Add a way to exit ignoring the candidates, Oleh Krehel, 2015/04/22
- [elpa] master 4adc074 06/22: Fix the default-directory for `counsel-git-grep',
Oleh Krehel <=
- [elpa] master dd559ad 07/22: ivy.el (ivy--filter): Try directory expansion with "/", Oleh Krehel, 2015/04/22
- [elpa] master 6da7819 09/22: ivy.el (ivy--filter): Update prefix optimization, Oleh Krehel, 2015/04/22
- [elpa] master 533b788 11/22: ivy.el (ivy-done): Be more strict for `require-match', Oleh Krehel, 2015/04/22
- [elpa] master fb805a0 08/22: README.md: Add a note on outdated ivy package, Oleh Krehel, 2015/04/22
- [elpa] master 70c5fe8 13/22: Bind "M-q" to `ivy-toggle-regexp-quote', Oleh Krehel, 2015/04/22
- [elpa] master 7edfbc9 14/22: ivy.el (ivy--exhibit): Wrap in `while-no-input', Oleh Krehel, 2015/04/22
- [elpa] master 1fad831 10/22: Change `ivy-read' to a cl-defun, Oleh Krehel, 2015/04/22
- [elpa] master e78557a 15/22: swiper.el (swiper--ivy): Fix preselect being added, Oleh Krehel, 2015/04/22
- [elpa] master 28abaa9 12/22: Allow to customize the regex matching per-collection, Oleh Krehel, 2015/04/22
- [elpa] master dd4aced 16/22: ivy.el (ivy--add-face): Don't fail for weird str, Oleh Krehel, 2015/04/22