9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] command repetition in sam/acme
@ 2009-03-03 12:07 Rudolf Sykora
  2009-03-03 12:49 ` Steve Simon
                   ` (2 more replies)
  0 siblings, 3 replies; 38+ messages in thread
From: Rudolf Sykora @ 2009-03-03 12:07 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello,

I just had to edit a file which has very long lines having >1000
'words' seperated e.g. with a TAB character. I had to find say 1000th
word on such a line.

In vim, it's easy. You use '1000W' command and there you are.
Can the same be achieved in sam/acme? The main problem for me is the
repetition --- i.e. how to do sth. known number of times...

Thanks
Ruda



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 12:07 [9fans] command repetition in sam/acme Rudolf Sykora
@ 2009-03-03 12:49 ` Steve Simon
  2009-03-03 13:53   ` Rudolf Sykora
  2009-03-03 14:15 ` John Stalker
  2009-03-03 16:09 ` Russ Cox
  2 siblings, 1 reply; 38+ messages in thread
From: Steve Simon @ 2009-03-03 12:49 UTC (permalink / raw)
  To: 9fans

I would do it with awk myself, Much depends on what you want to
do to the 1000'th word on the line.

in sam you can even play with your awk script in the command window, editing it
submitting it and if its wrong you just Undo and try again. Similar things can be
done in acme I believe but I don't know that.

-Steve



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 12:49 ` Steve Simon
@ 2009-03-03 13:53   ` Rudolf Sykora
  2009-03-03 15:40     ` roger peppe
  0 siblings, 1 reply; 38+ messages in thread
From: Rudolf Sykora @ 2009-03-03 13:53 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> I would do it with awk myself, Much depends on what you want to
> do to the 1000'th word on the line.

Say I really want to get there, so that I can manually edit the place.

Ruda



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 12:07 [9fans] command repetition in sam/acme Rudolf Sykora
  2009-03-03 12:49 ` Steve Simon
@ 2009-03-03 14:15 ` John Stalker
  2009-03-03 14:23   ` Rudolf Sykora
  2009-03-03 16:09 ` Russ Cox
  2 siblings, 1 reply; 38+ messages in thread
From: John Stalker @ 2009-03-03 14:15 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> I just had to edit a file which has very long lines having >1000
> 'words' seperated e.g. with a TAB character. I had to find say 1000th
> word on such a line.
>
> In vim, it's easy. You use '1000W' command and there you are.
> Can the same be achieved in sam/acme? The main problem for me is the
> repetition --- i.e. how to do sth. known number of times...
>
> Thanks
> Ruda

It's horribly inelegant, but I have occasionally done the following:
Suppose I want to repeat the command xyz 64 times.  I type xyz,
snarf it and paste it three times.  Then I snarf the lot of them,
and paste three times.  Then I snarf that and paste three times.
Ugly as hell, but it does work.
--
John Stalker
School of Mathematics
Trinity College Dublin
tel +353 1 896 1983
fax +353 1 896 2282



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 14:15 ` John Stalker
@ 2009-03-03 14:23   ` Rudolf Sykora
  0 siblings, 0 replies; 38+ messages in thread
From: Rudolf Sykora @ 2009-03-03 14:23 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> It's horribly inelegant, but I have occasionally done the following:
> Suppose I want to repeat the command xyz 64 times.  I type xyz,
> snarf it and paste it three times.  Then I snarf the lot of them,
> and paste three times.  Then I snarf that and paste three times.
> Ugly as hell, but it does work.

... :)

sounds like pioneering a way to hell
Ruda



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 13:53   ` Rudolf Sykora
@ 2009-03-03 15:40     ` roger peppe
  2009-03-03 15:58       ` yy
  2009-03-03 15:58       ` Uriel
  0 siblings, 2 replies; 38+ messages in thread
From: roger peppe @ 2009-03-03 15:40 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

2009/3/3 Rudolf Sykora <rudolf.sykora@gmail.com>:
>> I would do it with awk myself, Much depends on what you want to
>> do to the 1000'th word on the line.
>
> Say I really want to get there, so that I can manually edit the place.

if i really had to do this (as a one-off), i'd probably do it in a
few stages:

copy & paste the line to a New blank window.
in the new window:
Edit ,x/[ 	]+/a/\n/
:1000

edit as desired
Edit ,x/\n/d

copy and paste back to the original window.

if you were going to do this a lot, you could easily make a little
script to tell you the offset of the 1000th word.

e.g.
sed 's/[ \t]+/&\n/' | sed 1000q | tr -d '\012' | wc -c

actually that doesn't work 'cos sed has line length issues.
so i'd probably do it in C - the program would take the line
as stdin and could print out address
of the word in acme-friendly notation, e.g. :-++#8499;+#6

it'd only be a few minutes to write.

another option would be to write a little script that used the
addr file repeatedly to find the nth match of a regexp.



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 15:40     ` roger peppe
@ 2009-03-03 15:58       ` yy
  2009-03-03 16:25         ` Rudolf Sykora
  2009-03-03 15:58       ` Uriel
  1 sibling, 1 reply; 38+ messages in thread
From: yy @ 2009-03-03 15:58 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

2009/3/3 roger peppe <rogpeppe@gmail.com>:
> 2009/3/3 Rudolf Sykora <rudolf.sykora@gmail.com>:
>>> I would do it with awk myself, Much depends on what you want to
>>> do to the 1000'th word on the line.
>>
>> Say I really want to get there, so that I can manually edit the place.
>
> if i really had to do this (as a one-off), i'd probably do it in a
> few stages:
>
> copy & paste the line to a New blank window.
> in the new window:
> Edit ,x/[       ]+/a/\n/
> :1000
>
> edit as desired
> Edit ,x/\n/d
>
> copy and paste back to the original window.
>
> if you were going to do this a lot, you could easily make a little
> script to tell you the offset of the 1000th word.
>

Or you could also substitute the newline for whatever you want, so you
don't have to copy/paste to another window, eg:

Edit ,x/[\n]+/a/ENDOFLINE/
Edit ,x/[       ]+/a/\n/

Now you can go to the 1000 word with
:/ENDOFLINE/+1000

and once you are done:
Edit ,x/\n/d
Edit ,x/ENDOFLINE/c/\n/

If you are sure you don't have blank fields you don't need ENDOFLINE
and can use ^$ instead (don't forget to use the g command when you
remove the new lines). A bit awkward, but I don't think there is
(there should be?) a simple way to do such a weird task.

hth,


-- 
- yiyus || JGL .



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 15:40     ` roger peppe
  2009-03-03 15:58       ` yy
@ 2009-03-03 15:58       ` Uriel
  2009-03-03 15:59         ` Uriel
  1 sibling, 1 reply; 38+ messages in thread
From: Uriel @ 2009-03-03 15:58 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

awk '{n=n+NF} n>1000 {print ":"NR; exit}'

That will print something you can plumb and go to the line you want.

Should be obvious enough how to generalize into a reusable script.

(Typed from memory and not tested.)

uriel

On Tue, Mar 3, 2009 at 4:40 PM, roger peppe <rogpeppe@gmail.com> wrote:
> 2009/3/3 Rudolf Sykora <rudolf.sykora@gmail.com>:
>>> I would do it with awk myself, Much depends on what you want to
>>> do to the 1000'th word on the line.
>>
>> Say I really want to get there, so that I can manually edit the place.
>
> if i really had to do this (as a one-off), i'd probably do it in a
> few stages:
>
> copy & paste the line to a New blank window.
> in the new window:
> Edit ,x/[       ]+/a/\n/
> :1000
>
> edit as desired
> Edit ,x/\n/d
>
> copy and paste back to the original window.
>
> if you were going to do this a lot, you could easily make a little
> script to tell you the offset of the 1000th word.
>
> e.g.
> sed 's/[ \t]+/&\n/' | sed 1000q | tr -d '\012' | wc -c
>
> actually that doesn't work 'cos sed has line length issues.
> so i'd probably do it in C - the program would take the line
> as stdin and could print out address
> of the word in acme-friendly notation, e.g. :-++#8499;+#6
>
> it'd only be a few minutes to write.
>
> another option would be to write a little script that used the
> addr file repeatedly to find the nth match of a regexp.
>
>



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 15:58       ` Uriel
@ 2009-03-03 15:59         ` Uriel
  0 siblings, 0 replies; 38+ messages in thread
From: Uriel @ 2009-03-03 15:59 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Ok, I'm a moron for not reading the original post before answering. Never mind.

uriel

On Tue, Mar 3, 2009 at 4:58 PM, Uriel <uriel99@gmail.com> wrote:
> awk '{n=n+NF} n>1000 {print ":"NR; exit}'
>
> That will print something you can plumb and go to the line you want.
>
> Should be obvious enough how to generalize into a reusable script.
>
> (Typed from memory and not tested.)
>
> uriel
>
> On Tue, Mar 3, 2009 at 4:40 PM, roger peppe <rogpeppe@gmail.com> wrote:
>> 2009/3/3 Rudolf Sykora <rudolf.sykora@gmail.com>:
>>>> I would do it with awk myself, Much depends on what you want to
>>>> do to the 1000'th word on the line.
>>>
>>> Say I really want to get there, so that I can manually edit the place.
>>
>> if i really had to do this (as a one-off), i'd probably do it in a
>> few stages:
>>
>> copy & paste the line to a New blank window.
>> in the new window:
>> Edit ,x/[       ]+/a/\n/
>> :1000
>>
>> edit as desired
>> Edit ,x/\n/d
>>
>> copy and paste back to the original window.
>>
>> if you were going to do this a lot, you could easily make a little
>> script to tell you the offset of the 1000th word.
>>
>> e.g.
>> sed 's/[ \t]+/&\n/' | sed 1000q | tr -d '\012' | wc -c
>>
>> actually that doesn't work 'cos sed has line length issues.
>> so i'd probably do it in C - the program would take the line
>> as stdin and could print out address
>> of the word in acme-friendly notation, e.g. :-++#8499;+#6
>>
>> it'd only be a few minutes to write.
>>
>> another option would be to write a little script that used the
>> addr file repeatedly to find the nth match of a regexp.
>>
>>
>



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 12:07 [9fans] command repetition in sam/acme Rudolf Sykora
  2009-03-03 12:49 ` Steve Simon
  2009-03-03 14:15 ` John Stalker
@ 2009-03-03 16:09 ` Russ Cox
  2009-03-03 16:31   ` roger peppe
                     ` (2 more replies)
  2 siblings, 3 replies; 38+ messages in thread
From: Russ Cox @ 2009-03-03 16:09 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> I just had to edit a file which has very long lines having >1000
> 'words' seperated e.g. with a TAB character. I had to find say 1000th
> word on such a line.
>
> In vim, it's easy. You use '1000W' command and there you are.
> Can the same be achieved in sam/acme? The main problem for me is the
> repetition --- i.e. how to do sth. known number of times...

You can double-click at the beginning of the line and then execute

s/<tab>/\n/g
.-0+1000
u

that will show you what the 1000th word is, and then you
can go back to it after the undo.  It's not ideal, but you asked.

Russ


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 15:58       ` yy
@ 2009-03-03 16:25         ` Rudolf Sykora
  0 siblings, 0 replies; 38+ messages in thread
From: Rudolf Sykora @ 2009-03-03 16:25 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Thanks for the suggestions. Basically you propose breaking the line
into many lines, navigate using lines, edit, and then go back. That's
possible and manageable.

There is probably no need for having sth simple for this particular
task, however, generally thinking about it, being able to repeat
either a regex or a command known number of times might be quite
useful for me. (Then the task would be trivial.)

Thanks
Ruda

PS.:
Btw., as I said some time ago, files like mine do appear really often
in any (perhaps non-computer) science --- physics, medecine,
biology... There it is not so weird, but a necessity.



> Or you could also substitute the newline for whatever you want, so you
> don't have to copy/paste to another window, eg:
>
> Edit ,x/[\n]+/a/ENDOFLINE/
> Edit ,x/[       ]+/a/\n/
>
> Now you can go to the 1000 word with
> :/ENDOFLINE/+1000
>
> and once you are done:
> Edit ,x/\n/d
> Edit ,x/ENDOFLINE/c/\n/
>
> If you are sure you don't have blank fields you don't need ENDOFLINE
> and can use ^$ instead (don't forget to use the g command when you
> remove the new lines). A bit awkward, but I don't think there is
> (there should be?) a simple way to do such a weird task.
>
> hth,



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 16:09 ` Russ Cox
@ 2009-03-03 16:31   ` roger peppe
  2009-03-03 17:16     ` Uriel
  2009-03-03 16:39   ` Rudolf Sykora
  2009-03-03 20:30   ` Arvindh Rajesh Tamilmani
  2 siblings, 1 reply; 38+ messages in thread
From: roger peppe @ 2009-03-03 16:31 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

2009/3/3 Russ Cox <rsc@swtch.com>:
> s/<tab>/\n/g
> .-0+1000
> u
>
> that will show you what the 1000th word is, and then you
> can go back to it after the undo.  It's not ideal, but you asked.

watch out though... that actually takes you to the 1001st word!



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 16:09 ` Russ Cox
  2009-03-03 16:31   ` roger peppe
@ 2009-03-03 16:39   ` Rudolf Sykora
  2009-03-03 20:30   ` Arvindh Rajesh Tamilmani
  2 siblings, 0 replies; 38+ messages in thread
From: Rudolf Sykora @ 2009-03-03 16:39 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> s/<tab>/\n/g
> .-0+1000
> u
> Russ

Either I don't understand or this can't help me much. It's true that I
can see the 1000th word with this, but I need to edit that word then.
Just seeing it is not enough. The very same word can be on the very
line many times.

Anyway the idea is quite the same as of the others.

Thanks
Ruda



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 16:31   ` roger peppe
@ 2009-03-03 17:16     ` Uriel
  2009-03-03 18:50       ` Rudolf Sykora
  0 siblings, 1 reply; 38+ messages in thread
From: Uriel @ 2009-03-03 17:16 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Using a text editor to manipulate files with lines that are thousands
of words long seems like a not very good idea to me.

But all you need is two awk one liners to automate such task. Get desired word:

awk -v w=1000 -v ORS=' ' -v 'RS= ' 'NR==w { print } '

Replace it with a new value:

awk -v w=1000  -v nw='NewValue' -v ORS=' ' -v 'RS= ' 'NR==w { print
nw; next } { print } '

And so on for any other similar tasks.

A script that prompts you for line and word number, prints it, and
lets you enter a new value should be under a dozen lines of rc.

uriel

On Tue, Mar 3, 2009 at 5:31 PM, roger peppe <rogpeppe@gmail.com> wrote:
> 2009/3/3 Russ Cox <rsc@swtch.com>:
>> s/<tab>/\n/g
>> .-0+1000
>> u
>>
>> that will show you what the 1000th word is, and then you
>> can go back to it after the undo.  It's not ideal, but you asked.
>
> watch out though... that actually takes you to the 1001st word!
>
>



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 17:16     ` Uriel
@ 2009-03-03 18:50       ` Rudolf Sykora
  0 siblings, 0 replies; 38+ messages in thread
From: Rudolf Sykora @ 2009-03-03 18:50 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> Using a text editor to manipulate files with lines that are thousands
> of words long seems like a not very good idea to me.

1st : I don't see why. I had a feeling there was some tendency (at
least R Pike could have one) not to look at a file as on a list of
lines, but as on a linear stream of bytes. I find it really
frustrating when I see comments, like above, that eg. sed has problems
with 'too-long' lines.

2nd: as long as you communicate with people who use common measuring
instruments, you just have to edit such files. They are plain-text
files but have long lines. That doesn't mean they are extraordinarily
big; they may have only a few lines. And moreover, the structure of
those file is sensible.

3rd: awk might be a good instrument (although eg. Raymond argues it is
flawed) for analysis carried out automatically by machines, but it is,
for me, not an editor for manual, human, interactive work.

In the light of aforementioned: vim's ability to work in the nowrap
mode and the ability to repeat commands (or regexps) [and I could add
also the existence of column blocks] makes it superior to both
acme/sam when editing considered files. As usually, this is the tax
for sam/acme's simplicity. And, understand, I am for simple things. I
somehow can understand why sam and acme don't have the nowrap mode
and, followingly, the column blocks. It is, as far as I know, due to
the stream-like character of sam/acme's view on files. What I can't
understand is, why I can't repeat my commands / regexps. One of these
would be right enough to easily do my task and many more. Correct me
if I am wrong, but even the simplest regexps used in linux can have a
number denoting repetition. Why plan9's regexp(7) doesn't have it?

Thanks
Ruda



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 16:09 ` Russ Cox
  2009-03-03 16:31   ` roger peppe
  2009-03-03 16:39   ` Rudolf Sykora
@ 2009-03-03 20:30   ` Arvindh Rajesh Tamilmani
  2009-03-03 22:13     ` ron minnich
  2 siblings, 1 reply; 38+ messages in thread
From: Arvindh Rajesh Tamilmani @ 2009-03-03 20:30 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> You can double-click at the beginning of the line and then execute
>
> s/<tab>/\n/g
> .-0+1000
> u
>
> that will show you what the 1000th word is

it is useful to note down the address here.

s/<tab>/\n/g
.-0+1000
=#
u

the output of '=#' can then be 'sent' to the
sam window to reach the 1000th word.

setting the address mark (k) doesn't
seem to work in this case.

arvindh



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 20:30   ` Arvindh Rajesh Tamilmani
@ 2009-03-03 22:13     ` ron minnich
  2009-03-03 23:19       ` J.R. Mauro
  2009-03-03 23:37       ` Anthony Sorace
  0 siblings, 2 replies; 38+ messages in thread
From: ron minnich @ 2009-03-03 22:13 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

This discussion strikes me as coming from a different galaxy. It seems
to me that Acme and Sam clearly don't match the task at hand. We're
trying to use a screwdriver when we need a jackhammer .

I don't see the point in complaining about file formats. The
scientists in this case don't much care what we think. They're not
going to rewrite their formats so someone can use Acme.

Here's my suggestion:

vi

ron



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 22:13     ` ron minnich
@ 2009-03-03 23:19       ` J.R. Mauro
  2009-03-03 23:37       ` Anthony Sorace
  1 sibling, 0 replies; 38+ messages in thread
From: J.R. Mauro @ 2009-03-03 23:19 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Tue, Mar 3, 2009 at 5:13 PM, ron minnich <rminnich@gmail.com> wrote:
> This discussion strikes me as coming from a different galaxy. It seems
> to me that Acme and Sam clearly don't match the task at hand. We're
> trying to use a screwdriver when we need a jackhammer .
>
> I don't see the point in complaining about file formats. The
> scientists in this case don't much care what we think. They're not
> going to rewrite their formats so someone can use Acme.
>
> Here's my suggestion:
>
> vi

I seem to remember an interview with Rob Pike where he said that the
reason he hated vi and emacs was that they didn't support mouse
placement, and other than that, they were fine. I wonder if he would
find Vim usable these days, given that you can mouse around in it
without sacrificing the really powerful command syntax that Rudolf
seems to be missing here.

It's definitely efficient to be able to just "point and say 'here'",
which I think is the wording Rob used, but it's also useful to be able
to just say "go down 5 lines and then forward 5 words", which vi
excels at. I really like Acme, but (and maybe it's just me being a
newbie) I find myself really missing some of the vi
movement/delete/yank syntax.



Just my $.02 USD, which, due to inflation, is pretty worthless these days.

>
> ron
>
>



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 22:13     ` ron minnich
  2009-03-03 23:19       ` J.R. Mauro
@ 2009-03-03 23:37       ` Anthony Sorace
  2009-03-04  0:31         ` Rob Pike
  1 sibling, 1 reply; 38+ messages in thread
From: Anthony Sorace @ 2009-03-03 23:37 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

i agree complaining about the formats is pointless. and hey, at least
it's text. last plain text format with slightly awkward lines i had to
play with, they went and changed the next version to be ASN.1.

but i don't think the suggestions here for how to make it play well
with Acme are all that bad. personally, i'd go rog's route of writing
a little program to pop out the address, as having things jump around
when changing tabs for newlines and back would be kind jarring. Acme's
not ideally suited to the task at hand, but it's not an awful fit,
either, and has many other nice benefits that likely make up for the
disconnect (or would for me, anyway).

and, as they say, if you want vim you know where to find it.

oh, wait, maybe you don't:
	:; contrib/list stefanha/vim
	stefanha/vim: Vim: enhanced vi editor
never used it myself, but it exists. i find vi(1) more fun, myself.

anthony



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-03 23:37       ` Anthony Sorace
@ 2009-03-04  0:31         ` Rob Pike
  2009-03-04  0:44           ` J.R. Mauro
  2009-03-04  9:41           ` Rudolf Sykora
  0 siblings, 2 replies; 38+ messages in thread
From: Rob Pike @ 2009-03-04  0:31 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Sam and Acme use a simple, pure form of regular expressions.  If they
had the counting operations, this would be a trivial task, but to add
them would open the door to the enormous, ill-conceived complexity of
(no longer) regular expressions as the open source community thinks of
them.

So yes: use other tools, with my apologies.

-rob



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04  0:31         ` Rob Pike
@ 2009-03-04  0:44           ` J.R. Mauro
  2009-03-04  0:56             ` Rob Pike
  2009-03-04  9:41           ` Rudolf Sykora
  1 sibling, 1 reply; 38+ messages in thread
From: J.R. Mauro @ 2009-03-04  0:44 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Tue, Mar 3, 2009 at 7:31 PM, Rob Pike <robpike@gmail.com> wrote:
> Sam and Acme use a simple, pure form of regular expressions.  If they
> had the counting operations, this would be a trivial task, but to add
> them would open the door to the enormous, ill-conceived complexity of
> (no longer) regular expressions as the open source community thinks of
> them.

Do you see utility in counting/movement commands if they are not
combined with regular expressions?

>
> So yes: use other tools, with my apologies.
>
> -rob
>
>



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04  0:44           ` J.R. Mauro
@ 2009-03-04  0:56             ` Rob Pike
  2009-03-04  1:51               ` J.R. Mauro
  0 siblings, 1 reply; 38+ messages in thread
From: Rob Pike @ 2009-03-04  0:56 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

  Do you see utility in counting/movement commands if they are not
  combined with regular expressions?

If you want to make a substitution to the thousandth match of a
regular expression on a line, try

   s1000/[^	]+/yyy/

But to navigate to that place is not as straightforward. Counting only
works for characters and lines.

-rob



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04  0:56             ` Rob Pike
@ 2009-03-04  1:51               ` J.R. Mauro
  2009-03-04  2:15                 ` Rob Pike
  0 siblings, 1 reply; 38+ messages in thread
From: J.R. Mauro @ 2009-03-04  1:51 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Tue, Mar 3, 2009 at 7:56 PM, Rob Pike <robpike@gmail.com> wrote:
>  Do you see utility in counting/movement commands if they are not
>  combined with regular expressions?
>
> If you want to make a substitution to the thousandth match of a
> regular expression on a line, try
>
>   s1000/[^     ]+/yyy/
>
> But to navigate to that place is not as straightforward. Counting only
> works for characters and lines.

I meant more along the lines of adding in movement commands, so you
could do something like 1000w to move to the 1000th
(whitespace-delimited) word. There are also other "abstractions" like
blocks, sentences, pages, etc.

I'm not extremely adept with Acme and Sam, but it might also be useful
to have something like 1000y to copy 1000 lines without having to
select and scroll across them all. Of course this is a contrived
example, and as I said, I'm a bit ignorant as to whether the editors
already have something like this, but that's the thing I was wondering
if you found useful, or if you have a better alternative available in
Acme and Sam.

>
> -rob
>
>



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04  1:51               ` J.R. Mauro
@ 2009-03-04  2:15                 ` Rob Pike
  2009-03-04  4:59                   ` J.R. Mauro
  0 siblings, 1 reply; 38+ messages in thread
From: Rob Pike @ 2009-03-04  2:15 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

.,.1000

and then snarf.

It's a different model from the one you are familiar with.  That is
not a value judgment either way, but before pushing too hard in
comparisons or suggestions it helps to be familiar with both.

-rob



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04  2:15                 ` Rob Pike
@ 2009-03-04  4:59                   ` J.R. Mauro
  0 siblings, 0 replies; 38+ messages in thread
From: J.R. Mauro @ 2009-03-04  4:59 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Tue, Mar 3, 2009 at 9:15 PM, Rob Pike <robpike@gmail.com> wrote:
> .,.1000
>
> and then snarf.
>
> It's a different model from the one you are familiar with.  That is
> not a value judgment either way, but before pushing too hard in
> comparisons or suggestions it helps to be familiar with both.

I understand, I didn't really want to press the issue because I'm not
that familiar with Acme. It just seemed to me that having both modes
available would be useful. As much as cursor address movement
practically goes out the window with the ability to use a mouse, it
does seem natural to go "move forward 5 sentences/paragraphs/blocks",
but I suppose you'd need modal editing for that, which would clash
pretty badly with Acme.

>
> -rob
>



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04  0:31         ` Rob Pike
  2009-03-04  0:44           ` J.R. Mauro
@ 2009-03-04  9:41           ` Rudolf Sykora
  2009-03-04  9:52             ` Rob Pike
                               ` (2 more replies)
  1 sibling, 3 replies; 38+ messages in thread
From: Rudolf Sykora @ 2009-03-04  9:41 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> Sam and Acme use a simple, pure form of regular expressions.  If they
> had the counting operations, this would be a trivial task, but to add
> them would open the door to the enormous, ill-conceived complexity of
> (no longer) regular expressions as the open source community thinks of
> them.

Is it really so? R. Cox (Regular Expression Matching Can Be Simple And
Fast), I think, shows, that repetition can be first expanded and then
used even by the nice (non-backtracking) algorithms, like this:

e{3} --> eee
e{3,5} --> eeee?e?
e{3,} --> eee+

where would the problem arise?

Thanks
Ruda

>
> So yes: use other tools, with my apologies.
>
> -rob



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04  9:41           ` Rudolf Sykora
@ 2009-03-04  9:52             ` Rob Pike
  2009-03-04 11:32               ` Rudolf Sykora
  2009-03-04 13:37             ` erik quanstrom
  2009-03-04 17:03             ` Russ Cox
  2 siblings, 1 reply; 38+ messages in thread
From: Rob Pike @ 2009-03-04  9:52 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Not all the features adapt as easily.

-rob



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04  9:52             ` Rob Pike
@ 2009-03-04 11:32               ` Rudolf Sykora
  2009-03-04 13:31                 ` Uriel
  0 siblings, 1 reply; 38+ messages in thread
From: Rudolf Sykora @ 2009-03-04 11:32 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

2009/3/4 Rob Pike <robpike@gmail.com>:
> Not all the features adapt as easily.
>
> -rob

By counted repetittion I've  always meant just the mentioned, i.e.
{n}
{n,}
{,m}
{n,m}
.
What feature do you have on mind?

Thanks
Ruda



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04 11:32               ` Rudolf Sykora
@ 2009-03-04 13:31                 ` Uriel
  2009-03-04 13:41                   ` Rudolf Sykora
  2009-03-04 16:35                   ` John Stalker
  0 siblings, 2 replies; 38+ messages in thread
From: Uriel @ 2009-03-04 13:31 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

>From earlier in this thread:

"Sam and Acme use a simple, pure form of regular expressions. If they
had the counting operations, this would be a trivial task, but to add
them would open the door to the enormous, ill-conceived complexity of
(no longer) regular expressions as the open source community thinks of
them."

So, if you want counting, you can always write a patch, who knows, it
might even be accepted.

But I think that anyone not under the influence of psychedelic
substances that has suffered PCR, will agree we don't want to move in
that direction, and even if small, counting is a step in that
direction.

I personally rarely have use for it, and when I do, it is trivial to
write a script to generate the desired regexp, and I'm eternally
grateful for being free from Perl-induced psychosis.

uriel

On Wed, Mar 4, 2009 at 12:32 PM, Rudolf Sykora <rudolf.sykora@gmail.com> wrote:
> 2009/3/4 Rob Pike <robpike@gmail.com>:
>> Not all the features adapt as easily.
>>
>> -rob
>
> By counted repetittion I've  always meant just the mentioned, i.e.
> {n}
> {n,}
> {,m}
> {n,m}
> .
> What feature do you have on mind?
>
> Thanks
> Ruda
>
>



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04  9:41           ` Rudolf Sykora
  2009-03-04  9:52             ` Rob Pike
@ 2009-03-04 13:37             ` erik quanstrom
  2009-03-04 14:14               ` Rudolf Sykora
  2009-03-04 17:03             ` Russ Cox
  2 siblings, 1 reply; 38+ messages in thread
From: erik quanstrom @ 2009-03-04 13:37 UTC (permalink / raw)
  To: 9fans

> > Sam and Acme use a simple, pure form of regular expressions.  If they
> > had the counting operations, this would be a trivial task, but to add
> > them would open the door to the enormous, ill-conceived complexity of
> > (no longer) regular expressions as the open source community thinks of
> > them.
>
> Is it really so? R. Cox (Regular Expression Matching Can Be Simple And
> Fast), I think, shows, that repetition can be first expanded and then
> used even by the nice (non-backtracking) algorithms, like this:
>
> e{3} --> eee
> e{3,5} --> eeee?e?
> e{3,} --> eee+
>
> where would the problem arise?

adding repetition would break many previously-
working regular expressions (any with '{').  a
command line switch to all programs using regular
expressions would be unacceptable.  putting that
aside and getting to the heart of the question....

this is plan 9.  we don't ask if new feature
x would not cause a problem, we ask if x
would make plan 9 a better system.  i'm
quite sure one would be wrong in assuming
that plan 9's designers did not know about
repetition.  i think it would be safer to assume
they were not keen on the idea.

- erik



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04 13:31                 ` Uriel
@ 2009-03-04 13:41                   ` Rudolf Sykora
  2009-03-04 16:35                   ` John Stalker
  1 sibling, 0 replies; 38+ messages in thread
From: Rudolf Sykora @ 2009-03-04 13:41 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> "Sam and Acme use a simple, pure form of regular expressions. If they
> had the counting operations, this would be a trivial task, but to add
> them would open the door to the enormous, ill-conceived complexity of
> (no longer) regular expressions as the open source community thinks of
> them."
>
> So, if you want counting, you can always write a patch, who knows, it
> might even be accepted.
>
> But I think that anyone not under the influence of psychedelic
> substances that has suffered PCR, will agree we don't want to move in
> that direction, and even if small, counting is a step in that
> direction.
>
> I personally rarely have use for it, and when I do, it is trivial to
> write a script to generate the desired regexp, and I'm eternally
> grateful for being free from Perl-induced psychosis.
>
> uriel

Isn't it just easier to answer the questions? ...
this is just like bla... bla... bla...
sorry, but being such doesn't shed any light on the subject...
Ruda



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04 13:37             ` erik quanstrom
@ 2009-03-04 14:14               ` Rudolf Sykora
  2009-03-04 14:37                 ` erik quanstrom
  2009-03-04 16:34                 ` Steve Simon
  0 siblings, 2 replies; 38+ messages in thread
From: Rudolf Sykora @ 2009-03-04 14:14 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> this is plan 9.  we don't ask if new feature
> x would not cause a problem, we ask if x
> would make plan 9 a better system.

well, no-one disputes the claim, if you read twice.

> i'm
> quite sure one would be wrong in assuming
> that plan 9's designers did not know about
> repetition.  i think it would be safer to assume
> they were not keen on the idea.

I don't assume anything, while you do. What if they just didn't need
it and followed the idea of simplicity?

The result of this discussion basically has been: neither acme nor sam
is suited for the original problem, there is no simple way present in
plan9 allowing you to edit such files with long lines, which are quite
commonly and with justification present in the world. Only Vim, which
was ported to plan9, with its regexps, can do it gracefully. Thus if
you want to edit a file, you are forced to use bloated regexps present
in Vim. Isn't it sad being in plan9?! Things should be simple, but not
simpler than that.

Ruda



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04 14:14               ` Rudolf Sykora
@ 2009-03-04 14:37                 ` erik quanstrom
  2009-03-04 14:59                   ` Rudolf Sykora
  2009-03-04 16:34                 ` Steve Simon
  1 sibling, 1 reply; 38+ messages in thread
From: erik quanstrom @ 2009-03-04 14:37 UTC (permalink / raw)
  To: 9fans

> The result of this discussion basically has been: neither acme nor sam
> is suited for the original problem, there is no simple way present in
> plan9 allowing you to edit such files with long lines, which are quite
> commonly and with justification present in the world. Only Vim, which
> was ported to plan9, with its regexps, can do it gracefully. Thus if
> you want to edit a file, you are forced to use bloated regexps present
> in Vim. Isn't it sad being in plan9?! Things should be simple, but not
> simpler than that.

i disagree with your premise that only vim has the vigor to
modify your super special file.  all you need is f and f*.
f transforms your source into something easy to edit in acme.
f* transforms it back into the original form.  easy peasy.
or, you can write a simple program that edits the file
directly.  there are so many ways to do this, and i'm just
too lazy to list them all.

- erik



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04 14:37                 ` erik quanstrom
@ 2009-03-04 14:59                   ` Rudolf Sykora
  0 siblings, 0 replies; 38+ messages in thread
From: Rudolf Sykora @ 2009-03-04 14:59 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> i disagree with your premise that only vim has the vigor to
> modify your super special file.  all you need is f and f*.
> f transforms your source into something easy to edit in acme.
> f* transforms it back into the original form.  easy peasy.
> or, you can write a simple program that edits the file
> directly.  there are so many ways to do this, and i'm just
> too lazy to list them all.
>
> - erik

Alright. Such 'f, f*'  has already been proposed and shown, most
clearly, by yy at the beginning of this thread.
I agree it is functional and perhaps sufficient for now.
Let's consider this finished.
(Until I come up with some even more compelling argument in favor of
counted repetition...)

Ruda



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04 14:14               ` Rudolf Sykora
  2009-03-04 14:37                 ` erik quanstrom
@ 2009-03-04 16:34                 ` Steve Simon
  1 sibling, 0 replies; 38+ messages in thread
From: Steve Simon @ 2009-03-04 16:34 UTC (permalink / raw)
  To: 9fans

> Isn't it sad being in plan9?! Things should be simple, but not
> simpler than that.

I am not sad being in plan9 [sic].

I have used it as my main OS for about eight years and I have used sam
exclusively for ten. During that time I cannot remember ever needing
or wanting repeat counts on regular expressions.

Structural regular expressions have intrigued me since the paper was
published but they still await somone with the time and inclination.

-Steve (happy in plan9).



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04 13:31                 ` Uriel
  2009-03-04 13:41                   ` Rudolf Sykora
@ 2009-03-04 16:35                   ` John Stalker
  2009-03-04 16:56                     ` ron minnich
  1 sibling, 1 reply; 38+ messages in thread
From: John Stalker @ 2009-03-04 16:35 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> But I think that anyone not under the influence of psychedelic
> substances that has suffered PCR, will agree we don't want to move in
> that direction, and even if small, counting is a step in that
> direction.

Your feelings are understandable, given the horror of pcre, but
in this case they are irrational.  pcre is an atrocity for two
reasons: (1) it is badly implemented and (2) it changes the
family of languages which can be matched by regular expressions.
In fact (1) is more or less a consequence of (2).  Adding counts
would do neither of these, it just makes it a bit easier to
and more natural to describe some languages in the class.

There are sane objections to adding counts, but I don't think
this is really one of them.
--
John Stalker
School of Mathematics
Trinity College Dublin
tel +353 1 896 1983
fax +353 1 896 2282



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04 16:35                   ` John Stalker
@ 2009-03-04 16:56                     ` ron minnich
  0 siblings, 0 replies; 38+ messages in thread
From: ron minnich @ 2009-03-04 16:56 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I still don't get the discussion. This is a research system. People
want something. So implement that feature and see how it goes!

Report when done :-)

ron



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [9fans] command repetition in sam/acme
  2009-03-04  9:41           ` Rudolf Sykora
  2009-03-04  9:52             ` Rob Pike
  2009-03-04 13:37             ` erik quanstrom
@ 2009-03-04 17:03             ` Russ Cox
  2 siblings, 0 replies; 38+ messages in thread
From: Russ Cox @ 2009-03-04 17:03 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> Is it really so? R. Cox (Regular Expression Matching Can Be Simple And
> Fast), I think, shows, that repetition can be first expanded and then
> used even by the nice (non-backtracking) algorithms, like this:
>
> e{3} --> eee
> e{3,5} --> eeee?e?
> e{3,} --> eee+
>
> where would the problem arise?

The problem arises mainly not in this construct
but in the tremendous number of other
constructs that regexp libraries with counted
repetition usually throw in along with it.

That said, even counted repetition is not free.
Even if sam/acme had counted repetition,
it would not handle x{1000} particularly well,
since the expansion you give above would
end up being a very long regular expression
for non-trivial x.

R. Cox


^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2009-03-04 17:03 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-03 12:07 [9fans] command repetition in sam/acme Rudolf Sykora
2009-03-03 12:49 ` Steve Simon
2009-03-03 13:53   ` Rudolf Sykora
2009-03-03 15:40     ` roger peppe
2009-03-03 15:58       ` yy
2009-03-03 16:25         ` Rudolf Sykora
2009-03-03 15:58       ` Uriel
2009-03-03 15:59         ` Uriel
2009-03-03 14:15 ` John Stalker
2009-03-03 14:23   ` Rudolf Sykora
2009-03-03 16:09 ` Russ Cox
2009-03-03 16:31   ` roger peppe
2009-03-03 17:16     ` Uriel
2009-03-03 18:50       ` Rudolf Sykora
2009-03-03 16:39   ` Rudolf Sykora
2009-03-03 20:30   ` Arvindh Rajesh Tamilmani
2009-03-03 22:13     ` ron minnich
2009-03-03 23:19       ` J.R. Mauro
2009-03-03 23:37       ` Anthony Sorace
2009-03-04  0:31         ` Rob Pike
2009-03-04  0:44           ` J.R. Mauro
2009-03-04  0:56             ` Rob Pike
2009-03-04  1:51               ` J.R. Mauro
2009-03-04  2:15                 ` Rob Pike
2009-03-04  4:59                   ` J.R. Mauro
2009-03-04  9:41           ` Rudolf Sykora
2009-03-04  9:52             ` Rob Pike
2009-03-04 11:32               ` Rudolf Sykora
2009-03-04 13:31                 ` Uriel
2009-03-04 13:41                   ` Rudolf Sykora
2009-03-04 16:35                   ` John Stalker
2009-03-04 16:56                     ` ron minnich
2009-03-04 13:37             ` erik quanstrom
2009-03-04 14:14               ` Rudolf Sykora
2009-03-04 14:37                 ` erik quanstrom
2009-03-04 14:59                   ` Rudolf Sykora
2009-03-04 16:34                 ` Steve Simon
2009-03-04 17:03             ` Russ Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).