On 1. May 2007, at 01:10, Hans-Jörg Bibiko wrote:
On the other hand I have a problem with '\n\n' in the text.
OK. I solved this problem by replacing '\n' with a Japanese space ;)
An other problem arose with many spaces ' '. I also solved it with a Japanese character ;)
Attached is my take on it (based on yours and Andy’s code).
I use the offset and length given back by Google to figure out where the corrections should go.
Google seems to a) give the count in “code points” (regardless of encoding) and b) collapse all successive whitespace into one character. Here is the helper I use to adjust for that:
def substr(str, idx, len = 10000) $1 if str =~ /^(?:\s+|.){#{idx}}((?:\s+|.){0,#{len}})/m end
When Google returns multiple suggestions, the command will show a menu, with the original word at the top. It does this for every misspelled word in the text. When there is only one suggestion, the command uses that, and makes the word a tab-stop.
Personally I think the menu is generally not wanted, so that part should probably be removed (and the first suggestion should always be picked).
I gave it a key equivalent of ⌥⇧F2 which is analogous with ⌥F2 for the regular context menu (which has spelling suggestions).