I finally got around to tweaking the the find-grep command in emacs to remove one of it's biggest annoyances (to me). Mainly, that it searches .svn directories for content. I'd say at least 99.999999% of the time this isn't what I want.
Here's what I added to my .emacs to fix this:
(setq grep-find-command "find . -type f '!' -wholename '*/.svn/*' -print0 | xargs -0 -e grep -nH -e ")
Ahhh, much better.
If you use "M-x rgrep" it will automatically construct a find command line which ignores subdirectories of popular version control tools. You may also want to check "M-x lgrep". Both commands take also prefix arguments.
ReplyDeleteOooh, thanks for the grep related suggestions!
ReplyDelete-Ben
You should try out ack. It's vcs aware, and also knows about programming languages.
ReplyDeleteThere's also an ack-mode for it, but just replacing the find + grep command with ack works just fine.
http://petdance.com/ack/
http://www.shellarchive.co.uk/content/emacs.html
/J
Big +1 on the suggestion to use lgrep / rgrep. They’re great.
ReplyDeleteThe other suggestions are quite good, but I thought I'd also point out you could use find's prune capability:
ReplyDeletefind . -name .svn -prune -o -type f -print0
to avoid descending into .svn directories.
Guys -
ReplyDeleteThanks for all the suggestions. lgrep/rgrep will become my new friends.
Thanks for the reminder about -prune - when I checked the man page, I couldn't find it mentioned there. Should have looked harder...
Another +1 for rgrep. I use it every day, and just learned that you can further customize the "ignore directories" list (for things like log directories or whatever) by updating the grep-find-ignored-directories attribute. A nice write up of that is here http://mindlev.wordpress.com/2009/09/26/excluding-directories-from-rgrep-in-emacs/
ReplyDelete