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: Mon, 13 May 2013 22:45:10 -0600 Message-ID: <20130514044510.GB17139@dismay.proulx.com> References: <3477d0ac-7526-4dd7-bc43-7dca9edb1d23@googlegroups.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1368506727 18902 80.91.229.3 (14 May 2013 04:45:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 14 May 2013 04:45:27 +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 06:45:24 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 1Uc776-00075L-39 for geh-help-gnu-emacs@m.gmane.org; Tue, 14 May 2013 06:45:24 +0200 Original-Received: from localhost ([::1]:55223 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uc775-0001AP-KG for geh-help-gnu-emacs@m.gmane.org; Tue, 14 May 2013 00:45:23 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:60738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uc76v-0001A9-0f for help-gnu-emacs@gnu.org; Tue, 14 May 2013 00:45:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uc76u-0003Ic-0z for help-gnu-emacs@gnu.org; Tue, 14 May 2013 00:45:12 -0400 Original-Received: from joseki.proulx.com ([216.17.153.58]:43695) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uc76t-0003IW-Pq for help-gnu-emacs@gnu.org; Tue, 14 May 2013 00:45:11 -0400 Original-Received: from dismay.proulx.com (dismay.proulx.com [172.27.61.4]) (Authenticated sender: dismay) by joseki.proulx.com (Postfix) with ESMTPA id CDFED211DD for ; Mon, 13 May 2013 22:45:10 -0600 (MDT) Original-Received: by dismay.proulx.com (Postfix, from userid 1000) id 3830CD20359; Mon, 13 May 2013 22:45:10 -0600 (MDT) Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) 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:90739 Archived-At: Dan Espen wrote: > Rami A writes: > > M-x find-grep > > find . -type f -exec grep -n {} /dev/null \; What version of emacs are you using? That isn't emacs 23 nor emacs 24. So what version is it? M-x emacs-version Specifically "\;" should be "+" in emacs 24. > > Now I have to change /dev/null to be the directory which I want to search in. There is a misunderstanding of how that command works. You wouldn't replace /dev/null. Leave it the same. (Or use -H.) The string you would want to replace with the directory you want to search is the "." string not the "/dev/null" string. The "." specifies the directory to search. That space between the "-n" and "{}" is where you should type in the search pattern. > > How is it possible to not do that every time I use find-grep and > > that it could remember the directory I am specifying. > > > > Also, How to make it default to search all three file types .h .s > > .c and nothing else? > > In emacs 24.2.1 the string is: > > find . -type f -print0 | "xargs" -0 -e grep -nH -e That looks more like emacs 23.2.1 not 24.2.1. Emacs 24.3.1 uses this string by default: find . -type f -exec grep -nH -e {} + ^ cursor here > To only look at .hsc files I'd do: > > find . -type f -a -name '*.[hsc]' -exec grep -n {} /dev/null \; > > (Not tested but you should get the idea.) Looks good to me. But also include the pattern. And the -a is superfluous. find . -type f -name '*.[hsc]' -exec grep -nH PATTERN {} + > The "." after find is the directory you want to search in, if you don't > want to search the current directory, replace the ".". > > I believe /dev/null is there to convince grep that it should display > file names because it is looking at multiple files. Yes. Definitely! :-) Bob