DORMANTno replies

[PATCH] git.el: Add "git grep" functionality in a grep-style compilation buffer

From: David Christensen <hidden>
Date: 2016-06-15 22:45:16
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: David Christensen <redacted>
---
 contrib/emacs/git.el |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 279610f..46a9e49 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -1395,6 +1395,15 @@ amended version of it."
   (let ((info (ewoc-data (ewoc-locate git-status))))
     (view-file (git-fileinfo->name info))))
 
+(defun git-grep (pat)
+  "Run git grep on the repository with the provided pattern;
+results are placed in a grep-compilation buffer."
+  (interactive "sgit grep regexp: ")
+  (unless git-status (error "Not in git-status buffer."))
+  (let ((null-device nil)
+        (git-grep-flags nil))           ; for future extension
+    (grep (concat "git --no-pager grep -n " git-grep-flags " -e " pat))))
+
 (defun git-refresh-status ()
   "Refresh the git status buffer."
   (interactive)
@@ -1446,6 +1455,7 @@ amended version of it."
     (suppress-keymap map)
     (define-key map "?"   'git-help)
     (define-key map "*"    mark-map)
+    (define-key map "%"   'git-grep)
     (define-key map "h"   'git-help)
     (define-key map " "   'git-next-file)
     (define-key map "a"   'git-add-file)
-- 
1.6.0.1.90.g27a6e.dirty
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help