9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: smiley@icebubble.org
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] anchors broken in the g command in sam on p9p?
Date: Wed, 21 Aug 2013 17:19:18 +0000	[thread overview]
Message-ID: <86mwobarmx.fsf@cmarib.ramside> (raw)
In-Reply-To: <CAKzdPgws8btaBRTMXtSusE8DWNyQAEYUACu64QNSm5pM-GiPcA@mail.gmail.com> (Rob Pike's message of "Wed, 21 Aug 2013 16:45:18 +1000")

Rob Pike <robpike@gmail.com> writes:

> Nothing. That's exactly what ^ and $ do.
>

OK.  How does one match the start/end of dot in a g// or v// regexp?

> -rob
>

Wait, Rob Pike?  That "Rob Pike?"  As in the guy who wrote the program?
How fortuitous.  :)

I read your paper on sam, as well as the tutorial, and I understand the
examples, but I'm having trouble figuring out how to use sam for Real
Work(TM).  Every time I try to, I get unexpected results: either an
error message, or something I didn't expect.  One thing that I'm having
trouble with is figuring out how to SHRINK dot.  Expanding dot (by
regexp search) is easy:

,c/this is a line of letters/
,x/l..e/p
line
,x/(a|the) l..e [a-zA-Z]+/p
a line of

But if I want to shrink dot, say to just those two (..) characters, how
can I do it?  I could y/l/, but I'd need a way to detect on which "l"
dot is being split.  To wit, there is also an "l" matched by [a-zA-Z].

One of the things I had difficulty figuring out was how dot behaves
between subcommands in a compound command:

,c

this is some text for sam
to edit using commands in
a command block, to see
whether or not dot is passed
from command to subsequent command
within the block

.
,x/(.+\n)+/ y/command/ {
  /[ \n][a-zA-Z]+/-/[ \n][a-zA-Z]+/-/[ \n][a-zA-Z]+/-/[ \n][a-zA-Z]+/d
  a/X/
}

The docs don't state explicitly how dot changes (or doesn't change)
between subcommands.  The tutorial says that "{" sets dot for each
subcommand, but doesn't reveal that "{" resests dot *to the same thing*
for each subcommand.  As this example shows, a d// followed by an a// is
not the same as a c//, because dot is reset between subcommands.

A number of sources on the Interweb state that you use sam as your
preferred editor.  Maybe that's easier if happen to be the person who
wrote the program.  :) I though that, perhaps, acme might be more
usable, but the acme docs state that it implements the same command set
as sam (with the exception of the k, n, q, !, and = commands).  Do you
still use sam as your day-to-day editor?  Or have you switched to
ema^H^H^Hacme?

Another feature (limitation?) of sam is that changes made by subcommands
must be in left-to-right order.  IIRC, the acme docs mentioned something
about sorting changes to the file in order to implement its Undo and
Redo functions.  Does the sam-like editing in acme have the same
left-to-right limitation?  I figure, if anyone would know, it would be
the person who wrote acme, too.  :)

The use of structural regular expressions looks like it could be very
expressive and, ultimately, very useful.  It would be great if I could
figure out how to use sam (or acme, if it's any better) for real life
work.

Thanks!  (...for you help ...and for writing this infernal program in
the first place ;) )
--
+---------------------------------------------------------------+
|Smiley       <smiley@icebubble.org>    PGP key ID:    BC549F8B |
|Fingerprint: 9329 DB4A 30F5 6EDA D2BA  3489 DAB7 555A BC54 9F8B|
+---------------------------------------------------------------+



  reply	other threads:[~2013-08-21 17:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-21  5:11 smiley
2013-08-21  6:45 ` Rob Pike
2013-08-21 17:19   ` smiley [this message]
2013-08-22  6:24     ` Rudolf Sykora
2013-08-22  9:35       ` Rob Pike
2013-08-22 17:03     ` smiley
2013-08-25  7:58       ` Erez Schatz
2013-09-02  0:52         ` smiley
2013-08-21 20:14 ` Rudolf Sykora
2013-08-21 20:23   ` Rudolf Sykora

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=86mwobarmx.fsf@cmarib.ramside \
    --to=smiley@icebubble.org \
    --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).