branch: master commit 587526e00bc68c6610fee53146b6a176d190ad9c Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
counsel.el (counsel-git-grep-transformer): New defun * counsel.el (ivy-set-display-transformer): 'counsel-git-grep-transformer to 'counsel-git-grep . Fixes #399 --- counsel.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/counsel.el b/counsel.el index cf6eb01..e8597a6 100644 --- a/counsel.el +++ b/counsel.el @@ -686,6 +686,7 @@ Describe the selected candidate." map)) (ivy-set-occur 'counsel-git-grep 'counsel-git-grep-occur) +(ivy-set-display-transformer 'counsel-git-grep 'counsel-git-grep-transformer) (defvar counsel-git-grep-cmd "git --no-pager grep --full-name -n --no-color -i -e %S" "Store the command for `counsel-git-grep'.") @@ -753,6 +754,19 @@ Describe the selected candidate." candidates)) (setq ivy--old-re regexp)))) +(defun counsel-git-grep-transformer (str) + "Higlight file and line number in STR." + (when (string-match "\\`\\([^:]+\\):\\([^:]+\\):" str) + (set-text-properties (match-beginning 1) + (match-end 1) + '(face compilation-info) + str) + (set-text-properties (match-beginning 2) + (match-end 2) + '(face compilation-line-number) + str)) + str) + ;;;###autoload (defun counsel-git-grep (&optional cmd initial-input) "Grep for a string in the current git repository.