From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 29 Mar 2013 09:22:25 +0100 Message-ID: From: "Peter A. Cejchan" To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=089e010d8dde958a4604d90bf8a5 Subject: Re: [9fans] Acme Edit scriptlets Topicbox-Message-UUID: 38c2b1ae-ead8-11e9-9d60-3106f5b1d025 --089e010d8dde958a4604d90bf8a5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks, very nice, mates! I humbly add some of minebelow. Best, ++pac ##### ## Latin =C3=A4=C3=AB=C3=AF=C3=B1=C3=B6=C3=BC=C3=BF=C3=84=C3=85=C3=8B=C3=8F=C3=96=C3= =9C ## Greek =CE=B1=CE=B2=CE=B3=CE=B4=CE=B5=CE=B6=CE=B7=CE=B8=CE=BB=CE=BC=CE=BD=CE=BE=CF= =80=CF=81=CF=83=CF=84=CF=86=CF=88=CF=89=CE=93=CE=94=CE=98=CE=9B=CE=9E=CE=A0= =CE=A3=CE=A6=CE=A8=CE=A9 ## select text :; # select all text :;25 # select from start to line 25 (inclusive) :25; # select from line 25 (inclusive) to EOF Edit /;[ ]*\/\// # select from ; to // comments ## edit text Edit s/^/ /g # increase indentation Edit s,^ ,,g # decrease indentation Edit s/^/\/\/ /g #comment out using // Edit s/\n\n\n+/\n\n/g # remove redundant newlines, keep max two Edit s/^[ ]+//g # remove leading whitespace Edit s/[ ]+$//g # remove trailing whitespace Edit s/ +/ /g # remove multiple spaces Edit s/;$//g # remove trailing semicolon Edit s/\*+\///g # comments Edit s/\/\*+/\/\//g Edit s/[\(\)]/ /g # remove () Edit s/.*/(&)/g # add () Edit s/.*/float64(&)/g # float64() Edit s/.*/} & {/g # add } { Edit s/^/\/\/ /g # // comment out Edit /;[ ]*\/\// Edit s/;// # find and remove semicolon before // comments Edit s/\+\+[a-zA-Z]+[0-9a-zA-Z]*/&++/ Edit s/\+\+/d # NOT WORKING prefix to postfix operator Edit s/->/./g # struct pointer Edit ,s/\+\+([A-Za-z]+[A-Za-z0-9]*)/\1++/g# prefix to postfix operator: ++ Edit ,s/\-\-([A-Za-z]+[A-Za-z0-9]*)/\1--/g# prefix to postfix operator: -- # prefix to postfix operator: ++i --> i++ Edit /\+\+[a-zA-Z_]+[0-9a-zA-Z_]*/{ x/\+\+/d a/++/ } Edit s/\+\+([A-Za-z]+[A-Za-z0-9]*)/\1++/ # prefix to postfix operator: ++i --> i++ | 9 sed 's/\(//; s/(.*)\)/\1/' # remove outermost pair of parentheses Edit s:\((.*)\):\1:g # remove outermost pair of parentheses On Fri, Mar 29, 2013 at 2:19 AM, wrote: > > Hi! > > > > I did a quick writeup on little Edit scripts > > (well basicly sam(1) scripts) > > If anyone have more feel free to contribute. > > Maybe someone could put them on the wiki even. > > Nice idea... > > Here's a simple awk bit I use in Acme for centering text (its name is > the center-line rune: =E2=84=84) > > #!/bin/rc > # Center text > awk '{l=3Dlength();s=3Dint((70-l)/2); printf "%"(s+l)"s\n",$0}' > > It doesn't seem to be common practice, but I like to name editing > commands with unicode runes to save room: i.e. =E2=86=90 and =E2=86=92 f= or > indentation (used with code), or =E2=87=90 and =E2=87=92 for indentation = + a reformat > (used for natural language next). I find they serve a bit like icons. > > > --089e010d8dde958a4604d90bf8a5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thanks, very nice, mates!
I humbly add some of minebelow.
Best, ++pac=

#####
## Latin
=C3=A4=C3=AB=C3=AF=C3=B1=C3=B6=C3=BC=C3=BF=C3= =84=C3=85=C3=8B=C3=8F=C3=96=C3=9C

## Greek
=CE=B1=CE=B2=CE=B3=CE= =B4=CE=B5=CE=B6=CE=B7=CE=B8=CE=BB=CE=BC=CE=BD=CE=BE=CF=80=CF=81=CF=83=CF=84= =CF=86=CF=88=CF=89=CE=93=CE=94=CE=98=CE=9B=CE=9E=CE=A0=CE=A3=CE=A6=CE=A8=CE= =A9

## select text

:;=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 # = select all text
:;25=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 # select from start to line 25 (i= nclusive)
:25;=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 # select from line 2= 5 (inclusive) to EOF
Edit /;[ =C2=A0=C2=A0=C2=A0 ]*\/\//=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 # select from ; to // comments


## edit te= xt
Edit s/^/=C2=A0=C2=A0=C2=A0 /g=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 #= increase indentation
Edit s,^=C2=A0=C2=A0=C2=A0 ,,g=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 # decre= ase indentation
Edit s/^/\/\/ /g=C2=A0=C2=A0=C2=A0 #comment out using //=

Edit s/\n\n\n+/\n\n/g=C2=A0=C2=A0=C2=A0 # remove redundant newlines= , keep max two
Edit s/^[ =C2=A0=C2=A0=C2=A0 ]+//g=C2=A0=C2=A0=C2=A0 # re= move leading whitespace
Edit s/[ =C2=A0=C2=A0=C2=A0 ]+$//g=C2=A0=C2=A0=C2=A0 # remove trailing whit= espace
Edit s/ +/ /g=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 # remove multi= ple spaces
Edit s/;$//g=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 # remove tr= ailing semicolon
Edit s/\*+\///g=C2=A0=C2=A0=C2=A0 # comments
Edit s/= \/\*+/\/\//g
Edit s/[\(\)]/ /g=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 # re= move ()
Edit s/.*/(&)/g=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 # add ()
Edit s= /.*/float64(&)/g=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 # float64()
Ed= it s/.*/} & {/g=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 # add }=C2=A0 {Edit s/^/\/\/ /g=C2=A0=C2=A0=C2=A0 # // comment out
Edit /;[ =C2=A0=C2= =A0=C2=A0 ]*\/\// Edit s/;//=C2=A0=C2=A0=C2=A0 # find and remove semicolon = before // comments
Edit s/\+\+[a-zA-Z]+[0-9a-zA-Z]*/&++/ Edit s/\+\+/d=C2=A0=C2=A0=C2=A0 #= NOT WORKING prefix to postfix operator
Edit s/->/./g=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 # struct pointer

Edit ,s/\+\+([A-Za-z]+[A-Za-= z0-9]*)/\1++/g# prefix to postfix operator: ++
Edit ,s/\-\-([A-Za-z]+[A-Za-z0-9]*)/\1--/g# prefix to postfix operator: --<= br>
# prefix to postfix operator: ++i --> i++
Edit /\+\+[a-zA-Z_]+= [0-9a-zA-Z_]*/{
x/\+\+/d
a/++/
}

Edit s/\+\+([A-Za-z]+[A-Za= -z0-9]*)/\1++/ # prefix to postfix operator: ++i --> i++

| 9 sed 's/\(//; s/(.*)\)/\1/' # remove outermost pair of paren= theses
Edit s:\((.*)\):\1:g=C2=A0=C2=A0=C2=A0 # remove outermost pair of= parentheses





On Fri, Mar = 29, 2013 at 2:19 AM, <phineas.pett@gmail.com> wrote:
> Hi!
>
> I did a quick writeup on little Edit scripts
> (well basicly sam(1) scripts)
> If anyone have more feel free to contribute.
> Maybe someone could put them on the wiki even.

Nice idea...

Here's a simple awk bit I use in Acme for centering text (its name is the center-line rune: =E2=84=84)

#!/bin/rc
# Center text
awk '{l=3Dlength();s=3Dint((70-l)/2); printf "%"(s+l)"s\= n",$0}'

It doesn't seem to be common practice, but I like to name editing
commands with unicode runes to save room: i.e. =C2=A0=E2=86=90 and =E2=86= =92 for
indentation (used with code), or =E2=87=90 and =E2=87=92 for indentation + = a reformat
(used for natural language next). =C2=A0I find they serve a bit like icons.=



--089e010d8dde958a4604d90bf8a5--