9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: roger peppe <rogpeppe@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] +- in acme
Date: Mon, 19 Apr 2010 17:02:02 +0100	[thread overview]
Message-ID: <n2mdf49a7371004190902q4b07cd24p8c3efd6f5c2cbdc8@mail.gmail.com> (raw)
In-Reply-To: <h2sa560a5d01004190559n5f67cc34y3ba34182346ce43c@mail.gmail.com>

this seems like a bug to me - it doesn't follow the description
in the manual page. the end of the empty selection at the
start of a line is surely within that line.

i had a look at the code, and was surprised by the fact that
the logic appears to implemented in two places;
middle clicking "Edit +" executes lineaddr() where
right clicking ":+" goes through number().

in both cases, the code checks whether the character 1 before
the end of the selection is '\n' which only works if the selection
is non-null.

a simple fix in lineaddr might look like this:

			if(sign==0 || addr.r.q1==0){
				p = 0;
				n = 1;
			}else if(addr.r.q1 > addr.r.q0){
				p = addr.r.q1-1;
				n = textreadc(f->curtext, p++)=='\n';
			}else{
				p = addr.r.q0;
				n = 0;
			}

this issue is made more awkward by the fact that the selection
at the start of a line is included when the line before it is
entirely selected - in some sense it's actually in both lines.

i think it's worth adding a special case for the null selection,
but others' mileages may vary.


On 19 April 2010 13:59, Rudolf Sykora <rudolf.sykora@gmail.com> wrote:
>> the idiom is -+  try + then - one-at-a-time and you'll see why.
>>
>> - erik
>>
>
> Well, ok, -+ works in any case, so it's actually what I usually need.
> Still I don't fully understand.
> The man page says:
>
> Some useful idioms: a1+- (a1-+) selects
> the line containing the end (beginning) of a1.
>
> Isn't it that an empty dot has the same beginning and end?
> Isn't it that my dot (here place 'just before the beginning 'I' of
> this sentence) is on the same line as the 'I' itself?
> Moreover, even if the beginning and end wouldn't be identical for my
> case, I'd still expect that the beginning is before the end... (so
> that +- would have a better chance to match my line!).
>
> Thanks
> Ruda
>
>



      reply	other threads:[~2010-04-19 16:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-19  7:12 Rudolf Sykora
2010-04-19 12:07 ` erik quanstrom
2010-04-19 12:59   ` Rudolf Sykora
2010-04-19 16:02     ` roger peppe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=n2mdf49a7371004190902q4b07cd24p8c3efd6f5c2cbdc8@mail.gmail.com \
    --to=rogpeppe@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).