From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <82380754-4ab1-4c31-b696-0b9c604ec2c9@googlegroups.com> References: <82380754-4ab1-4c31-b696-0b9c604ec2c9@googlegroups.com> Date: Thu, 4 Apr 2013 14:16:10 +0200 Message-ID: From: =?UTF-8?B?QmVuY2UgRsOhYmnDoW4=?= To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=14dae9340ee796118b04d987ef87 Subject: Re: [9fans] Acme Edit scriptlets Topicbox-Message-UUID: 3d6d237e-ead8-11e9-9d60-3106f5b1d025 --14dae9340ee796118b04d987ef87 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cool. Here's a script i use to generate case insensitive regexes. It turns FooBar into [Ff][Oo][Oo][Bb][Aa][Rr] term% cat /bin/uncase #!/bin/rc exec awk '{ lower =3D tolower($0) upper =3D toupper($0) len =3D length($0) for( i =3D 1 ; i <=3D len ; i++ ) printf "[" substr(upper, i, 1) substr(lower, i, 1) "]" printf "\n" }' 2013/4/4 Mark van Atten > On Friday, 29 March 2013 01:38:06 UTC+1, Bence F=C3=A1bi=C3=A1n wrote: > > > I did a quick writeup on little Edit scripts > > Many thanks, this thread is very useful. > > There is also Jason Catena's list of Edit idioms at > https://raw.github.com/catenate/acme-fonts/master/test/1/acme/Edit/sam > > When editing and re-editing latex, I regularly pipe selections > through a simple-minded script called `chunk' which does most of > the work for obtaining semantic linebreaks. That goes back to a > recommendation by Kernighan in his paper `Unix for beginners' of > 1974; see the quotation, comments and link at [1]. > > > > #!/usr/local/plan9/bin/rc > # chunk up (to prepare) for semantic linebreaks > > # do not break within \cite > # do not break within $$ math > # break after closing parentheses ),] > # break before an opening parentheses (,[ > > ssam -e 'x/(^[^%].+\n)+/ y/\\cite[^{]*{(\n|.)*}/ y/\$.*\$/ > x/(([^A-Z]\.)|[,;:!?]|\)|\]) | (\(|\[)/ s/ /\n/' \ | 9 fmt -w 60 > -j > > > For batch processing probably something more sophisticated would > be needed to leave various environments unchunked. But I don't use > it that way, and just apply it to selections where I know its use > makes sense. Usually these are areas where I have just been doing > a lot of rewriting. > > There's no point in chunking up commented material, and sometimes > it is actually convenient to have a place where I can keep things > unchunked for reference. > > The original chunk command in Writer's Workbench [2], for troff not > latex, was based on a parser for English, I think. I find I don't > want that (because I write in other languages as well), and that > even in English I don't need it (because the chunking based on > interpunction is always fine with me, and where I care about the > remaining cases, I prefer to do it myself; but see [3]). > > Mark. > > > [1] http://rhodesmill.org/brandon/2012/one-sentence-per-line/ > > [2] http://man.cat-v.org/unix_WWB/1/chunk > > [3] https://github.com/waldir/semantic-linebreaker > > --14dae9340ee796118b04d987ef87 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Cool.


Here's a= script i use to generate case
insensitive regexes. It turn= s

FooBar

into

[Ff][Oo][Oo][Bb][Aa][Rr]
=
term% cat /bin/uncase
#!/bin/rc

exec awk '{
lower =3D tolower($0)
upper =3D toupper($= 0)
len =3D len= gth($0)

for( i =3D 1 ; i <=3D len ; i++ )
printf "[&quo= t; substr(upper, i, 1) substr(lower, i, 1) "]"
printf "\n"
= }'



2013/4/4 Mark van Atten <= vanattenmark@gm= ail.com>
On Friday, 29 March 2013 01:38:06 UTC+1,= Bence F=C3=A1bi=C3=A1n =C2=A0wrote:

> I did a quick writeup on little Edit scripts

Many thanks, this thread is very useful.

There is also Jason Catena's list of Edit idioms at
https://raw.github.com/catenate/acme-fonts/master= /test/1/acme/Edit/sam

When editing and re-editing latex, I regularly pipe selections
through a simple-minded script called `chunk' which does most of
the work for obtaining semantic linebreaks. That goes back to a
recommendation by Kernighan in his paper `Unix for beginners' of
1974; see the quotation, comments and link at [1].



#!/usr/local/plan9/bin/rc
# chunk up (to prepare) for semantic linebreaks

# do =C2=A0not break within \cite
# do not break within $$ math
# break after closing parentheses ),]
# break before an opening parentheses (,[

ssam -e 'x/(^[^%].+\n)+/ =C2=A0y/\\cite[^{]*{(\n|.)*}/ y/\$.*\$/
x/(([^A-Z]\.)|[,;:!?]|\)|\]) | (\(|\[)/ s/ /\n/' \ | 9 fmt -w 60
-j


For batch processing probably something more sophisticated would
be needed to leave various environments unchunked. But I don't use
it that way, and just apply it to selections where I know its use
makes sense. Usually these are areas where I have just been doing
a lot of rewriting.

There's no point in chunking up commented material, and sometimes
it is actually convenient to have a place where I can keep things
unchunked for reference.

The original chunk command in Writer's Workbench [2], for troff not
latex, was =C2=A0based on a parser for English, I think. I find I don't=
want that (because I write in other languages as well), and that
even in English I don't need it (because the chunking based on
interpunction is always fine with me, and where I care about the
remaining cases, I prefer to do it myself; but see [3]).

Mark.


[1] http://rhodesmill.org/brandon/2012/one-sentence-per-line/<= /a>

[2]
htt= p://man.cat-v.org/unix_WWB/1/chunk

[3] https://github.com/waldir/semantic-linebreaker


--14dae9340ee796118b04d987ef87--