]> code.delx.au - gnu-emacs-elpa/commitdiff
Git grep using emacs grep, instead of broken vc-git-grep.
authorKen Manheimer <ken.manheimer@gmail.com>
Mon, 12 Oct 2015 16:27:54 +0000 (12:27 -0400)
committerKen Manheimer <ken.manheimer@gmail.com>
Mon, 12 Oct 2015 16:27:54 +0000 (12:27 -0400)
Google search first-hits this github gist wrapping of git grep with
emacs grep mode. I adjusted it a little to properly use '--no-pager'.

(vc-git-grep use of grep-find (or whatever) to dwim always does The
Wrong Thing, requiring finagling of the arguments and editing of the
command, before submitting it.)

gistfile1.el

index f5de07d52ef2d3f3c365672ad75ab194e5825bb5..a8550ce44cc7d704df21e1a00e507cc0dcbf9eee 100644 (file)
@@ -1,10 +1,13 @@
+;; From https://gist.github.com/offby1/1240799
+
 ;; There's something similar (but fancier) in vc-git.el: vc-git-grep
 
 ;; -I means don't search through binary files
 
 ;; --no-color, oddly enough, is required to allow emacs to colorize the output
 
-(defcustom git-grep-switches "--extended-regexp -I -n --ignore-case --no-color"
+(defcustom git-grep-switches
+  "git --no-pager grep --extended-regexp -I -n --ignore-case --no-color"
   "Switches to pass to `git grep'."
   :type 'string)
 
@@ -27,7 +30,7 @@
        (list (read-shell-command "Run git-grep (like this): "
                                  (format (concat
                                           "cd %s && "
-                                          "git grep %s -e %s")
+                                          "%s -e %s")
                                          root
                                          git-grep-switches
                                          (let ((thing (and
@@ -47,3 +50,5 @@
                                  'git-grep-history))))
     (let ((grep-use-null-device nil))
       (grep command-args))))
+
+(provide 'gist-git-grep)
\ No newline at end of file