How and where do I define multi-language spelling? I use the LaTeX bundle and type different languages in my documents. I would like to define a scope for French, for instance, using \begin{french} and \end{french} as markers.
David Howden suggested a while back “to add to the grammar (creating scopes for different languages) and then set the languages for those scopes in the tm_properties file.” I would like to learn how to do that. I don't know regex (only very minimally) and where to define such scope. Thanks for pointers. --Gildas
Hey!
I do remember saying something like that, and then hoping that someone else would experiment with it! Unfortunately I'm rather too busy with other problems at the moment, but I can quickly give a more detailed explanation of how I think this could work, or at least where I got the idea from!
In .tm_properties files you can set things like:
[ scope.name ] spellChecking = true spellingLanguage = 'en_GB'
So I was thinking that you could inject a grammar (or just modify the grammar that you are interested in, i.e. LaTeX), with a definition for a new scope, say
meta.lang.fr
and then in .tm_properties you could put
[ meta.lang.fr ] spellChecking = true spellingLanguage = 'fr'
I think the hardest part would be actually writing the grammar stuff. A quick google springs up a semi-useful link that would get you started:
http://manual.macromates.com/en/language_grammars http://developmentality.wordpress.com/2011/02/08/textmate-introduction-to-la...
And there's the TM book (Pragmatic Textmate Power Editing) which has a whole chapter on creating grammars.
For information about the new grammar injection stuff, again give it a google - there is some chatter here somewhere (I remember it going on!), and there is definitely a whitespace bundle which uses it to show bad whitespace (http://mads379.github.com/posts/whitespace-tmbundle).
EDIT: Decided to just try it myself. The grammar injection works fine, though it can mess up the highlighting. Sadly the spelling checker doesn't seem to work on a per-scope basis (maybe this is something on Allan's todo list?). As I wrote the instructions as I was doing it, I've included them here just incase this gets fixed in the future (or someone can spot the silly thing I've done which makes this not work :-)).
In Bundle Editor, open the Latex Bundle and press Cmd+N to get the "Create new Item" sheet. Choose "Grammar"
Set an approprate name (mine is "Language Block"). Remove all other settings (for the moment!), and set Injection Selector to "*". Set the grammar to be:
{ patterns = ( { begin = '\blang=fr\b'; end = '\bendlang=fr\b'; name = 'meta.lang.fr'; }, ); }
(check that above links for how to write grammars).
Then restart TM2 (from a few tests just now, this was necessary for it to appear!).
Now, in a latex document:
lang=fr Bonjour! endlang=fr
(we need to change the lang, endlang syntax to be ignored by latex, but that is a job for later).
Place your cursor before the letter B and hit Ctrl+Shift+P (to show you the scope). It will show meta.lang.fr in the list that appears. The language injection works!
Now put the properties into a relevant .tm_properties file (as above), and it should work fine (though not at the moment :-/).
Hope this is helpful! At least you don't have to bother until this works :-).
David.
On 3 August 2012 14:06, Gildas Hamel gweltaz@ucsc.edu wrote:
How and where do I define multi-language spelling? I use the LaTeX bundle and type different languages in my documents. I would like to define a scope for French, for instance, using \begin{french} and \end{french} as markers.
David Howden suggested a while back “to add to the grammar (creating scopes for different languages) and then set the languages for those scopes in the tm_properties file.” I would like to learn how to do that. I don't know regex (only very minimally) and where to define such scope. Thanks for pointers. --Gildas
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
* Skriv a reas David Howden (dhowden@gmail.com): [....] |> Place your cursor before the letter B and hit Ctrl+Shift+P (to show |> you the scope). It will show meta.lang.fr in the list that appears. |> The language injection works! |> |> Now put the properties into a relevant .tm_properties file (as above), |> and it should work fine (though not at the moment :-/). |> |> Hope this is helpful! At least you don't have to bother until this works :-). |>
Very helpful. Thanks for taking the time to experiment. I'll give it a try and adapt to my setup. --Gildas
Not at all, though sadly it doesn't work properly as yet. Waiting on a response from allan on how fully the spelling stuff is integrated with the scopes...
David.
On 4 August 2012 10:49, Gildas Hamel gweltaz@ucsc.edu wrote:
- Skriv a reas David Howden (dhowden@gmail.com):
[....] |> Place your cursor before the letter B and hit Ctrl+Shift+P (to show |> you the scope). It will show meta.lang.fr in the list that appears. |> The language injection works! |> |> Now put the properties into a relevant .tm_properties file (as above), |> and it should work fine (though not at the moment :-/). |> |> Hope this is helpful! At least you don't have to bother until this works :-). |>
Very helpful. Thanks for taking the time to experiment. I'll give it a try and adapt to my setup. --Gildas
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
So it seems that these settings only work properly on a per-file basis, so this solution is not useful at all in this case!
I suppose that if you're using tex you can actually just have the different languages in different files and \input{french-file} them?
On 4 August 2012 11:32, David Howden dhowden@gmail.com wrote:
Not at all, though sadly it doesn't work properly as yet. Waiting on a response from allan on how fully the spelling stuff is integrated with the scopes...
David.
On 4 August 2012 10:49, Gildas Hamel gweltaz@ucsc.edu wrote:
- Skriv a reas David Howden (dhowden@gmail.com):
[....] |> Place your cursor before the letter B and hit Ctrl+Shift+P (to show |> you the scope). It will show meta.lang.fr in the list that appears. |> The language injection works! |> |> Now put the properties into a relevant .tm_properties file (as above), |> and it should work fine (though not at the moment :-/). |> |> Hope this is helpful! At least you don't have to bother until this works :-). |>
Very helpful. Thanks for taking the time to experiment. I'll give it a try and adapt to my setup. --Gildas
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate