unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* dir-specific grep-find-command?
@ 2003-06-15 23:54 Ed L Cashin
  2003-06-17 19:10 ` Kevin Rodgers
  0 siblings, 1 reply; 4+ messages in thread
From: Ed L Cashin @ 2003-06-15 23:54 UTC (permalink / raw)


Hi.  I often have to do grep-find in the linux kernel sources, and I
never want grep to search through object files and the like.  I wrote
a little script, kern-grep-find, that does this:

  test -z "$*" && exit 0
  
  find . -type f \
      ! \( -name '*.o' \
      -o -name 'vmlinu*' \
      -o -name '*.ko' \
      -o -name '*.a' \
      -o -name '*.so' \) \
      -print0 | xargs -0 -e grep -n -e "$*"

... and then I wanted that to be the default command for those times
when I'm doing dired or using a buffer in the kernel sources.  For
want of a more elegant solution, I created a list of regexps that
match my kernel source directories and am overriding the grep-find
function in my .emacs file, modifying grep-find like this:

      (unless grep-find-command
        (grep-compute-defaults))
      (list (read-from-minibuffer "Run find (like this): "
-                                grep-find-command nil nil
-                                'grep-find-history))))
+                                (if (in-kernel 0)
+                                    "kern-grep-find "
+                                    grep-find-command) nil nil
+                                    'grep-find-history))))
   (let ((null-device nil))             ; see grep
     (grep command-args)))

... so that it calls my "in-kernel" function to see whether the
default-directory matches one of my kernel source dir regexps.  If
we're in the kernel sources, it uses the script, otherwise, it uses
grep-find-command. 

This works, but it seems really ugly.  Since grep-find doesn't have
any hooks, and I'm not immediately sure how hooks would even work, I
don't know what else to do.

Does anyone have any ideas or suggestions?

-- 
--Ed L Cashin     PGP public key: http://noserose.net/e/pgp/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-06-20 15:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-15 23:54 dir-specific grep-find-command? Ed L Cashin
2003-06-17 19:10 ` Kevin Rodgers
2003-06-19  5:13   ` Ed L Cashin
2003-06-20 15:07     ` Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).