unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Simple EMACS Grep
@ 2007-04-20  3:23 bobblue88
  2007-04-20  7:31 ` stianse
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: bobblue88 @ 2007-04-20  3:23 UTC (permalink / raw)
  To: help-gnu-emacs

Anyone has a good EMACS Grep define to search only certain file types,
such as "*.c, *.h, *.s, *.cpp" and etc?

The standard EMACS "grep-find" search all file types.

Thanks,

-Robert

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

* Re: Simple EMACS Grep
  2007-04-20  3:23 Simple EMACS Grep bobblue88
@ 2007-04-20  7:31 ` stianse
  2007-04-20  9:05 ` Peter Dyballa
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: stianse @ 2007-04-20  7:31 UTC (permalink / raw)
  To: help-gnu-emacs

On Apr 20, 5:23 am, bobblu...@gmail.com wrote:
> Anyone has a good EMACS Grep define to search only certain file types,
> such as "*.c, *.h, *.s, *.cpp" and etc?
>
> The standard EMACS "grep-find" search all file types.
>
> Thanks,
>
> -Robert

I always use M-x grep for such cases. E.g.

M-x grep
Run grep (like this): grep -nH -e 'foo' *.c

I've never used grep-find so I'm not sure if there are any differences
between these two searches.

- Stian

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

* Re: Simple EMACS Grep
  2007-04-20  3:23 Simple EMACS Grep bobblue88
  2007-04-20  7:31 ` stianse
@ 2007-04-20  9:05 ` Peter Dyballa
       [not found] ` <mailman.2290.1177060338.7795.help-gnu-emacs@gnu.org>
  2007-04-27 15:06 ` Karl Hegbloom
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Dyballa @ 2007-04-20  9:05 UTC (permalink / raw)
  To: bobblue88; +Cc: help-gnu-emacs


Am 20.04.2007 um 05:23 schrieb bobblue88@gmail.com:

> Anyone has a good EMACS Grep define to search only certain file types,
> such as "*.c, *.h, *.s, *.cpp" and etc?
>
> The standard EMACS "grep-find" search all file types.

You need to add:

	\( -name "*.[chs]" -or -name "*.cpp“ \)

And so one if you have more detailed wishes.

--
Mit friedvollen Grüßen

   Pete

The human animal differs from the lesser primates in his passion for  
lists of "Ten Best".
                                      -- H. Allen Smith

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

* Re: Simple EMACS Grep
       [not found] ` <mailman.2290.1177060338.7795.help-gnu-emacs@gnu.org>
@ 2007-04-23  0:21   ` bobblue88
  0 siblings, 0 replies; 5+ messages in thread
From: bobblue88 @ 2007-04-23  0:21 UTC (permalink / raw)
  To: help-gnu-emacs

Thanks, Peter.    Do you know where I can find the original "find-
grep" to customize?  Sorry I am still at a newbee level for EMACS and
has only binary version of 21.3 EMACS installed.

-Robert

On Apr 20, 2:05 am, Peter Dyballa <Peter_Dyba...@Web.DE> wrote:
> Am 20.04.2007 um 05:23 schrieb bobblu...@gmail.com:
>
> > Anyone has a goodEMACSGrepdefine to search only certain file types,
> > such as "*.c, *.h, *.s, *.cpp" and etc?
>
> > The standardEMACS"grep-find" search all file types.
>
> You need to add:
>
>         \( -name "*.[chs]" -or -name "*.cpp" \)
>
> And so one if you have more detailed wishes.
>
> --
> Mit friedvollen Grüßen
>
>    Pete
>
> The human animal differs from the lesser primates in his passion for  
> lists of "Ten Best".
>                                       -- H. Allen Smith

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

* Re: Simple EMACS Grep
  2007-04-20  3:23 Simple EMACS Grep bobblue88
                   ` (2 preceding siblings ...)
       [not found] ` <mailman.2290.1177060338.7795.help-gnu-emacs@gnu.org>
@ 2007-04-27 15:06 ` Karl Hegbloom
  3 siblings, 0 replies; 5+ messages in thread
From: Karl Hegbloom @ 2007-04-27 15:06 UTC (permalink / raw)
  To: bobblue88; +Cc: help-gnu-emacs

On Thu, 2007-04-19 at 20:23 -0700, bobblue88@gmail.com wrote:
> Anyone has a good EMACS Grep define to search only certain file types,
> such as "*.c, *.h, *.s, *.cpp" and etc?
> 
> The standard EMACS "grep-find" search all file types.

Have a look at M-x find-function grep-find once, and see that it first
checks the value of `grep-find-command', and then uses it's own unique
`grep-find-history' variable for the command history.

You could create a ".dired" file for the top-level directory of you C
project with:

  Local Variables:
  grep-find-command: "find . -type f \( -name '*.[hcs]' -or -name '*.cpp' \) -print0 | xargs -0 -e grep -n -e "
  End:

That should make it do what you want by default whenever you run it from
that location, provided you have first requested a directory listing via
dired so that the .dired is seen.

You could also, if you liked, use `add-to-list' to push that string onto
the `grep-find-history' in ~/.emacs.

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

end of thread, other threads:[~2007-04-27 15:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-20  3:23 Simple EMACS Grep bobblue88
2007-04-20  7:31 ` stianse
2007-04-20  9:05 ` Peter Dyballa
     [not found] ` <mailman.2290.1177060338.7795.help-gnu-emacs@gnu.org>
2007-04-23  0:21   ` bobblue88
2007-04-27 15:06 ` Karl Hegbloom

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).