9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Arvindh Rajesh Tamilmani" <arvindht@gmail.com>
To: 9fans@cse.psu.edu
Subject: [9fans] rectangle dot in acme
Date: Sat, 21 Oct 2006 23:05:02 +0100	[thread overview]
Message-ID: <c4a46c570610211505h39623aa5h4cbef78f0516edd0@mail.gmail.com> (raw)

The script below (called rect) partially implements kill-rectangle and
string-rectangle commands from emacs.  For example, select :/-a/,/-b/
in an acme window containing the following lines:

/bin/bind -a '#L' /dev >/dev/null >[2=1]
/bin/bind -a '#w1' /dev >/dev/null >[2=1]
/bin/bind -a '#t' /dev >/dev/null >[2=1]
/bin/bind -b '#A' /dev >/dev/null >[2=1]

Now 2-1 chord on rect deletes the options to bind.  2-1 on "rect -b"
replaces the options to bind with -b.  This can be achieved using Edit
but I found these shortcuts quite handy in emacs while extracting
columns of data from log files.

Comments welcome.
Thanks.
Arvindh

P.S. The script doesn't work in an unnamed acme window - $acmeaddr is
unset in that case.

#!/bin/rc

if(~ $acmeaddr '')
	exit 'nil acmeaddr'

if(~ $#* 2)
	repl=$1

cd /mnt/acme/$winid

p=`{echo $acmeaddr | sed 's/.*#(.*),#(.*)/\1 \2/'}
p1=$p(1)
p2=$p(2)

q=`{sam -d body >[2=1] <<! | tr -d '.body;#-'}
#$p1-+x/^/=
#$p2-+x/^/=
!

pre=`{echo $p1-$q(2) | bc}
row=`{echo $p2-$q(4)-$pre | bc}
prere=`{seq -f. 1 $pre | tr -d $ifs}
rowre=`{seq -f. 1 $row | tr -d $ifs}

echo -n '0,$' >addr
sed $q(1)^,$q(3)^'s/(^'$"prere')(.*|('$"rowre'(.*)))/\1'$"repl'\4/' body >data


                 reply	other threads:[~2006-10-21 22:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=c4a46c570610211505h39623aa5h4cbef78f0516edd0@mail.gmail.com \
    --to=arvindht@gmail.com \
    --cc=9fans@cse.psu.edu \
    /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).