[9fans] Acme aborts on a pointless Edit command
I was feeling obscene and decided to test out stupid
commands in sam and acme. Here's something I didn't
expect.
Sam:
, x g/^/m. no change to file
Acme (Edit):
, x g/^/m. aborts in /sys/src/cmd/acme/ecmd.c:/^move
It aborts because "move overlaps itself" but the
question I have is, should it work like sam and
do *visually* nothing at all?
Anthony
P.S.
This came about because I was trying to find a way to
move lines matching a certain pattern to the beginning
of a file (like g/pattern/m0 in ed). Is there a nice
way to do this in sam?
Something that works like the ed command but leaves the
lines in original order, not reversed, would be even
better.
--
I spent a night with a blow-up girl and some LSD. -Freeheat
Re: [9fans] Acme aborts on a pointless Edit command
THE UNIX PROGRAMMING ENVIRONMENT by Kernighan and Pike to the rescue!
According to Appendix A, to reverse lines,
g/^/m0
Or, better yet, in rc:
awk '
{ x[NR] = $0}
END {
for (i = NR; i >= 1; i--)
print x[i]
}'
On Dec 23, 2007, at 11:17 PM, Anthony Martin wrote:
[color=blue]
> I was feeling obscene and decided to test out stupid
> commands in sam and acme. Here's something I didn't
> expect.
>
> Sam:
> , x g/^/m. no change to file
>
> Acme (Edit):
> , x g/^/m. aborts in /sys/src/cmd/acme/ecmd.c:/^move
>
> It aborts because "move overlaps itself" but the
> question I have is, should it work like sam and
> do *visually* nothing at all?
>
>
> Anthony
>
> P.S.
> This came about because I was trying to find a way to
> move lines matching a certain pattern to the beginning
> of a file (like g/pattern/m0 in ed). Is there a nice
> way to do this in sam?
>
> Something that works like the ed command but leaves the
> lines in original order, not reversed, would be even
> better.
>
> --
> I spent a night with a blow-up girl and some LSD. -Freeheat[/color]
Re: [9fans] Acme aborts on a pointless Edit command
> THE UNIX PROGRAMMING ENVIRONMENT by Kernighan and Pike to the rescue![color=blue]
> According to Appendix A, to reverse lines,
>
> g/^/m0[/color]
That's how I know it. If you read again, though, you'll
realize that wasn't my question.
Anthony
Re: [9fans] Acme aborts on a pointless Edit command
i'd be willing to give it a pass if it whined a bit, but aborting
on user input is a bit antisocial.
by the way, the transliteration of the ed line reverse trick into acme
is
Edit ,x m$
(with diagnostic). Edit ,x m0 does not work as expected, especially
on the input file
1
2
- erik
Re: [9fans] Acme aborts on a pointless Edit command
The command
g/^/m0
works in ed because the move commands are done in sequence.
In sam and (supposedly) acme, they're done atomically, and result
in a big no-op. They have a completely different model of execution.
The acme problem is just a bug that should be fixed.
-rob
Re: [9fans] Acme aborts on a pointless Edit command
On Dec 24, 2007 12:25 AM, erik quanstrom <quanstro@quanstro.net> wrote:[color=blue]
> i'd be willing to give it a pass if it whined a bit, but aborting
> on user input is a bit antisocial.[/color]
"Here I am, brain the size of a planet, and they ask me to move lines
around and back, doing nothing. Call that job satisfaction, 'cause I
don't. Excuse me while I go and abort()."
--Joel
Re: [9fans] Acme aborts on a pointless Edit command
The UNIX philosophy: if something doesn't work, fix it. The code is
available and commented to a fault.
The DOS philosophy: if something doesn't work, get a new one or make
one yourself. The program DEBUG is a wonderful place to start.
The GCC philosophy: make something do simple little tasks and put it
together in a large program with a now-pointless acronym. Oh, and
give no warranty, and link lots and lots of useless and complicated
libraries, and spend hours finding bugs in a single configure file.
Choose one. Meanwhile, I'll be ed-ding /dev/sdC0/fossil to find all
occurrences of the string "exits" and move them to where they are
just to see ed blow up. (Seriously, you won't get far with ed-ding a
partition - I tried).
On Dec 24, 2007, at 12:24 PM, Joel C. Salomon wrote:
[color=blue]
> On Dec 24, 2007 12:25 AM, erik quanstrom <quanstro@quanstro.net>
> wrote:[color=green]
>> i'd be willing to give it a pass if it whined a bit, but aborting
>> on user input is a bit antisocial.[/color]
>
> "Here I am, brain the size of a planet, and they ask me to move lines
> around and back, doing nothing. Call that job satisfaction, 'cause I
> don't. Excuse me while I go and abort()."
>
> --Joel[/color]
Re: [9fans] Acme aborts on a pointless Edit command
On Dec 24, 2007 4:17 AM, Anthony Martin <ality@pbrane.org> wrote:[color=blue]
> This came about because I was trying to find a way to
> move lines matching a certain pattern to the beginning
> of a file (like g/pattern/m0 in ed). Is there a nice
> way to do this in sam?[/color]
if i want to do something like this in acme, i'd tend to
split it into stages:
x/pattern/p
x/pattern/d
then paste the text in the output window back
to the beginning of the original window.
(actually, it would be nice if Edit output from a given
window ended up in the local directory's +Errors window
rather than the global one, but i've never quite mustered
the impetus to actually do it...)
Re: [9fans] Acme aborts on a pointless Edit command
I keep waiting for the message that says "here's the patch"
:-)
ron
Re: [9fans] Acme aborts on a pointless Edit command