From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?EUC-KR?B?s+vBpMXC?= Subject: Re: Search files in a folder Date: Wed, 15 Sep 2010 01:06:25 +0900 Message-ID: References: <8739teiwsq.wl%ucecesf@ucl.ac.uk> <874oduqul6.fsf@archdesk.localdomain> <87eicxzkdw.fsf@archdesk.localdomain> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2112406160==" Return-path: Received: from [140.186.70.92] (port=59200 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvY1g-0002dH-1Z for emacs-orgmode@gnu.org; Tue, 14 Sep 2010 12:06:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvY1c-0007sN-3w for emacs-orgmode@gnu.org; Tue, 14 Sep 2010 12:06:31 -0400 Received: from mail-pz0-f41.google.com ([209.85.210.41]:53234) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvY1b-0007s4-NF for emacs-orgmode@gnu.org; Tue, 14 Sep 2010 12:06:28 -0400 Received: by pzk26 with SMTP id 26so3959890pzk.0 for ; Tue, 14 Sep 2010 09:06:26 -0700 (PDT) In-Reply-To: <87eicxzkdw.fsf@archdesk.localdomain> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Matt Lundin Cc: emacs-orgmode@gnu.org --===============2112406160== Content-Type: multipart/alternative; boundary=000e0cd1445824576604903a6586 --000e0cd1445824576604903a6586 Content-Type: text/plain; charset=EUC-KR Content-Transfer-Encoding: quoted-printable Wow, It works like a magic! Thank you so much. I wrote it to my .emacs. Thank you. Sincerely, Jeongtae 2010/9/14 Matt Lundin > =B3=EB=C1=A4=C5=C2 writes: > > > Suvayu, I read your comment, and googled about what I can't understand. > > > > In Emacs, M-x grep Filename * does what I want. Thank you. > > > > And now, I want to make it as one elisp command. > > > > What should I do? Can anybody write a simple script? > > FWIW, here's my elisp function to search all my org files with lgrep: > > --8<---------------cut here---------------start------------->8--- > (defun my-org-grep (search &optional context) > "Search for word in org files. > > Prefix argument determines number of lines." > (interactive "sSearch for: \nP") > (let ((grep-find-ignored-files '("#*" ".#*")) > (grep-template (concat "grep -i -nH " > (when context > (concat "-C" (number-to-string context)= )) > " -e "))) > (lgrep search "*org*" "/home/matt/org/"))) > > (global-set-key (kbd "") 'my-org-grep) > --8<---------------cut here---------------end--------------->8--- > > A prefix argument (e.g., C-u 3 ) will change the number of > contextual lines pulled up by the search. > > Best, > Matt > --000e0cd1445824576604903a6586 Content-Type: text/html; charset=EUC-KR Content-Transfer-Encoding: quoted-printable Wow, It works like a magic! Thank you so much.

I wrote it to my .ema= cs. Thank you.

Sincerely, Jeongtae



2010/9/14 Matt Lundin <mdl@imapmail.org>
=B3=EB=C1=A4=C5=C2 <basil83@gmail.= com> writes:

> Suvayu, I read your comment, and googled about what I can't unders= tand.
>
> In Emacs, M-x grep <RET> Filename * <RET> does what I want= . Thank you.
>
> And now, I want to make it as one elisp command.
>
> What should I do? Can anybody write a simple script?

FWIW, here's my elisp function to search all my org files with lg= rep:

--8<---------------cut here---------------start------------->8---
 (defun my-org-grep (search &optional context)
   "Search for word in org files.

Prefix argument determines number of lines."
   (interactive "sSearch for: \nP")
   (let ((grep-find-ignored-files '("#*" ".#*= "))
         (grep-template (concat "grep <X&= gt; -i -nH "
                    &nbs= p;           (when context
                    &nbs= p;             (concat "-C" (number= -to-string context)))
                    &nbs= p;           " -e <R> <F>"))= )
     (lgrep search "*org*" "/home/matt/org/&= quot;)))

 (global-set-key (kbd "<f8>") 'my-org-grep)
--8<---------------cut here---------------end--------------->8---

A prefix argument (e.g., C-u 3 <f8>) will change the number of
contextual lines pulled up by the search.

Best,
Matt

--000e0cd1445824576604903a6586-- --===============2112406160== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --===============2112406160==--