From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bob Proulx Newsgroups: gmane.emacs.help Subject: Re: using find-grep in emacs Date: Tue, 14 May 2013 09:42:07 -0600 Message-ID: <20130514154207.GA28848@hysteria.proulx.com> References: <3477d0ac-7526-4dd7-bc43-7dca9edb1d23@googlegroups.com> <20130514044510.GB17139@dismay.proulx.com> <51922478.7090506@easy-emacs.de> <4C6D96CF-3362-4D80-8875-5959D9B7243C@Web.DE> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1368546145 13587 80.91.229.3 (14 May 2013 15:42:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 14 May 2013 15:42:25 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 14 17:42:26 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UcHMu-0001Yt-1Z for geh-help-gnu-emacs@m.gmane.org; Tue, 14 May 2013 17:42:24 +0200 Original-Received: from localhost ([::1]:36264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcHMt-0007Hw-LD for geh-help-gnu-emacs@m.gmane.org; Tue, 14 May 2013 11:42:23 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcHMh-0007Hd-8W for help-gnu-emacs@gnu.org; Tue, 14 May 2013 11:42:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UcHMe-00005l-Uo for help-gnu-emacs@gnu.org; Tue, 14 May 2013 11:42:11 -0400 Original-Received: from joseki.proulx.com ([216.17.153.58]:46253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UcHMe-00005T-N5 for help-gnu-emacs@gnu.org; Tue, 14 May 2013 11:42:08 -0400 Original-Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id E5063211DD for ; Tue, 14 May 2013 09:42:07 -0600 (MDT) Original-Received: by hysteria.proulx.com (Postfix, from userid 1000) id CF9712DCCE; Tue, 14 May 2013 09:42:07 -0600 (MDT) Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <4C6D96CF-3362-4D80-8875-5959D9B7243C@Web.DE> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 216.17.153.58 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:90764 Archived-At: Peter Dyballa wrote: > schrieb Andreas R=F6hler: > > Because a Null -- 0 -- offers the most space to fill all that in? >=20 > 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