Customizing Emacs grep-find to ignore Subversion files
Update: Use ack instead. It’s great.
grep-find is an Emacs function for recursively searching all of the files in the current directory. By default, it recurses into Subversion directories, producing redundant, spurious hits.
Fortunately, it’s easy to fix this. If you add the following lines to your .emacs, grep-find will have the desired behavior of ignoring Subversion’s copies of the base versions of your files.
(custom-set-variables
'(grep-find-command "find . -type f -not -name \"*.svn-base\" -and -not -name \"*.tmp\" -print0 | xargs -0 -e grep -n -s -F "))
For further simplicity, you can do something like the following to add a single-keystroke command for searching an entire project.
(defun grep-project (s)
(interactive "sSearch project for: ")
(grep-find (concat "find /home/philbo/webroot/ -type f -not -name \"*.svn-base\" -and -not -name \"*.tmp\" -and -not -name \"*.log\" -print0 | xargs -0 -e grep -n -s \
-F \"" s "\""))
)
(global-set-key (quote [f4]) (quote grep-project))