all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bob Proulx <bob@proulx.com>
To: help-gnu-emacs@gnu.org
Subject: Re: using find-grep in emacs
Date: Tue, 14 May 2013 09:42:07 -0600	[thread overview]
Message-ID: <20130514154207.GA28848@hysteria.proulx.com> (raw)
In-Reply-To: <4C6D96CF-3362-4D80-8875-5959D9B7243C@Web.DE>

Peter Dyballa wrote:
> schrieb Andreas Röhler:
> > Because a Null -- 0 -- offers the most space to fill all that in?
> 
> No! It's the least space to read from. No other file ends earlier.

In case this issue confuses people I wanted to say a few words.  Prior
to the addition of the grep -H option the behavior was this following.
The grep, egrep, fgrep programs would print matching lines from files.
If one file was searched then no file name would be printed.  If more
than one file was searched then grep would prefix the line by the name
of the file so that you could tell which file it came from.

So the problem was how do you instruct grep to print the name of the
file even when you were only searching one file?  The answer was to
tell grep to search more than one file.  But, you say, I only want to
search one file.  The answer is to search /dev/null in addition to
whatever file you are wanting to search.  /dev/null will return end of
file immediately.  It won't use any cpu time.  With multiple files
being searched grep will print the file name on each line.  An elegant
Unix solution.  That is why the grep template uses grep with /dev/null
so that grep will print the file name so that Emacs compile mode can
parse it.

GNU grep has an extension to print file names without needing to have
an extra null file argument.  With GNU grep you can specify the -H
option and GNU grep will print the file name for all matches
regardless of the number of files being searched.  Newer emacs
versions use this option and make the assumption that you have GNU
grep available.  (Or it might figure it out dynamically.  I don't
know.)

But the grep -H option is only available in GNU grep for the GNU
system and BSD grep for BSD systems.  It is not available in the older
traditional Unix systems.  It isn't in the POSIX standard.  Therefore
using -H is non-portable.  It won't work on HP-UX or IBM AIX for example.

  http://pubs.opengroup.org/onlinepubs/009695399/utilities/grep.html

But if you are using Emacs then you probably have grep -H available
too and might as well use it.

The Emacs grep find templates can be customized.  See the
grep-find-template variable in this case for example.

Bob



  reply	other threads:[~2013-05-14 15:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-13 23:47 using find-grep in emacs Rami A
2013-05-14  0:45 ` Dan Espen
2013-05-14  2:36   ` Barry Margolin
2013-05-14 13:31     ` Ludwig, Mark
2013-05-14  4:45   ` Bob Proulx
2013-05-14 11:48     ` Andreas Röhler
2013-05-14 15:27       ` Peter Dyballa
2013-05-14 15:42         ` Bob Proulx [this message]
2013-05-14 17:19           ` Andreas Röhler
     [not found]         ` <mailman.25743.1368546134.855.help-gnu-emacs@gnu.org>
2013-05-14 19:41           ` Barry Margolin
2013-05-15 18:25 ` Rami A
2013-05-15 18:49   ` Dan Espen
2013-05-15 18:51   ` Andreas Röhler
     [not found]   ` <mailman.25858.1368643771.855.help-gnu-emacs@gnu.org>
2013-05-15 19:11     ` Rami A
2013-05-15 19:46       ` Andreas Röhler
2013-05-15 21:23         ` Peter Dyballa
2013-05-16  5:10           ` Andreas Röhler

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=20130514154207.GA28848@hysteria.proulx.com \
    --to=bob@proulx.com \
    --cc=help-gnu-emacs@gnu.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.