-
-
Save paxan/562864 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; There's something similar (but fancier) in vc-git.el: vc-git-grep | |
;; -I means don't search through binary files | |
(defcustom git-grep-switches "--extended-regexp -I -n --ignore-case" | |
"Switches to pass to `git grep'." | |
:type 'string) | |
(defcustom git-grep-default-work-tree (expand-file-name "~/Documents/src/kits") | |
"Top of your favorite git working tree. \\[git-grep] will search from here if it cannot figure out where else to look." | |
:type 'directory | |
) | |
(when (require 'vc-git nil t) | |
;; Uncomment this to try out the built-in-to-Emacs function. | |
;;(defalias 'git-grep 'vc-git-grep) | |
(defun git-grep (command-args) | |
(interactive | |
(let ((root (vc-git-root default-directory))) | |
(when (not root) | |
(message "git-grep: %s doesn't look like a git working tree; searching from %s instead" default-directory git-grep-default-work-tree) | |
(setq root git-grep-default-work-tree)) | |
(list (read-shell-command "Run git-grep (like this): " | |
(format (concat | |
"cd %s && " | |
"git grep %s -e %s") | |
root | |
git-grep-switches | |
(shell-quote-argument (thing-at-point 'symbol))) | |
'git-grep-history)))) | |
(let ((grep-use-null-device nil)) | |
(grep command-args)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment