branch: master
commit bd69d2139886e35d94909e5f31d6d93e43fd4739
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
counsel.el (counsel-git-occur): Actually use git ls-files
---
counsel.el | 61 +++++++++++++++++++++++++------------------------------------
1 file changed, 25 insertions(+), 36 deletions(-)
diff --git a/counsel.el b/counsel.el
index 93ecbf4..06deeb8 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1061,45 +1061,34 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
(defun counsel-git-occur ()
"Occur function for `counsel-git' using `counsel-find-dired'."
- (let ((re (concat
- (if (string-match-p "\\`\\^" ivy--old-re) "" ".*")
- ivy--old-re
- (if (string-match-p "\\$\\'" ivy--old-re) "" ".*"))))
- (counsel-find-dired
- counsel--git-dir
- (format "%s . -type f -iregex %s -ls"
- find-program
- (shell-quote-argument re)))))
-
-(defvar find-ls-option)
-(defvar find-ls-subdir-switches)
+ (counsel-find-dired
+ counsel--git-dir
+ (format "%s | grep -i -E '%s' | xargs ls -alh"
+ counsel-git-cmd ivy--old-re)))
(defun counsel-find-dired (dir cmd)
"Adapted from `find-dired'."
- (erase-buffer)
- (setq default-directory dir)
- (let ((lines (split-string
- (shell-command-to-string cmd)
- "\n")))
- (dired-mode dir (cdr find-ls-option))
- (mapc (lambda (l)
- (when (string-match "\\` *[0-9]+ *[0-9]+ \\(.*\\)\\'" l)
- (insert
- " "
- (replace-regexp-in-string "\\./" "" (match-string 1 l))
- "\n")))
- lines)
- (goto-char (point-min))
- (setq-local dired-sort-inhibit t)
- (setq-local revert-buffer-function (lambda (_1 _2)
- (counsel-find-dired dir cmd)))
- (setq-local dired-subdir-alist
- (list (cons default-directory (point-min-marker))))
- (setq-local dired-subdir-switches find-ls-subdir-switches)
- (insert " " dir ":\n")
- (let ((point (point)))
- (insert " " cmd "\n")
- (dired-insert-set-properties point (point)))))
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (setq default-directory dir)
+ (let ((lines (split-string
+ (shell-command-to-string cmd)
+ "\n")))
+ (dired-mode dir "-alh")
+ (mapc (lambda (l)
+ (insert " " l "\n"))
+ lines)
+ (goto-char (point-min))
+ (setq-local dired-sort-inhibit t)
+ (setq-local revert-buffer-function (lambda (_1 _2)
+ (counsel-find-dired dir cmd)))
+ (setq-local dired-subdir-alist
+ (list (cons default-directory (point-min-marker))))
+ (setq-local dired-subdir-switches "-alh")
+ (insert " " dir ":\n")
+ (let ((point (point)))
+ (insert " " cmd "\n")
+ (dired-insert-set-properties point (point))))))
(ivy-set-occur 'counsel-git 'counsel-git-occur)