Yesterday on the TextMate irc channel the [gSpell service for OSX][1] was mentioned, which is a fairly neat way of spell checking (more details on the gSpell homepage.) I decided to try and simulate the service as a TextMate command which takes a selection and looks up the most reasonable alternative with Google.
[The tmCommand is Available here.][2]
[1]: http://nspindel.com/gspell/ [2]: http://homepage.mac.com/andy.herbert/.Public/Check%20Spelling% 20Using%20Google.tmCommand
Hi Andy,
very nice feature.
I have two tiny additions to that.
1) How about to specify a variable TM_GSPELL_LANG to be able to set the input language (e.g. 'de' for German) for line:
Line 8: GOOG_PAGE = "/tbproxy/spell?lang=#{ENV["TM_GSPELL_LANG"]}&hl=en"
2) If you query gsepll for e.g. German "Fähhre" it returns among others "F&#E4;hre". To decode this here my suggestion:
def mydecode(source) return source.gsub(/&#([0-9]{1,7});|&#x([0-9a-f]{1,6});/i) { $1 ? [$1.to_i].pack('U') : [$2.to_i(16)].pack('U') } end
Unfortunately, Ruby is not my first language. Maybe you can add this. For checking of a single word I did
... tt=mydecode(t) alts = t.split(/\t/) ...
this works, but for the multiple words checking - I have no idea ;( Maybe it would work if one decode the body variable but this doesn't work for multiple words. I get the spelling suggestion 'Fe' for 'Fähhre'
Thanks,
Hans
Hi,
regarding to the multiple word checking I found a way to do it, but in Ruby I have no idea to get the REAL length of a (I guess) UTF-8 string. The point is that s="Fähre" s.length returns 6 not 5. I tried to set $KCODE = 'UTF-8' in the script but it doesn't work.
Have someone an idea?
Cheers,
Hans
Hi,
On 29.04.2007, at 13:54, Andy Herbert wrote:
Yesterday on the TextMate irc channel the [gSpell service for OSX] [1] was mentioned, which is a fairly neat way of spell checking (more details on the gSpell homepage.) I decided to try and simulate the service as a TextMate command which takes a selection and looks up the most reasonable alternative with Google.
[The tmCommand is Available here.][2]
20Using%20Google.tmCommand
After learning Ruby a bit better, here comes the utf-8 version for French, German etc. of it.
You can set a TM shell variable TM_GSPELL_LANG to e.g. 'de' for German, if you want the German spell checker. If it is unset 'en' is the default.
Cheers,
Hans
PS Maybe a Ruby programmer could rewrite it better ;)
On Apr 30, 2007, at 10:45 AM, Hans-Jörg Bibiko wrote:
Hi,
On 29.04.2007, at 13:54, Andy Herbert wrote:
Yesterday on the TextMate irc channel the [gSpell service for OSX] [1] was mentioned, which is a fairly neat way of spell checking (more details on the gSpell homepage.) I decided to try and simulate the service as a TextMate command which takes a selection and looks up the most reasonable alternative with Google.
[The tmCommand is Available here.][2]
20Using%20Google.tmCommand
After learning Ruby a bit better, here comes the utf-8 version for French, German etc. of it.
You can set a TM shell variable TM_GSPELL_LANG to e.g. 'de' for German, if you want the German spell checker. If it is unset 'en' is the default.
Cheers,
Hans PS Maybe a Ruby programmer could rewrite it better ;)
This so totally rocks!
thomas Aylott — subtleGradient — CrazyEgg — sixteenColors
Hi,
I found a tiny error. Here the corrected utf-8 version of gspell.
BTW In addition to that it is very easy to write out all google suggestions delimited by a '|' within the multiple word spell checking. With the help of a small command which shows this list as pull-menu you can edit each error very handy ;)
Cheers,
Hans
Is there a way to add a BOM marker to a UTF8 file created by Textmate?
Homesite on Windows doesn't seem to be reading files created by Textmate correctly as UTF8 -- I have a suspicion this may have something to do with the lack of a BOM marker in the beginning.
--- David Zhou david@nodnod.net
On 30. Apr 2007, at 21:50, David Zhou wrote:
Is there a way to add a BOM marker to a UTF8 file created by Textmate?
Homesite on Windows doesn't seem to be reading files created by Textmate correctly as UTF8 -- I have a suspicion this may have something to do with the lack of a BOM marker in the beginning.
For the records, I talked with David on IRC and we created this command, which adds a BOM to the currently open file (which TM will then preserve):
Though this comes with the usual disclaimer about not using BOM’s in UTF-8, since it is bad for compatibility, e.g. the shell won’t understand the shebang line, merging multiple files using cat, grep, or similar, may cause BOM’s to end up in the middle of the file (and/ or not at the start of the result), etc.
Hi,
On 30.04.2007, at 21:50, David Zhou wrote:
Is there a way to add a BOM marker to a UTF8 file created by Textmate?
Homesite on Windows doesn't seem to be reading files created by Textmate correctly as UTF8 -- I have a suspicion this may have something to do with the lack of a BOM marker in the beginning.
the BOM for UTF-8 is EF BB BF
One approach could be the following tmCommand:
Save:Nothing
Commands: T=$(cat) filename="$(CocoaDialog filesave --title 'Save UTF-8 with BOM')" [ -n "$filename" ] && echo -en "\357\273\277$T" > "$filename"
Input: Entire Document Output: Discard
Hans