git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Christensen <david@endpoint.com>
To: git@vger.kernel.org
Cc: julliard@winehq.org, David Christensen <david@endpoint.com>
Subject: [PATCH] git.el: Add "git grep" functionality in a grep-style compilation buffer
Date: Sat, 30 Aug 2008 13:55:23 -0500	[thread overview]
Message-ID: <1220122523-68561-1-git-send-email-david@endpoint.com> (raw)


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

             reply	other threads:[~2008-08-30 18:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-30 18:55 David Christensen [this message]
2008-09-09  9:25 ` [PATCH] git.el: Add "git grep" functionality in a grep-style compilation buffer David Kågedal
2008-09-09 14:51   ` Rémi Vanicat
2008-09-09 15:14     ` David Kågedal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1220122523-68561-1-git-send-email-david@endpoint.com \
    --to=david@endpoint.com \
    --cc=git@vger.kernel.org \
    --cc=julliard@winehq.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).