9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] sam, shorten dot by 1 line
@ 2012-08-01 16:37 Rudolf Sykora
  2012-08-01 19:09 ` Rob Pike
  2012-08-01 20:51 ` Rudolf Sykora
  0 siblings, 2 replies; 12+ messages in thread
From: Rudolf Sykora @ 2012-08-01 16:37 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hello,

having a multiline dot in sam, I wanted to shorten it by one line at
its end. I tried
.,.+0-
which did not work. I had to write
.,.+1-2
or, hopefully equivalently
.,.+-2

While I understand how the latter two ways work, I do not understand
why the first does not.
Can anybody tell me?
Thanks
Ruda



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

* Re: [9fans] sam, shorten dot by 1 line
  2012-08-01 16:37 [9fans] sam, shorten dot by 1 line Rudolf Sykora
@ 2012-08-01 19:09 ` Rob Pike
  2012-08-01 20:21   ` Rudolf Sykora
  2012-08-01 20:51 ` Rudolf Sykora
  1 sibling, 1 reply; 12+ messages in thread
From: Rob Pike @ 2012-08-01 19:09 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

-#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



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

* Re: [9fans] sam, shorten dot by 1 line
  2012-08-01 19:09 ` Rob Pike
@ 2012-08-01 20:21   ` Rudolf Sykora
  0 siblings, 0 replies; 12+ messages in thread
From: Rudolf Sykora @ 2012-08-01 20:21 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 1 August 2012 21:09, Rob Pike <robpike@gmail.com> wrote:
> -#0,+#0-2

This really does not answer the question, neither helps to understand.
Thanks anyway.
Ruda



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

* Re: [9fans] sam, shorten dot by 1 line
  2012-08-01 16:37 [9fans] sam, shorten dot by 1 line Rudolf Sykora
  2012-08-01 19:09 ` Rob Pike
@ 2012-08-01 20:51 ` Rudolf Sykora
  2012-08-01 22:21   ` Rob Pike
  1 sibling, 1 reply; 12+ messages in thread
From: Rudolf Sykora @ 2012-08-01 20:51 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 1 August 2012 18:37, Rudolf Sykora <rudolf.sykora@gmail.com> 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



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

* Re: [9fans] sam, shorten dot by 1 line
  2012-08-01 20:51 ` Rudolf Sykora
@ 2012-08-01 22:21   ` Rob Pike
  2012-08-02  8:45     ` Rudolf Sykora
  0 siblings, 1 reply; 12+ messages in thread
From: Rob Pike @ 2012-08-01 22:21 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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



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

* Re: [9fans] sam, shorten dot by 1 line
  2012-08-01 22:21   ` Rob Pike
@ 2012-08-02  8:45     ` Rudolf Sykora
  2012-08-05  8:19       ` Rudolf Sykora
  0 siblings, 1 reply; 12+ messages in thread
From: Rudolf Sykora @ 2012-08-02  8:45 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 2 August 2012 00:21, Rob Pike <robpike@gmail.com> 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



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

* Re: [9fans] sam, shorten dot by 1 line
  2012-08-02  8:45     ` Rudolf Sykora
@ 2012-08-05  8:19       ` Rudolf Sykora
  2012-08-06  0:52         ` Rob Pike
  0 siblings, 1 reply; 12+ messages in thread
From: Rudolf Sykora @ 2012-08-05  8:19 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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



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

* Re: [9fans] sam, shorten dot by 1 line
  2012-08-05  8:19       ` Rudolf Sykora
@ 2012-08-06  0:52         ` Rob Pike
  2012-08-06  7:04           ` Rudolf Sykora
  0 siblings, 1 reply; 12+ messages in thread
From: Rob Pike @ 2012-08-06  0:52 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

.+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



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

* Re: [9fans] sam, shorten dot by 1 line
  2012-08-06  0:52         ` Rob Pike
@ 2012-08-06  7:04           ` Rudolf Sykora
  2012-08-06 10:53             ` tlaronde
  0 siblings, 1 reply; 12+ messages in thread
From: Rudolf Sykora @ 2012-08-06  7:04 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 6 August 2012 02:52, Rob Pike <robpike@gmail.com> 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



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

* Re: [9fans] sam, shorten dot by 1 line
  2012-08-06  7:04           ` Rudolf Sykora
@ 2012-08-06 10:53             ` tlaronde
  2012-08-06 15:05               ` Rob Pike
  0 siblings, 1 reply; 12+ messages in thread
From: tlaronde @ 2012-08-06 10:53 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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 <tlaronde +AT+ polynum +dot+ com>
                      http://www.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C



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

* Re: [9fans] sam, shorten dot by 1 line
  2012-08-06 10:53             ` tlaronde
@ 2012-08-06 15:05               ` Rob Pike
  2012-08-10  9:32                 ` Rudolf Sykora
  0 siblings, 1 reply; 12+ messages in thread
From: Rob Pike @ 2012-08-06 15:05 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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



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

* Re: [9fans] sam, shorten dot by 1 line
  2012-08-06 15:05               ` Rob Pike
@ 2012-08-10  9:32                 ` Rudolf Sykora
  0 siblings, 0 replies; 12+ messages in thread
From: Rudolf Sykora @ 2012-08-10  9:32 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 6 August 2012 17:05, Rob Pike <robpike@gmail.com> 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



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

end of thread, other threads:[~2012-08-10  9:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-01 16:37 [9fans] sam, shorten dot by 1 line Rudolf Sykora
2012-08-01 19:09 ` Rob Pike
2012-08-01 20:21   ` Rudolf Sykora
2012-08-01 20:51 ` Rudolf Sykora
2012-08-01 22:21   ` Rob Pike
2012-08-02  8:45     ` Rudolf Sykora
2012-08-05  8:19       ` Rudolf Sykora
2012-08-06  0:52         ` Rob Pike
2012-08-06  7:04           ` Rudolf Sykora
2012-08-06 10:53             ` tlaronde
2012-08-06 15:05               ` Rob Pike
2012-08-10  9:32                 ` Rudolf Sykora

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).