From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: harven Newsgroups: gmane.emacs.help Subject: Re: How to supply the current word as a parameter to grep? Date: Fri, 19 Sep 2008 08:34:26 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <388a3e6b-72ee-4f6d-8578-d503d794d9e8@j22g2000hsf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1221838885 31206 80.91.229.12 (19 Sep 2008 15:41:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 19 Sep 2008 15:41: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 Fri Sep 19 17:42:22 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Kgi7g-0007Qv-5N for geh-help-gnu-emacs@m.gmane.org; Fri, 19 Sep 2008 17:42:20 +0200 Original-Received: from localhost ([127.0.0.1]:57749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kgi6e-00020d-Nq for geh-help-gnu-emacs@m.gmane.org; Fri, 19 Sep 2008 11:41:16 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!transit3.readnews.com!news-out.readnews.com!news-xxxfer.readnews.com!postnews.google.com!t54g2000hsg.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 27 Original-NNTP-Posting-Host: 129.20.38.196 Original-X-Trace: posting.google.com 1221838467 25402 127.0.0.1 (19 Sep 2008 15:34:27 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 19 Sep 2008 15:34:27 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: t54g2000hsg.googlegroups.com; posting-host=129.20.38.196; posting-account=hanW0AoAAADuR-PIr5jGeb298Y3jGR7p User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:162463 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:57805 Archived-At: On Sep 19, 2:01=A0pm, etay.me...@gmail.com wrote: > Hi, > > I have the following entries in my .emacs: > > (setq grep-command "cd ~/work && find -name \"*.cpp\" -or -name \"*.h > \" | xargs grep -nH -e ") > > I'd like have the current word supplied as a parameter to grep > whenever I hit the above key combination. > How do I accomplish that? > > Thanks, > > -Etay Meiri The commands lgrep and rgrep are somehow more user-friendly than the M- x grep command. The word at point can be captured using the command (thing-at-point 'word). So you may try: (defun my-grep () "look for word at point in files ending by .cpp and .h recursively starting from the work directory" (interactive) (rgrep (thing-at-point 'word) "*.cpp *.h" "~/work")) (global-set-key [(control shift f)] 'my-grep)