jde-find-dired

Len Trigg <[email protected]> Thu, 22 Mar 2007 10:10:46 +1200
Newsgroups gmane.emacs.jdee
Organization Reel Two Ltd.
Message-ID <hbaby65jtl.wl%[email protected]>
Hi all,

Here's a handy function I use for finding java files containing text
as a dired buffer.


(defun jde-find-dired (dir regexp)
  "Find java files in DIR containing a regexp REGEXP and start Dired on output.
The command run (after changing into DIR) is

    find . -type f -and -name \\*.java -exec grep -s -e REGEXP {} \\\; -ls

Thus ARG can also contain additional grep options."
  (interactive "DJde-find-dired (directory): \nsJde-find-dired (grep regexp): ")
  (find-dired dir
	      (concat "-type f -and -name \\*.java -exec grep " find-grep-options " -e "
		      (shell-quote-argument regexp)
		      " {} \\\; ")))


The built-in jde-find is good for hopping from one occurrence to another,
but jde-find-dired gives you an easy way to do search/replace of all
occurrences (e.g.: using dired's: % m java <RET>, then Q).

Dired's built-in find-grep picks up unwanted files (like class files,
svn admin files).

However, it would be nice if my function could have knowledge of
multiple sourcepath directories like jde-find does, but that seemed a
bit tricky.


Also, is there a recommended place to put useful functions like this?
Perhaps hanging off the jdee page at the emacswiki?  (I suspect there
are a lot of such functions living in people's .emacs files, and it'd
be nice to share them.)


Cheers,
Len.