el/dot-emacs.el: Approximately cromulent `git-grep' command.
authorMark Wooding <mwooding@good.com>
Mon, 16 Mar 2015 13:46:05 +0000 (13:46 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 16 Mar 2015 15:21:12 +0000 (15:21 +0000)
Full Emacs grep is much fancier.  Maybe it'll get improved later.  Maybe
someone else will do a proper one.  Alas, the thing welded into vc-git
is terrible.

el/dot-emacs.el

index 8bb88c3..4601e23 100644 (file)
@@ -3193,6 +3193,19 @@ This allows you to pass a list of arguments through `ansi-term'."
   (interactive "sHost: ")
   (ansi-term (list "ssh" host) (format "ssh@%s" host)))
 
+(defvar git-grep-command
+  "env PAGER=cat git grep --no-color -nH -e "
+  "*The default command for \\[git-grep].")
+
+(defvar git-grep-history nil)
+
+(defun git-grep (command-args)
+  "Run `git grep' with user-specified args and collect output in a buffer."
+  (interactive
+   (list (read-shell-command "Run git grep (like this): "
+                            git-grep-command 'git-grep-history)))
+  (grep command-args))
+
 ;;;--------------------------------------------------------------------------
 ;;; Inferior Emacs Lisp.