Created
March 16, 2023 21:47
-
-
Save twopoint718/1845c1e246ce4050d3303d3b61384b2e to your computer and use it in GitHub Desktop.
Wrapper for Emacs' default grep. It uses `git grep`, passes in the git project directory, and also uses the current symbol under cursor as a default.
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
(defun cjw-git-grep (my-word) | |
"Use git-grep for search in current project (vc-root-dir). Default | |
search term uses symbol under cursor" | |
(interactive | |
(list | |
(read-string | |
(format "Search (%s): " (thing-at-point 'symbol)) ; prompt | |
nil ; initial input | |
nil ; history list | |
(thing-at-point 'symbol) ; evaluated. will be default | |
))) | |
(let ((default-directory (vc-root-dir))) | |
(message "=====> git grep '%s' in %s" my-word (vc-root-dir)) | |
(grep (format "git --no-pager grep --line-number -e '%s'" my-word)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment