[TxMt] Re: Cocoa Autocomplete

Sam Halliday sam.halliday at gmail.com
Thu Jan 11 12:31:35 UTC 2007


Hi Hans-Joerg,

I see what your script is doing there and it would be sensible but  
for the fact that I would require British (not American) English plus  
my own personal additions to the dictionary.

I could get around the British restraint by using a British file from  
somewhere (possibly aspell), and my personal additions as located in  
"Library/Spelling/en_GB" (but uses some odd characters and  
terminators, so regex definitely needed there).

Perhaps you might want to generalise your script to include the user  
additions?

If there is no other way around this, I may just have to do that.

Thanks,
Sam

On 11 Jan 2007, at 12:23, Hans-Joerg Bibiko wrote:

> Dear all,
>
> I don't know whether I can follow the entire discussion but here  
> comes my opinion.
>
>
> First of all I find it quite useful that TM has its own completion  
> based on terms occurring in the current document. Actually TM was  
> written as an editor to write source code. By writing the name of a  
> variable only once I can use the key 'ESC' to complete the name if  
> I have to write it again instead of having all English words  
> beginning with that I typed.
>
> Nevertheless everybody knows TM is useful for thousand of things.  
> Also for writing prose. To use a completion for all English words,  
> for instance, you can write such a command very easily by yourself.
>
> Here a fast written first approach in Ruby:
>
> #!/usr/bin/ruby
> require File.join(ENV['TM_SUPPORT_PATH'], "lib/exit_codes.rb")
> require File.join(ENV['TM_SUPPORT_PATH'], "lib/dialog.rb")
> require File.join(ENV['TM_SUPPORT_PATH'], 'lib/current_word.rb')
>
> word = Word.current_word(/\w./)
>
> wrds = `cat /usr/share/dict/web2 | grep ^#{word}`
>
> words = wrds.split("\n")
> if words.size == 1
>   out = words.first
> else
>   idx = Dialog.menu words
>   TextMate.exit_discard if idx.nil?
>   out = words[idx]
> end
>
> TextMate.exit_discard if words.empty?
>
> print out[word.length..-1]
> print " "
>
>
> What I'm doing here is use the dict file of Webster's dictionary  
> which should come out of each Mac OSX release. This file is located  
> in /usr/share/dict/web2.
>
> Then I use the system command:
>
> cat /usr/share/dict/web2 | grep ^myword
>
> The output is a list separated by a '\n' of all words beginning  
> with 'myword'. I put this list into a dialog and then you can  
> select that one which you want to insert.
>
> This script can be modified easily to use an other dictionary of  
> course.
>
> If you want to use a non-English dictionary then you have to manage  
> the right encoding in beforehand, but this can be discussed later.
>
>
> Attached is an example command 'AutoComplete' using this script. I  
> bound this command to the key APPLE+ESC, but you can change it.
>
> Maybe it helps. (and with this solution Allan hasn't to change TM's  
> source code)
>
>
> Best
>
> -Hans
>
> <AutoComplete.tmCommand>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate

-- 
Sam


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <http://lists.macromates.com/textmate/attachments/20070111/474c3be4/attachment.sig>


More information about the textmate mailing list