* rgrep with (some) fixed parameters
@ 2008-06-06 19:26 Stefan Vollmar
2008-06-06 20:40 ` Peter Jones
2008-06-06 20:54 ` Thierry Volpiatto
0 siblings, 2 replies; 6+ messages in thread
From: Stefan Vollmar @ 2008-06-06 19:26 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
I find the M-rgrep command very useful but need it frequently in the
context of a particular project where all parameters remain constant
(directory, name pattern of files to search) except the expression to
look for. How could I create a command my-rgrep that uses some pre-set
parameters and only asks for the search pattern (the project-specific
parameters have already been assigned to some variables) ?
Many thanks in advance,
Stefan
--
Dr. Stefan Vollmar, Dipl.-Phys.
Max-Planck-Institut für neurologische Forschung
Gleuelerstr. 50, 50931 Köln, Germany
Tel.: +49-221-4726-213 FAX +49-221-4726-298
Tel.: +49-221-478-5713 Mobile: 0160-93874279
Email: vollmar@nf.mpg.de http://www.nf.mpg.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: rgrep with (some) fixed parameters
2008-06-06 19:26 rgrep with (some) fixed parameters Stefan Vollmar
@ 2008-06-06 20:40 ` Peter Jones
2008-06-06 21:43 ` Stefan Vollmar
2008-06-06 20:54 ` Thierry Volpiatto
1 sibling, 1 reply; 6+ messages in thread
From: Peter Jones @ 2008-06-06 20:40 UTC (permalink / raw)
To: Stefan Vollmar; +Cc: help-gnu-emacs
Stefan Vollmar <vollmar@nf.mpg.de> writes:
> I find the M-rgrep command very useful but need it frequently in the
> context of a particular project where all parameters remain constant
> (directory, name pattern of files to search) except the expression to
> look for. How could I create a command my-rgrep that uses some pre-set
> parameters and only asks for the search pattern (the project-specific
> parameters have already been assigned to some variables) ?
You just need to write a few small lines of lisp. Read the
documentation for rgrep:
C-h f rgrep
--
Peter Jones, pmade inc.
http://pmade.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: rgrep with (some) fixed parameters
2008-06-06 19:26 rgrep with (some) fixed parameters Stefan Vollmar
2008-06-06 20:40 ` Peter Jones
@ 2008-06-06 20:54 ` Thierry Volpiatto
1 sibling, 0 replies; 6+ messages in thread
From: Thierry Volpiatto @ 2008-06-06 20:54 UTC (permalink / raw)
To: Stefan Vollmar; +Cc: help-gnu-emacs
Have a look at TraverseDirectory
http://www.emacswiki.org/cgi-bin/wiki/TraverseDirectory
It doesn't do exactly what you want but it's much easier to configure
than grep/find commands.
May be i can add what you want to it.
Stefan Vollmar <vollmar@nf.mpg.de> writes:
> Hi,
>
> I find the M-rgrep command very useful but need it frequently in the
> context of a particular project where all parameters remain constant
> (directory, name pattern of files to search) except the expression to
> look for. How could I create a command my-rgrep that uses some pre-set
> parameters and only asks for the search pattern (the project-specific
> parameters have already been assigned to some variables) ?
>
> Many thanks in advance,
> Stefan
> --
> Dr. Stefan Vollmar, Dipl.-Phys.
> Max-Planck-Institut für neurologische Forschung
> Gleuelerstr. 50, 50931 Köln, Germany
> Tel.: +49-221-4726-213 FAX +49-221-4726-298
> Tel.: +49-221-478-5713 Mobile: 0160-93874279
> Email: vollmar@nf.mpg.de http://www.nf.mpg.de
>
>
>
>
>
>
>
--
A + Thierry
Pub key: http://pgp.mit.edu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: rgrep with (some) fixed parameters
2008-06-06 20:40 ` Peter Jones
@ 2008-06-06 21:43 ` Stefan Vollmar
2008-06-07 14:23 ` Kevin Rodgers
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Vollmar @ 2008-06-06 21:43 UTC (permalink / raw)
To: help-gnu-emacs
Dear Peter,
On 06.06.2008, at 22:40, Peter Jones wrote:
> Stefan Vollmar <vollmar@nf.mpg.de> writes:
>> I find the M-rgrep command very useful but need it frequently in the
>> context of a particular project where all parameters remain constant
>> (directory, name pattern of files to search) except the expression to
>> look for. How could I create a command my-rgrep that uses some pre-
>> set
>> parameters and only asks for the search pattern (the project-specific
>> parameters have already been assigned to some variables) ?
>
> You just need to write a few small lines of lisp. Read the
> documentation for rgrep:
>
> C-h f rgrep
I did, but I am new to Emacs customization and might have overlooked
something.
If I do the equivalent of a
(setq grep-find-command "find somepath \\( -path \*/.svn \\) -prune -o
-type f \\( -iname \\*.cpp \\) -exec grep -nH -e {} /dev/null \\;")
in my .emacs file,
C-u C-u M-x rgrep
does indeed use this pattern (and does not ask about anything else,
and I could use a keyboard shortcut for this) - so far so good.
However, I feel that having to look at that long-ish command every
time I use it, is not elegant - in particular, as I need to navigate
to the correct position when the find command is being displayed in
the minibuffer (point should be between "-e" and "{}" to insert the
pattern to search for). Could you help me improve on this?
Many thanks in advance,
Stefan
--
Dr. Stefan Vollmar, Dipl.-Phys.
Max-Planck-Institut für neurologische Forschung
Gleuelerstr. 50, 50931 Köln, Germany
Tel.: +49-221-4726-213 FAX +49-221-4726-298
Tel.: +49-221-478-5713 Mobile: 0160-93874279
Email: vollmar@nf.mpg.de http://www.nf.mpg.de
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: rgrep with (some) fixed parameters
2008-06-06 21:43 ` Stefan Vollmar
@ 2008-06-07 14:23 ` Kevin Rodgers
2008-06-07 16:37 ` Stefan Vollmar
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Rodgers @ 2008-06-07 14:23 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Vollmar wrote:
> If I do the equivalent of a
>
> (setq grep-find-command "find somepath \\( -path \*/.svn \\) -prune -o
> -type f \\( -iname \\*.cpp \\) -exec grep -nH -e {} /dev/null \\;")
>
> in my .emacs file,
> C-u C-u M-x rgrep
> does indeed use this pattern (and does not ask about anything else, and
> I could use a keyboard shortcut for this) - so far so good. However, I
> feel that having to look at that long-ish command every time I use it,
> is not elegant - in particular, as I need to navigate to the correct
> position when the find command is being displayed in the minibuffer
> (point should be between "-e" and "{}" to insert the pattern to search
> for). Could you help me improve on this?
(defun project-rgrep (regexp)
"Run `rgrep' with REGEXP, \"*.cpp\" FILES, and \"somepath\" DIR."
(interactive
(progn
(grep-compute-defaults)
(list (grep-read-regexp))))
(rgrep regexp "*.cpp" "somepath"))
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: rgrep with (some) fixed parameters
2008-06-07 14:23 ` Kevin Rodgers
@ 2008-06-07 16:37 ` Stefan Vollmar
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Vollmar @ 2008-06-07 16:37 UTC (permalink / raw)
To: help-gnu-emacs
Dear Kevin,
On 07.06.2008, at 16:23, Kevin Rodgers wrote:
> Stefan Vollmar wrote:
>> If I do the equivalent of a
>> (setq grep-find-command "find somepath \\( -path \*/.svn \\) -prune
>> -o -type f \\( -iname \\*.cpp \\) -exec grep -nH -e {} /dev/null \
>> \;")
>> in my .emacs file,
>> C-u C-u M-x rgrep
>> does indeed use this pattern (and does not ask about anything else,
>> and I could use a keyboard shortcut for this) - so far so good.
>> However, I feel that having to look at that long-ish command every
>> time I use it, is not elegant - in particular, as I need to
>> navigate to the correct position when the find command is being
>> displayed in the minibuffer (point should be between "-e" and "{}"
>> to insert the pattern to search for). Could you help me improve on
>> this?
>
> (defun project-rgrep (regexp)
> "Run `rgrep' with REGEXP, \"*.cpp\" FILES, and \"somepath\" DIR."
> (interactive
> (progn
> (grep-compute-defaults)
> (list (grep-read-regexp))))
> (rgrep regexp "*.cpp" "somepath"))
>
> --
> Kevin Rodgers
> Denver, Colorado, USA
Wonderful - exactly what I had hoped for!
Thanks,
Stefan
--
Dr. Stefan Vollmar, Dipl.-Phys.
Max-Planck-Institut für neurologische Forschung
Gleuelerstr. 50, 50931 Köln, Germany
Tel.: +49-221-4726-213 FAX +49-221-4726-298
Tel.: +49-221-478-5713 Mobile: 0160-93874279
Email: vollmar@nf.mpg.de http://www.nf.mpg.de
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-06-07 16:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-06 19:26 rgrep with (some) fixed parameters Stefan Vollmar
2008-06-06 20:40 ` Peter Jones
2008-06-06 21:43 ` Stefan Vollmar
2008-06-07 14:23 ` Kevin Rodgers
2008-06-07 16:37 ` Stefan Vollmar
2008-06-06 20:54 ` Thierry Volpiatto
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.