[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
dir-specific grep-find-command?
From: |
Ed L Cashin |
Subject: |
dir-specific grep-find-command? |
Date: |
Sun, 15 Jun 2003 19:54:32 -0400 |
User-agent: |
Gnus/5.090014 (Oort Gnus v0.14) Emacs/21.2 (i386-debian-linux-gnu) |
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/
- dir-specific grep-find-command?,
Ed L Cashin <=