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?

Reply via email to