Hi there,
I'm starting to feel really useless now! I'm trying to write a language grammar for the latex TODO bundle (http://tug.ctan.org/tex-archive/macros/latex/contrib/todo/)
When used, it produces a nice todo file that looks like the following:
(abstract) l.4, p iii, s : expand upon this `argument' (introduction) l.17, p 1, s 1.1: Did I just think these categories up, or did they come from somewhere? (introduction) l.26, p 1, s 1.1: Back these definitions with references to the literature (background) l.37, p 10, s 2.1.1: is there actually an example of a virtual environment with no users? (background) l.67, p 11, s 2.1.1: fill out this section with a complete range of quotes
Currently I just want to add syntax highlighting to this document. I have created my own bundle (LaTeXTODO), and inside my own language file: (LaTeXTODO). This language file looks as follows:
{ scopeName = 'source.latex_todo'; fileTypes = ( 'TODO' ); patterns = ( { match = '^((.*?))'; captures = { 1 = { name = 'entity.name.latex_todo'; }; }; } ); }
I was hoping it would match the first bracketed word in each sentence (abstract), (introduction), etc. and scope them as 'entity.name.latex_todo'. Unfortunately this doesn't seem to be the case. For some very strange reason, when i click on (abstract), and hit the short-cut ctrl-shift-p it says that the scope is tex.log.latex.
This is very odd, and the language menu at the bottom definitely says i'm in LaTeXTODO mode. I'm really at a loss with what to do with languages grammars now, and i'm almost wondering whether TextMate is playing fairly...
Yours in hope of any help at all, Sam Aaron
On Oct 9, 2006, at 9:17 AM, sam aaron wrote:
{ scopeName = 'source.latex_todo'; fileTypes = ( 'TODO' ); patterns = ( { match = '^((.*?))'; captures = { 1 = { name = 'entity.name.latex_todo'; }; }; } ); }
Is this the entire grammar file, or is there more that you are not showing us? Because if this is really the entire grammar file, then this wouldn't possibly give you a scope of tex.log.anything, provided the language grammar is indeed set to your new grammar. If this is not the entire file, then that means there might be other rules that take precedence, so you'll need to paste the entire thing.
Yours in hope of any help at all, Sam Aaron
Haris
Is this the entire grammar file, or is there more that you are not showing us? Because if this is really the entire grammar file, then this wouldn't possibly give you a scope of tex.log.anything, provided the language grammar is indeed set to your new grammar.
That's the thing, this *is* the entire grammar file, and the file *is* set to LateXTODO. This is what's making me wonder if it is actually me, or if TextMate isn't behaving correctly.
I'm using Version 1.5.3 (1269) of TextMate if that help things?
Thanks, Sam
On Oct 9, 2006, at 11:08 AM, sam aaron wrote:
That's the thing, this *is* the entire grammar file, and the file *is* set to LateXTODO. This is what's making me wonder if it is actually me, or if TextMate isn't behaving correctly.
Just to make sure, have you pressed the "Test" button in the bundle editor since you last changed your grammar? You have to press the "Test" button for TM to start using the changes you've made.
Thanks, Sam
Haris
Just to make sure, have you pressed the "Test" button in the bundle editor since you last changed your grammar? You have to press the "Test" button for TM to start using the changes you've made.
just pressed the 'test' button, and it's now working :-) Sorry to have made such a simple mistake!
I wonder whether the test button should be called 'activate' or other? I also wonder whether TextMate can detect if you've been playing with the bundle file, and inform you that the version you're looking at isn't currently activated, until you activate it.
Thanks for the help though! I guess I should just get on with my thesis though... it's that that really needs to be worked on! ;-)
Sam
On Oct 9, 2006, at 11:27 AM, sam aaron wrote:
just pressed the 'test' button, and it's now working :-) Sorry to have made such a simple mistake!
It's not that simple, I've happened to have made the same mistake myself many times.
I wonder whether the test button should be called 'activate' or other? I also wonder whether TextMate can detect if you've been playing with the bundle file, and inform you that the version you're looking at isn't currently activated, until you activate it.
Yes I'd like to second that request for some better indicator of the state of the system at that point. I don't know what Allan has planned for 2.0, but it would definitely be nice to have an indicator that the Test button hasn't been pressed, even though the language has changed, and hence what you see as a language grammar is not what TM is using. For all other bundle items, the moment the bundle editor closes their changes are registered, but not so for languages, and there is no visual indicator that something is amiss.
Thanks for the help though! I guess I should just get on with my thesis though... it's that that really needs to be worked on! ;-)
Heh, that brings back memories ;) I spent a considerable amount of my time while working on my thesis, tinkering with the LaTeX bundle instead. TM is just too addictive in that respect (in a good way of course). ;)
Good luck.
Sam
Haris
Heh, that brings back memories ;) I spent a considerable amount of my time while working on my thesis, tinkering with the LaTeX bundle instead. TM is just too addictive in that respect (in a good way of course). ;)
Well I'm glad to hear that it's possible to tinker with TM, and finish your thesis off ;-) Thing is, there's so much to learn, and to do one thing requires a whole load of other knowledge. Plus the fact that learning things like ruby feels like such a 'good' thing :-) regexps on the other hand are the root of all evil!!!
I do however think that knowing if things have been saved in the bundle editor is something I'm struggling with. I don't always close the editor after I've made a change, and do things like toggle between two different commands before I try the command again, which feels like a bit of a fudge. Again even in non-language files, an 'Activate' button would be very handy.
Oh, and if you're interested do know why I wanted to know if it was possible to persist commands, I was thinking about the possibility of embedding an irb console within TM. I think it woudl be wonderful to have a syntax highlighted irb console, and it would a cool place to try out new commands etc - as it would have access to all the TM variables. I'm sure it's possible (why managed to achieve something similar with his Try Ruby site), but that's definitely a post-PhD project ;-) irbmate!
Take care, Sam
On 9. Oct 2006, at 17:43, Charilaos Skiadas wrote:
[...] I don't know what Allan has planned for 2.0, but it would definitely be nice to have an indicator that the Test button hasn't been pressed, even though the language has changed, and hence what you see as a language grammar is not what TM is using. For all other bundle items, the moment the bundle editor closes their changes are registered, but not so for languages, and there is no visual indicator that something is amiss.
Closing the bundle editor should “apply” the changes for the language grammar.
The reason there is an explicit test button is that, as some language grammar hackers will know, it is possible to create infinite (zero- width matching) cycles in the language grammar, which will make TextMate’s parser freeze (when using that grammar) -- so “live” editing of grammars is currently a bad idea (since an intermediate state could trigger the problem). The parser used for 2.0 will not have this problem, and so there is no real need to not apply the changes immediately.
The reason there is an explicit test button is that, as some language grammar hackers will know, it is possible to create infinite (zero-width matching) cycles in the language grammar, which will make TextMate’s parser freeze (when using that grammar) -- so “live” editing of grammars is currently a bad idea (since an intermediate state could trigger the problem). The parser used for 2.0 will not have this problem, and so there is no real need to not apply the changes immediately.
I am aware, that this is very bad. I had underestimated the power of some of these regular expressions. The reason, why it takes me so long, to fix this for the txp Grammar, is that a couple of other things are wrong as well. So for me as a non-programmer the approach is the following: I regenerated the core-modules of the language, and currently test them one by one,when everything works I put everything together using snippets and macros in plist.scope. I am not getting any errors anymore right now, but it is going to take me some time, as there is a lot of testing involved.
regards, marios
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
when i click on (abstract), and hit the short-cut ctrl-shift-p it says that the scope is tex.log.latex.
I think that your Grammar is ok, and should work correctly when tested from within a project (Not just a scratch file)
The experience, that I have, while working with new Language Grammars, is that one tends to forget what actually is playing in the Bundle Editor. So you want to make sure also, that no other Bundle is overriding your stuff, (As well as your own ones),
You could go through the Bundle Editors filter list and disable various stuff that you suspect. and press the test button after each language change.
You can also try a reload Bundle Items from the menu.
regards, marios
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate