chiark / gitweb /
el/dot-emacs.el: Approximately cromulent `git-grep' command.
[profile] / el / dot-emacs.el
index 8bb88c3f40f3d84fe49bb02b0938364ab363c6ed..4601e238ed79da17de28e9bade152abba5ab208a 100644 (file)
@@ -3193,6 +3193,19 @@ (defun ssh (host)
   (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.