all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Fabrice Niessen" <tdhkhcidiacy-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
To: help-gnu-emacs-mXXj517/zsQ@public.gmane.org
Subject: Re: How do I grep multiple files in Emacs?
Date: Fri, 19 Dec 2008 12:00:51 +0100	[thread overview]
Message-ID: <87ljucpgyk.fsf@mundaneum.com> (raw)
In-Reply-To: 69cd276e-d8a4-479a-b87d-b63e0f7be1a5@k24g2000pri.googlegroups.com

deech,

> I frequently have to search multiple files/ buffers for a
> word/phrase. Is there any way to do this in Emacs without
> dropping into the shell?

In my `.emacs' file, I've mapped `C-c 1', `C-c 2' and `C-c 3'
-- I know, this is normally not advised -- to do different
levels of grepping:

    o   C-c 1 searches for a pattern in the file name;

    o   C-c 2 searches for a pattern in the file contents, but
        only displays the file names which are relevant;

    o   C-c 3 searches for a pattern in the file contents, and
        displays all lines which are relevant.

Keys are more or less bound from the less to the most
"verbose"... 1, 2, 3...

--8<---------------cut here---------------start------------->8---
;; search for files with names matching a wild card pattern and Dired the
;; output
(global-set-key [(control c) ?1] 'find-name-dired)

;; search for files with contents matching a wild card pattern and Dired the
;; output
(global-set-key [(control c) ?2] 'find-grep-dired)

;; run grep via find, with user-specified arguments
(global-set-key [(control c) ?3] 'grep-find)

;; ignore `.svn' and `CVS' directories
(setq grep-find-command
      (concat
       "find . \\( -path '*/.svn' -o -path '*/CVS' \\) -prune -o -type f "
              "-print0 | xargs -0 -e grep -i -n -e "))
--8<---------------cut here---------------end--------------->8---

See (info "(emacs)Dired and Find") for further info.

And, if you wish so, you can have a look at the rest of my
`.emacs' file at:

    http://www.mygooglest.com/fni/dot-emacs.html

Best regards,
  Fabrice Niessen

_________________________________________________________________________
Fabrice Niessen
Search the Web with "My Google Search Tools" on http://www.MyGooglest.com


      parent reply	other threads:[~2008-12-19 11:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-18 21:56 How do I grep multiple files in Emacs? deech
2008-12-18 21:57 ` harven
2008-12-18 22:09   ` deech
2008-12-19  6:29     ` Thierry Volpiatto
2008-12-18 22:50 ` Drew Adams
2008-12-19 11:00 ` Fabrice Niessen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ljucpgyk.fsf@mundaneum.com \
    --to=tdhkhcidiacy-genee64ty+gs+fvcfc7uqw@public.gmane.org \
    --cc=help-gnu-emacs-mXXj517/zsQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.