From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 10 Apr 2013 23:01:36 +0100 From: trebol To: 9fans <9fans@9fans.net> Message-ID: <20130410220136.GA22815@one.invalid.invalid> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Content-Transfer-Encoding: quoted-printable Subject: [9fans] International Ispell in Plan9 Topicbox-Message-UUID: 408ffb58-ead8-11e9-9d60-3106f5b1d025 Hello everyone, First of all, I'm just starting to learn programming, and I'm a complete newbie in Plan9, so please, be patient... I was sad with the English only spell checker, so I compiled international ispell with ape: -Installed pdcurses. -Patched term.c for termios.h, I used a linux patch (I don't have idea) -Modified correct.c:827 (I had type conflicts). (void) fputs ((const char*)tok, logfile);=20 -Edited local.h.generic for local.h: #define MINIMENU /* Display a mini-menu at the bottom of the screen */ #define USG /* Define on System V or if term.c won't compile */ #undef NO_FCNTL_H /* Define if you get compile errors on fcntl.h */ #define NO_MKSTEMP /* Define if you get compile or link errors */ #define CFLAGS "-O -D_POSIX_SOURCE -D_BSD_EXTENSION" #define TERMLIB "-lcurses" #define REGLIB "" #undef NO8BIT #define WORDS "/usr/trebol/local/share/dict/words" =09 #define LANGUAGES "{american,MASTERDICTS=3Damerican.med,HASHFILES=3Damer= icanmed.hash,EXTRADICT=3D} {espa=C3=B1ol}" /* * Important directory paths. If you change MAN45DIR from man5 to * something else, you probably also want to set MAN45SECT and * MAN45EXT (but not if you keep the man pages in section 5 and just * store them in a different place). */ #define BINDIR "/usr/trebol/local/bin" #define LIBDIR "/usr/trebol/local/lib" #define MAN1DIR "/usr/trebol/local/man/man1" #define MAN45DIR "/usr/trebol/local/man/man5" I used http://www.datsi.fi.upm.es/~coes/espa~nol-1.7.tar.gz for Spanish spell checking, untar it in ispell-3.3.02/languages/espa=C3=B1ol and made some changes: -Changed all files and directories names to utf8 (acme don't work fine wi= th the ~) -Added a utf8 formatter to the aff file: altstringtype "utf8" "tex" ".txt" =09 altstringchar =C3=A1 \'a altstringchar =C3=81 \'A altstringchar =C3=A9 \'e altstringchar =C3=89 \'E altstringchar =C3=AD \'i altstringchar =C3=8D \'I altstringchar =C3=B1 \'n altstringchar =C3=91 \'N altstringchar =C3=B3 \'o altstringchar =C3=93 \'O altstringchar =C3=BA \'u altstringchar =C3=9A \'U altstringchar =C3=BC \"u altstringchar =C3=9C \"U -Edited Makefile, changed LANGUAGE to espa=C3=B1ol and corrected paths: =09 ... PATHADDER =3D ../../ BUILDHASH =3D ../../buildhash UNSQ =3D ../../unsq FIX8BIT =3D ../../fix8bit ... LANGUAGE =3D espa=C3=B1ol ... e=C3=B1e: sh e=C3=B1es ... ../../munchlist -v -l ... 'make' works fine, but the deformatters must be compiled, 'make install' expects executables but 'make all' creates .o files. After 'make install= ' the Spanish .aff and .hash files must be moved to the correct directory. Well, ispell's normal mode works, but the suggestions and the line of the misspelled word aren't showed (curses's problems?). Interactive and -a, -l modes works fine. The next problem was acme. I had to change spout.c:63 for no ASCII chara= cters: if(isalpharune(c)) Then aspell. I made a version for ispell... well this was for me a nightmare, but I've learned a lot about rc. #!/bin/rc 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) for(j in `{$home/local/bin/acme/spout | sort -t: -u +2 | sort -t: +1.1n= }){if(test `{echo -n $j | $home/local/bin/ispell -l $spellflags}){echo -n= $j; echo -n $j | $home/local/bin/ispell -a $spellflags | awk -F: '/^&/{O= RS=3D""; print $2}'; echo}} > $dir/$id/body if not for(i in $args) cat $i | for(j in `{$home/local/bin/acme/spout | sort -t: -u +2 | sort = -t: +1.1n}){if(test `{echo -n $j | $home/local/bin/ispell -l $spellflags}= ){echo -n $i; echo -n $j; echo -n $j | $home/local/bin/ispell -a $spellfl= ags | awk -F: '/^&/{ORS=3D""; print $2}'; echo}} > $dir/$id/body echo clean }> $dir/$id/ctl This works, and the output is like this: test:#0,#7:centeya centena test:#8,#14:cami=C3=B1o camilo, camino, cari=C3=B1o test:#15,#21:camion camino, cami=C3=B3n So you can click to visit the file in the word misspelled, and also see t= he suggestions. With -dlanguage, -ppersonaldictionary and -Tformatter you can use all of the international ispell's dictionaries. I put functions in my profile for a easy use: fn aispelles {$home/local/bin/acme/aispell -p$home/lib/pdict -Tutf8 -desp= a=C3=B1ol $*} fn aispellen {$home/local/bin/acme/aispell -p$home/lib/pdict_en -damerica= n $*} And you can have '>> /personal/dictionary/path' to acme's tag (or command= s file's window) for adding words to your personal dictionary quickly. The problem is the 'for' statement. When the file grows a little the script works VERY slow. And some times I have 'test: unexpected operator/operand:' with this test expression. I'm sure there is a faster (and more proper) way to make this right, so I'll appreciate any help. Regards, trebol.