[TxMt] Spell checking using Google

Hans-Jörg Bibiko bibiko at eva.mpg.de
Thu May 3 12:25:45 UTC 2007


On 03.05.2007, at 13:42, Allan Odgaard wrote:

> On 2. May 2007, at 10:23, Hans-Joerg Bibiko wrote:
>
>> 1) ESC behaviour
>> If I press ESC while the pull-down menu is shown it takes Google's  
>> first suggestion. By my opinion it's more logically that pressing  
>> ESC will change nothing. Thus I wrote:
>> ...
>> res = TextMate::UI.menu(items.flatten)
>> correction = (res) ? res['string'] : org
>> ...
>
> Actually, I think escape should abort the entire thing.
I agree, but if you use my way it does the same.

>
>> 2) \n\n problem
>> There's is still the problem if the selected text contains '\n\n'
>> I managed it by relpacing all \n with a non-used character
>
> I cannot reproduce this. What text are you testing with?
I was wrong. Not \n\n is the problem but a line like " \n" or "\t\n".  
If I don't replace the \n the snippet matching is wrong after such a  
line.

German example (TM_GSPELL_LANG = de)
-comment out str = str.gsub(/\n/, " ") in my script

Text:
Dies ist ein Tesst.\n
  \n
Dies istt ein Test.\n

(second line is SPACE\n)
invoke the script Tesst is highlighted, press TAB and now 'tt e'  
highlighted instead of istt.
If you replace \n everything is fine.


>
>> 3) Google returns only one suggestion
>>>  When there is only one suggestion, the command uses that, and  
>>> makes the word a tab-stop.
>> By my opinion it would be better to show always a pull-down menu  
>> with the original and the suggestion. Google hasn't always right.
>
> hmm… you can always undo. If Google is right >50% of the time, I  
> think always accepting, and require an undo, is better than showing  
> a pop-up.
OK - undo is also fine ;)

>> 5)
>> For security reason the command returns the snippet: new_str +  
>> "${0:}"
>
> Huh?
What do you mean with 'Huh?'?
Huh - I forgot it or I don't understand why?
If the second is right:
If you don't write + "${0:}" and you come to last misspelled word and  
press TAB you will replace the last highlighted word with TAB instead  
of jumping to the end. You don't know that this word is last  
misspelled word. ;)

Attached the modified script.

Hans

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Google Spell Check Selection : Word.tmCommand
Type: application/octet-stream
Size: 2963 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20070503/8167f0e8/attachment.tmCommand>
-------------- next part --------------






More information about the textmate mailing list