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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: David Christensen <david@xxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux