Re: [9fans] command repetition in sam/acme
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} -- ?e? e{3,} -- eee+ where would the problem arise? Thanks Ruda So yes: use other tools, with my apologies. -rob
Re: [9fans] command repetition in sam/acme
Not all the features adapt as easily. -rob
Re: [9fans] command repetition in sam/acme
2009/3/4 Rob Pike robp...@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
Re: [9fans] command repetition in sam/acme
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.syk...@gmail.com wrote: 2009/3/4 Rob Pike robp...@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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
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).
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
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} -- ?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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
2009/3/3 Rudolf Sykora rudolf.syk...@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.
Re: [9fans] command repetition in sam/acme
awk '{n=n+NF} n1000 {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 rogpe...@gmail.com wrote: 2009/3/3 Rudolf Sykora rudolf.syk...@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.
Re: [9fans] command repetition in sam/acme
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 urie...@gmail.com wrote: awk '{n=n+NF} n1000 {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 rogpe...@gmail.com wrote: 2009/3/3 Rudolf Sykora rudolf.syk...@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.
Re: [9fans] command repetition in sam/acme
2009/3/3 roger peppe rogpe...@gmail.com: 2009/3/3 Rudolf Sykora rudolf.syk...@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 .
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
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,
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
2009/3/3 Russ Cox r...@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!
Re: [9fans] command repetition in sam/acme
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 rogpe...@gmail.com wrote: 2009/3/3 Russ Cox r...@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!
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
On Tue, Mar 3, 2009 at 5:13 PM, ron minnich rminn...@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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
On Tue, Mar 3, 2009 at 7:31 PM, Rob Pike robp...@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
Re: [9fans] command repetition in sam/acme
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
Re: [9fans] command repetition in sam/acme
On Tue, Mar 3, 2009 at 7:56 PM, Rob Pike robp...@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
Re: [9fans] command repetition in sam/acme
.,.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
Re: [9fans] command repetition in sam/acme
On Tue, Mar 3, 2009 at 9:15 PM, Rob Pike robp...@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