[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b724678 10/12: counsel.el: Add awesome swiper highlighting
From: |
Oleh Krehel |
Subject: |
[elpa] master b724678 10/12: counsel.el: Add awesome swiper highlighting to git grep |
Date: |
Tue, 21 Apr 2015 12:09:23 +0000 |
branch: master
commit b724678cc6eb8ae386a5702e3988de9ce1eebde3
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el: Add awesome swiper highlighting to git grep
* counsel.el (swiper): Require.
(counsel-git-grep-function): Use `swiper--add-overlays'. Remember to set
`swiper--window', and call `swiper--cleanup'. Use `ivy--regex' in all
cases to build the regex.
---
counsel.el | 42 ++++++++++++++++++++++++------------------
1 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/counsel.el b/counsel.el
index c1cc347..62159b9 100644
--- a/counsel.el
+++ b/counsel.el
@@ -32,7 +32,7 @@
;;; Code:
-(require 'ivy)
+(require 'swiper)
(defun counsel-el ()
"Elisp completion at point."
@@ -195,33 +195,39 @@
(setq ivy--full-length counsel--git-grep-count)
(list ""
(format "%d chars more" (- 3 (length ivy-text)))))
- (let ((cmd-t "git --no-pager grep --full-name -n --no-color -i -e \"%s\"")
+ (let ((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 (format cmd-t string)))
+ (setq res (shell-command-to-string cmd))
(setq ivy--full-length nil))
- (setq res (shell-command-to-string (concat (format cmd-t (ivy--regex
string)) " | head -n 5000")))
+ (setq res (shell-command-to-string (concat cmd " | head -n 5000")))
(setq ivy--full-length (counsel-git-grep-count ivy-text)))
(split-string res "\n" t))))
(defun counsel-git-grep ()
"Grep for a string in the current git repository."
(interactive)
- (let* ((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))
- (goto-char (point-min))
- (forward-line (1- (string-to-number (cadr
lst))))))
- (val (ivy-read "pattern: " 'counsel-git-grep-function))
- lst)
- (when val
- (funcall ivy--persistent-action val))))
+ (unwind-protect
+ (let* ((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))
+ (goto-char (point-min))
+ (forward-line (1- (string-to-number
(cadr lst))))
+ (setq swiper--window (selected-window))
+ (swiper--cleanup)
+ (swiper--add-overlays (ivy--regex
ivy-text))))
+ (val (ivy-read "pattern: " 'counsel-git-grep-function))
+ lst)
+ (when val
+ (funcall ivy--persistent-action val)))
+ (swiper--cleanup)))
(defun counsel-locate-function (str &rest _u)
(if (< (length str) 3)
- [elpa] master updated (3d54459 -> e86b27e), Oleh Krehel, 2015/04/21
- [elpa] master 0d1fa17 01/12: ivy.el (ivy-done): Expand file name for empty text, Oleh Krehel, 2015/04/21
- [elpa] master 36b15f3 02/12: ivy.el (ivy--regex): Switch to non-greedy ".*?" joiner, Oleh Krehel, 2015/04/21
- [elpa] master 49638b4 04/12: ivy.el (ivy--sorted-files): Avoid returning an empty list, Oleh Krehel, 2015/04/21
- [elpa] master 2a5d3fc 05/12: Fix double-sorting for file names, Oleh Krehel, 2015/04/21
- [elpa] master bb89c9d 03/12: Allow to customize the sorting methods, Oleh Krehel, 2015/04/21
- [elpa] master 94c124d 07/12: ivy.el (ivy-done): Don't directory-expand glob filename, Oleh Krehel, 2015/04/21
- [elpa] master 5268d10 06/12: Add an option to call the completion action without exiting, Oleh Krehel, 2015/04/21
- [elpa] master 9d5b60f 09/12: ivy.el (ivy--regex): Add optional greedy arg, Oleh Krehel, 2015/04/21
- [elpa] master be716a1 08/12: swiper.el (swiper--add-overlays): Update arglist, Oleh Krehel, 2015/04/21
- [elpa] master b724678 10/12: counsel.el: Add awesome swiper highlighting to git grep,
Oleh Krehel <=
- [elpa] master 675bd5f 11/12: Fix describe-function / -variable "C-." interaction, Oleh Krehel, 2015/04/21
- [elpa] master e86b27e 12/12: Merge commit '675bd5ff97f75fb7d838e6056442ce71adf85e56' from swiper, Oleh Krehel, 2015/04/21