all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: dkcombs@panix.com (David Combs)
Subject: Re: find string in files
Date: Sun, 19 Nov 2006 22:55:46 +0000 (UTC)	[thread overview]
Message-ID: <ejqndi$bra$1@reader2.panix.com> (raw)
In-Reply-To: 873b96gm1j.fsf@thalassa.informatimago.com

In article <873b96gm1j.fsf@thalassa.informatimago.com>,
Pascal Bourguignon  <pjb@informatimago.com> wrote:
>Gary Wessle <phddas@yahoo.com> writes:
>
>> how can I have the output of "$ grep -FHwire string path" in a window
>> in the same frame with each line hyperlinked so that by placing the
>> pointer and <RET> it takes me there?
>
>M-x grep RET (edit the command) grep -FHwire string path RET
>
>
>> this command is just a shell command to find exact string recursively
>> in a given path.
>
>You'll probably want to keep -n


(Absolutely keep -n  --  that's what emacs uses to go-to
  that line!)


Here's what I do:

In *shell*:

  egrep -in mypattern set-of-files-to-look-in > t.loc
   (note: you MUST either list TWO-or-more files (so as
    to get the file-names in the t.loc lines),
   or accomplish the same via the gnu-egrep option that forces that.

Then, do M-x grep

   and CHANGE the offered grep-stmt to "cat t.loc"

   and THEN hit <return>.

My reason for doing it in these two steps:

.  Enables me to mess around, make mistakes, retry, etc,
    the egrep (OR WHATEVER!) to create that t.loc output-file.

.  The "or whatever!":  all emacs cares is that t.loc 
    LOOKS LIKE the result of a grep -n --
    ie, has lines of the form:

     relative-or-absolute-path-name COLON lineNum COLON (optionally!)the-text-at-that-lineNum

.  about that "(optionally!)the-text..." -- emacs (it seems to me) totally
   *ignores* that text, relying solely on the target line-number.

   THUS -- you can do what ever you want to that egrep-found text --
    such as when running through some text someone has written,
    and you want to make sure that the word "which" wasn't used
    where a "that" would have been better,

  you can modify your t.loc from, say, 

 foo.txt:100:Now is the time for a good man, which is sorely needed in 
 foo.txt:123:that is the location which I saw yesterday when
 foo.txt:147:and she was the date which he went to the
 ...
    
 foo.txt:100:Now is the time for a good man, **WHICH** is sorely needed in 
 foo.txt:123:**THAT** is the location **WHICH** I saw yesterday when
 foo.txt:147:and she was the date **WHICH** he went to the
 ...
 
, enabling you to easily spot all uses of that and which in *grep* --
yet when you ^C^C on a *grep* line, the corresponding one it goes
to, in the actual target file, has *not* been modified.

Nifty.


Also, I believe I had success when using the egrep options -A and -B,
to get surrounding context.


And, you can write your own program or script to hunt down interesting
places in files -- just so your output t.loc file *appears to emacs*
to be output from grep -n.

I hope these hints aid others -- they sure have helped me! 

David

  reply	other threads:[~2006-11-19 22:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-30  6:55 find string in files Gary Wessle
2006-10-30 10:01 ` Pascal Bourguignon
2006-11-19 22:55   ` David Combs [this message]
2006-10-30 10:31 ` Peter Dyballa
2006-10-30 10:48 ` Mathias Dahl

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='ejqndi$bra$1@reader2.panix.com' \
    --to=dkcombs@panix.com \
    /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.