Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add M-x git-grep

  • Loading branch information...
commit a1430770d2a2e69ff8ab1e0befb50a2e42ca29a0 1 parent f952ad4
@nelhage authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 dot-emacs
13 dot-emacs
@@ -249,6 +249,19 @@ unable to perform symbol completion.")
(grep-apply-setting 'grep-use-null-device nil)))
+(defun chomp (str)
+ "Chomp leading and tailing whitespace from STR."
+ (while (string-match "\\`\n+\\|^\\s-+\\|\\s-+$\\|\n+\\'"
+ str)
+ (setq str (replace-match "" t t str)))
+ str)
+(defun git-grep ()
+ (interactive)
+ (let ((cdup (chomp (shell-command-to-string "git rev-parse --show-cdup")))
+ (grep-command "git grep -nH -e"))
+ (cd (expand-file-name cdup))
+ (call-interactively 'grep)))
(eval-after-load 'calc
Please sign in to comment.
Something went wrong with that request. Please try again.