From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 12 Apr 2013 13:21:53 +0100 From: trebol To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Message-ID: <20130412122153.GA16785@one.invalid.invalid> References: <20130410220136.GA22815@one.invalid.invalid> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: [9fans] International Ispell in Plan9 Topicbox-Message-UUID: 40e93a56-ead8-11e9-9d60-3106f5b1d025 On Thu, Apr 11, 2013 at 07:57:13PM +0200, Nemo wrote: > you could put it in sources, if not yet there. I want to put order in this mess before put it in sources. I change the for loop to work in the output of ispell instead, and now ispell works only one time in terse mode. The script is now much faster thanks to the good design of awk and grep. #!/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 = `{cat /mnt/acme/$winid/tag | awk '{print $1}'}; for(j in `{cat $i | $home/local/bin/ispell -a $spellflags | awk '/^[&#]/{gsub(/ /,"_"); print}'}){$home/local/bin/acme/spout $i | grep `{echo $j | awk -F_ '{print $2}'} | awk -F: '{OFS=":";$1 = "'$winname'"; 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 `{cat $i | $home/local/bin/ispell -a $spellflags | awk '/^[&#]/{gsub(/ /,"_"); print}'}){$home/local/bin/acme/spout $i | grep `{echo $j | awk -F_ '{print $2}'} >> /tmp/$pid^'.'aispell } ; sort -u /tmp/$pid^'.'aispell > $dir/$id/body; rm -f /tmp/$pid^'.'aispell } echo clean }> $dir/$id/ctl Now you can use it in the tag line to spell check the dot, and the output begins with the name of the window, so if you select all the window's body, you can spell check it without save it with the same commodity. Of course the addresses of the misspelled words don't works with a common selection. To make this work, I need to know how to get the dot address within the script. Also the functions don't work in acme, but a similar script works. Why? fn aispellen {$home/local/bin/acme/aispell -p$home/lib/pdict_en -damerican $*} Any help?