Article View: demon.ip.developers
Article #168Re: grep 'n edit, I wish!
From: pete$no$pam
Date: Wed, 11 Nov 1998 00:00
Date: Wed, 11 Nov 1998 00:00
88 lines
3263 bytes
3263 bytes
In article <910784101snz@wash.demon.co.uk>
john$@wash.demon.co.uk "John Washington" writes:
> OK, this is going to be pretty contrived if I'm to get
> the IP part of the charter into this posting, but traffic
> is getting a bit quiet in this group, so maybe you'll
> welcome ANYthing. :-)
_Almost_ anything :-)
>
> I constantly find myself typing things like:
>
> grep foobar *.c
> [pause to eyeball result]
> edit thisfile.c thatfile.c tother.c yafile.c etc.c
>
> And that really bugs me. The damn computer knows which files
> I want already. I could even have used the -l option in grep
> to get a little list of them.
>
> For several years the synapses down the far end of my tail have
> been reckoning it should be a SMoP to somehow generate that
> command line for me. I could just type
>
> e foobar
>
> and somehow, after a short whirr and churn, I'd be inside the
> editor with all those relevant files ready to roll.
>
> I can't stand it any longer. The message has at last got up to
> my brain that if I don't know how to do it, one of you can, Shirley?
BATCH is your friend. Try the following GREPEDIT.BAT - call
it what you like:
@echo off
if %1.=={%0}. goto addfile
if %2.==. goto error
Rem
Rem Usage is: %0 greptext filelist
Rem eg. %0 buffer *.c
Rem
Rem Ensure you have enough environment space...
Rem
set args=
echo Grepping...
for %%f in (%2) do call %0 {%0} %1 %%f
if %args%.==. goto nofiles
Rem fix the line below for your editor - mine is Qedit
q %args%
echo.
set args=
goto end
:nofiles
echo No files found containing %1
goto end
:error
echo Bad args: usage is %0 greptext filelist
goto end
:addfile
sgrep -l %2 %3
if errorlevel 1 goto end
set args=%args% %3
:end
..
> Can anyone help? Please?? It would make my life so much more
> pleasant when browsing code such as Snews and Ka9q. Phew! At
> last something to get on-topic with IP. :-)
Just try: grepedit my_stuff *.c in your snews dir...
> P.S. What do others feel? Is this kind of digression unwelcome,
> or should we sometimes use this as a forum to exchange useful
> development tools, tips and tricks? Or are there better places
> in Usenet for this?
What is development without tools? In a general sort of way
I see no problem with discussing hints and tips like the
above, keeping in mind the IP bit of the group. So long as
things do not degrade into wars about editors and compilers
etc.
--
Pete
Technical Details
Message-ID:
<910821453snz@pdlmail.demon.co.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<910784101snz@wash.demon.co.uk>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10bb05,f355ae5d069fba47 X-Google-Attributes: gid10bb05,public From: pete$no$pam@pdlmail.demon.co.uk Subject: Re: grep 'n edit, I wish! Date: 1998/11/11 Message-ID: <910821453snz@pdlmail.demon.co.uk> X-Deja-AN: 410866924 X-Reply-To: remove the $no$pam (optional) References: <910784101snz@wash.demon.co.uk> X-Complaints-To: abuse@demon.net X-Mail2News-Path: news.demon.net!pdlmail.demon.co.uk X-Trace: mail2news.demon.co.uk 910822561 mail2news:29338 mail2news mail2news.demon.co.uk Organization: PDL Reply-To: pete$no$pam@pdlmail.demon.co.uk Newsgroups: demon.ip.developers