Re: [9fans] sam, shorten dot by 1 line
On 6 August 2012 17:05, Rob Pike wrote: > Empty dot at the beginning of a line is also empty dot at the end of > the previous line. This is odd, but one can live with that once they know. Nonetheless, It should be written somewhere (man page?). > > I'm not justifying the behavior, just explaining it. This is really > old code with, I admit, some quirky properties. I often think of > rewriting the address code in sam and acme but never do, because a > rewrite would change the behavior of corner cases and break people's > scripts. Still I think things should not stay 'wrong' just because other scripts have been adjusted to the behaviour. I spent quite some time finding out why my new script didn't sometimes work. It was kind of natural to expect that the dot is on the line on which it is drawn to be. Ruda
Re: [9fans] sam, shorten dot by 1 line
Empty dot at the beginning of a line is also empty dot at the end of the previous line. I'm not justifying the behavior, just explaining it. This is really old code with, I admit, some quirky properties. I often think of rewriting the address code in sam and acme but never do, because a rewrite would change the behavior of corner cases and break people's scripts. Let's move on. -rob
Re: [9fans] sam, shorten dot by 1 line
On Mon, Aug 06, 2012 at 09:04:13AM +0200, Rudolf Sykora wrote: > > This pertains to the example I gave: > > Having > > | asdfasdf asdfasdf asdfasdf asdfasdfa asfdsfasdf > > where | represents an empty dot at the beginning of a line (line as > drawn in the editor), .+0 does nothing. According to what .+0 should > do, I'd expect it should select the whole line. I'm definitively not an expert, but I always thought that there was only one legitimate direction of the stream or the string i.e. the direction of the sequence (addressing lines "3,2" is not legitimate). If this is handled like a circular buffer, with only one legitimate direction, .+0 goes from the end to the beginning, but in the correct direction in the circular buffer, and selects nothing (since next to end you have dot). Hoping not saying too much nonsense. -- Thierry Laronde http://www.kergis.com/ Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C
Re: [9fans] sam, shorten dot by 1 line
On 6 August 2012 02:52, Rob Pike wrote: > .+0 goes from the end of the current value of dot to the end of the > line containing dot. > .-0 goes from the beginning of the line containing dot to the > beginning of the current value of dot. Yes, this is what I thought. (But is different from what you initially wrote.) > I don't understand your second question. > > -rob This pertains to the example I gave: Having | asdfasdf asdfasdf asdfasdf asdfasdfa asfdsfasdf where | represents an empty dot at the beginning of a line (line as drawn in the editor), .+0 does nothing. According to what .+0 should do, I'd expect it should select the whole line. Thanks! Ruda
Re: [9fans] sam, shorten dot by 1 line
.+0 goes from the end of the current value of dot to the end of the line containing dot. .-0 goes from the beginning of the line containing dot to the beginning of the current value of dot. I don't understand your second question. -rob
Re: [9fans] sam, shorten dot by 1 line
Hello 9fans, could at least somebody comment on the situation I observe? I.e., what exactly .+0 means, and why the empty dot at a very beginning of a line (as seen in the editor) seems to actually not be on the line? Thanks Ruda
Re: [9fans] sam, shorten dot by 1 line
On 2 August 2012 00:21, Rob Pike wrote: > .,.+0 means: from the beginning of . to the end of .+0, and .+0 is the > null string at the end of . It just does not work for me like that. (.+#0 seems to do what you describe.) 1) Having a line asdfasdf asdfasdf asdfasdf | asdfasdfa asfdsfasdfa where | represents the current (emty) dot, .+0 selects everything to the right from the original dot to the end of the line, including the newline. 2) Having | asdfasdf asdfasdf asdfasdf asdfasdfa asfdsfasdf .+0 does nothing 3) Having asdfasdf asdfasdf asdfasdf asdfasdfa asfdsfasdf | .+0 selects the newline, and next .+0 selects the empty dot on the beginning of the next line, like what we start from in the case 2). This behaviour, along with the mentioned behaviour of +-, where for | asdfasdf asdfasdf asdfasdf asdfasdfa asfdsfasdf +- selects the previous line while for asdfasdf asdfasdf asdfasdf | asdfasdfa asfdsfasdfa it selects the current line still stays ununderstood by me... (and the last example is contraintuitive). [sideremark: -+ works even when the empty dot is on the first and last line of the file, the latter being a problem for +-, which is a strange asymmetry. How should one then select the line on which a possibly multiline dot ends and at the same time this is the last line in the file (which however, you do not have to know if this happens under some loop command)?] Any more explanation is highly welcome! Ruda
Re: [9fans] sam, shorten dot by 1 line
Break it down: a,b means: from the beginning of a to the end of b .,. means: from the beginning of . to the end of . 1 means: from the beginning of line 1 to the end of line 1. .,.+0 means: from the beginning of . to the end of .+0, and .+0 is the null string at the end of . Now the step: .,.+0-1 means: from the beginning of . to the end of .+0-1, which means the end of the line preceding the null string at the end of ., which ends right back at .+0, so it means the last line of ., so this doesn't work. .,.+0-2 means: from the beginning of . to the end of .+0-2, which means the end of the second line preceding .+0, which is one line back from the end. QED. The key observation is that on the right of the comma you're talking about where the address *ends*. -rob
Re: [9fans] sam, shorten dot by 1 line
On 1 August 2012 18:37, Rudolf Sykora wrote: > .,.+0- It seems a related question is: why +- behaves differently when I am somewhere in the middle of a line (the whole line is then a dot) and when I am at the very beginning of a line (then the *previous* line is selected)... Thanks! Ruda
Re: [9fans] sam, shorten dot by 1 line
On 1 August 2012 21:09, Rob Pike wrote: > -#0,+#0-2 This really does not answer the question, neither helps to understand. Thanks anyway. Ruda
Re: [9fans] sam, shorten dot by 1 line
-#0,+#0-2 (go from the null string at the beginning to the null string at the end of the line starting two lines back from the end.) -rob