From: trebol <trebol55555@yahoo.es>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: [9fans] International Ispell in Plan9
Date: Sat, 13 Apr 2013 04:36:45 +0100 [thread overview]
Message-ID: <20130413033644.GA1319@one.invalid.invalid> (raw)
In-Reply-To: <56802e952dbdab2949ef6e4fae793332@kw.quanstro.net>
Thanks for the help erik!
This is the best I made for now...
/////////////////////////////////////
/////////////////////////////////////
#!/bin/rc
rm -f /tmp/$pid^'.'aispell*
args=()
spellflags=()
for(x){
switch($x){
case -d*
spellflags=($spellflags $x)
case -p*
spellflags=($spellflags $x)
case -T*
spellflags=($spellflags $x)
case *
args = ($args $x)
}
}
dir = /mnt/wsys
if(! test -f $dir/cons)
dir = /mnt/term/$dir
id=`{cat $dir/new/ctl}
id=$id(1)
if(~ $#args 1 && ~ $args /*){
adir = `{basename -d $args}
args = `{basename $args}
echo 'name '^$adir^/-spell > $dir/$id/ctl
cd $adir
}
if not {
echo 'name '^`{pwd}^/-spell > $dir/$id/ctl
}
{
echo noscroll
if(~ $#args 0){
cat > /tmp/$pid^'.'aispell0
i = /tmp/$pid^'.'aispell0
winname = `{sed 's/ .*//g' < /mnt/acme/$winid/tag}
if(~ $winname '') winname = nonamedwindow
for(j in `{$home/local/bin/ispell -a $spellflags < $i | grep '^[&#]' | sed 's/ /_/g'}){
{cat $i; echo} | $home/local/bin/acme/spout | # spout needs \n
grep `{echo $j |
awk -F_ '{print $2}'} |
awk -F: '{OFS=":";$1 = "'$i'"; print}' >> /tmp/$pid^'.'aispell
}
sort -u /tmp/$pid^'.'aispell > $dir/$id/body
rm -f /tmp/$pid^'.'aispell*
}
if not for(i in $args){
for(j in `{ $home/local/bin/ispell -a $spellflags < $i | grep '^[&#]' | sed 's/ /_/g'}){
{cat $i; echo} | $home/local/bin/acme/spout |
grep `{echo $j | awk -F_ '{print $2}'} |
awk -F: '{OFS=":";$1 = "'$i'"; print}'>> /tmp/$pid^'.'aispell
}
sort -u /tmp/$pid^'.'aispell > $dir/$id/body
rm -f /tmp/$pid^'.'aispell
}
echo clean
}> $dir/$id/ctl
/////////////////////////////////////
/////////////////////////////////////
Is
grep '^[&#]' | sed 's/ /_/g'
better than
awk '/^[&#]/{gsub(/ /,"_"); print}'
?
I can use sed instead of awk in
awk -F: '{OFS=":";$1 = "'$i'"; print}'
but if the tag name contains the character used in sed as '/' it will
cause errors. I discovered working in this script that acme has problems
with file names containing whitespaces (I only can open it at startup
and if you click in the tag strange things happens...) so a solution would
be:
sed 's ^[^:]*: '$winname': g'
> and i think further simplification is possible by using
> {} instead of the temporary file dance.
I don't have the knowledge to make a better redirection work with the
standard input sent to the script. Specially with the output of the
statements inside the for loop. The file funky dance was the only way I
found to make the work.
> and i'd imagine that that's where the bug is.
The script works fine, 'aispell /some/file', 'aispell < /some/file' and
executing '> aispell' in a acme's window with some text selected works as
expected. But executing '> aispelles' in a acme's window, where aispelles
is a function:
'fn aispelles {/aispell/path -despañol -Tutf8 -p/personal/dictionary/path $*}'
doesn't works. But this function in win or outside acme works fine
('aispelles < /some/file' and 'aispelles /some/file'), so I
don't know what is the problem.
Also, I corrected a bug related with spout, it needs \n previous to EOF, so
the last line in a input without \n now doesn't stay out of the check.
I have looked in the acme scripts a lot and I can't find any example of
getting the dot address, only in c code. If anyone knows how to make it
in rc, I will be very grateful. I think with the feature of selecting a address
in the output of the script executed to any selected text in a window,
and pointing the cursor in the right position, the work will
be finish.
I'm learning a lot about Plan9, acme, rc, awk, sed ... perhaps I should have to wait
until I have the skills and knowledge about programming and Plan9 before
posting anything like this in the list, but I thought this could be useful
for someone.
Regards,
trebol.
next prev parent reply other threads:[~2013-04-13 3:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-10 22:01 trebol
2013-04-11 6:57 ` Mark van Atten
2013-04-11 17:57 ` Nemo
2013-04-12 12:21 ` trebol
2013-04-12 12:39 ` Francisco J Ballesteros
2013-04-12 12:56 ` erik quanstrom
2013-04-13 3:36 ` trebol [this message]
2013-04-11 12:34 trebol
2013-04-13 6:48 trebol
2013-04-14 2:30 trebol
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=20130413033644.GA1319@one.invalid.invalid \
--to=trebol55555@yahoo.es \
--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).