01.30.06
Textmate spelling commands
I just created a new command for TextMate, that offers alternative spellings to current words, with significant help from Allan and the gang at the #textmate irc channel. All is not rosy however. You will need to have aspell installed for it to work. You can see in this screencast the command at work, and if you like it then here is the code for the command and instructions on how to install aspell.
Ready? Ok, here is the command:
# Offers spelling alternatives for current word.
# You MUST have installed aspell for this to work.
#
#
require_cmd aspell
res=$(aspell <<<"$TM_CURRENT_WORD" -a --mode=none|tail -n2|cut -f2 -d:|tr -d ,)
if [[ "${res:0:1}" == "*" ]]
then
# Correct word. Exit
exit_discard
fi
#res="${res//'/\\\'}"
#echo $res
# Offer corrections via cocoadialog
result=$(CocoaDialog dropdown \
--title 'Possible spellings' \
--text 'Choose correct spelling for insertion, or escape to cancel.' \
--button1 Ok --button2 Cancel \
--string-output --no-newline \
--items $res)
if [[ ${result:0:2} != Ok ]]
then
exit_discard
else
result=${result:3}
echo -n ${result}
fi
If you have subversion installed, you can also get it by doing a subversion checkout of the Experimental bundle, which contains it. If you do it manually, you would want to set its input to selected text, with a fallback to word, and its output to Replace Selected Text. I have bound it to ctrl-;, but that is of course up to you.
Ok, this was the easy part, now for the hard part of installing aspell, which will require working on the command line. If the words fink or darwinports make sense to you, then just use them to find and install aspell and don’t keep on reading. The rest of you don’t be scared yet! Oh, by the way, you will need to know your administrator password at this point. (Now be scared). First of all, you need to get the most recent version of aspell, which in my case is 0.60.4. After you have it downloaded, say in your Desktop, double-click to decompress it (if the browser did not do this automatically for you). Now you are looking at a folder titled aspell-0.60.4.
Open Terminal.app, and cd your self to that directory. One way to do that is to type cd, press space, and then drag the folder onto the terminal window, and press Enter. Now your terminal will probably say something like:
charilaos-skiadas-ibook-g4-2:~/Desktop/aspell-0.60.4 haris$
Alright, now the magic can begin. First, make sure you have the Developer Tools installed. That means XCode and other stuff, and it is supposed to be in one of the CD/DVD’s that came with your computer. If you don’t have them installed, then go do that now.
Done? good. ok, back to our folder, and the terminal. You’ll want to type ./configure and press Enter. Now lots of cool and bizarre stuff show up on your screen, and you’ll probably see the words yes and no a bunch of times. After a while you will see the prompt above again. What just happened is that your computer prepared the aspell package for installation, by telling it important information like what kind of compiler is running etc. Now type make and press Enter. A lot of even more chaotic and totally incomprehensible stuff will show up in your screen, and it will take quite some time for it to finish. This would be the moment to go for a snack.
Ok, now that that is done, you are almost ready to play with aspell. Your computer just finished compiling the actual executable program, and you could theoretically run it from where you are right now. The next part necessary is to place it at the appropriate location, so that other commands can find it. Luckily, this will be done for us automatically. So type sudo make install and press Enter. You will be asked for your administrator password. A couple more pages weird lines and you are done! Your computer just moved the files at the appropriate locations so that they can be found. To test things, open a new terminal window, type aspell and press Enter. You should see some error message about there not being a dictionary or something like that.
Oh, did I forget to mention it? We will need to repeat all the above steps for each dictionary we want to add to aspell. Sounds fun, eh? Ok, go to the address ftp://ftp.gnu.org/gnu/aspell/dict and download whatever language dictionaries you want, and follow the same “configure/make/make install” process as above. Now you are set. Enjoy!
Later