From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sat, 13 Apr 2013 04:36:45 +0100 From: trebol To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Message-ID: <20130413033644.GA1319@one.invalid.invalid> References: <20130410220136.GA22815@one.invalid.invalid> <20130412122153.GA16785@one.invalid.invalid> <56802e952dbdab2949ef6e4fae793332@kw.quanstro.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <56802e952dbdab2949ef6e4fae793332@kw.quanstro.net> User-Agent: Mutt/1.5.21 (2010-09-15) Content-Transfer-Encoding: quoted-printable Subject: [9fans] International Ispell in Plan9 Topicbox-Message-UUID: 410eb358-ead8-11e9-9d60-3106f5b1d025 Thanks for the help erik! This is the best I made for now... ///////////////////////////////////// ///////////////////////////////////// #!/bin/rc rm -f /tmp/$pid^'.'aispell* args=3D() spellflags=3D() for(x){ switch($x){ case -d* spellflags=3D($spellflags $x) case -p* spellflags=3D($spellflags $x) case -T* spellflags=3D($spellflags $x) case * args =3D ($args $x) } } dir =3D /mnt/wsys if(! test -f $dir/cons) dir =3D /mnt/term/$dir id=3D`{cat $dir/new/ctl} id=3D$id(1) if(~ $#args 1 && ~ $args /*){ adir =3D `{basename -d $args} args =3D `{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 =3D /tmp/$pid^'.'aispell0 winname =3D `{sed 's/ .*//g' < /mnt/acme/$winid/tag} if(~ $winname '') winname =3D 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=3D":";$1 =3D "'$i'"; print}' >> /tmp/$pid^'.'aispell=20 }=20 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=3D":";$1 =3D "'$i'"; print}'>> /tmp/$pid^'.'aispell } sort -u /tmp/$pid^'.'aispell > $dir/$id/body rm -f /tmp/$pid^'.'aispell } echo clean }> $dir/$id/ctl ///////////////////////////////////// ///////////////////////////////////// Is=20 grep '^[&#]' | sed 's/ /_/g'=20 better than awk '/^[&#]/{gsub(/ /,"_"); print}' ? I can use sed instead of awk in=20 awk -F: '{OFS=3D":";$1 =3D "'$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 woul= d 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.=20 > 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 a= s expected. But executing '> aispelles' in a acme's window, where aispelle= s is a function: 'fn aispelles {/aispell/path -despa=C3=B1ol -Tutf8 -p/personal/dictionar= y/path $*}'=20 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 h= ave 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 usefu= l for someone. Regards, trebol.