All my troubles with TextMate seem to do with language grammars. Here's another issue I can't work out on my own...
I'm trying to add " case 'something': " to the Symbol List in the PHP language grammer. I've added the following pattern:
{ name = 'meta.symbol-list.php'; match = "\bcase\s+[^:]+:"; },
And after also adding a showInSymbolList preference item it does place all case items into the symbol list. But the unfortunate side effect is that the text is now not in the keyword.control.php scope, so has no syntax highlighting.
How to give more than one scope name to a pattern? I don't want to include ALL the matches for keyword.control.php in my symbol list.
Thanks, Quinn
On 7/3/2006, at 7:03, Quinn Comendant wrote:
How to give more than one scope name to a pattern? I don't want to include ALL the matches for keyword.control.php in my symbol list.
You can name captures [1], so you want to capture the case part, and likely the label part, and assign an (additional) name to that.
[1] http://macromates.com/textmate/manual/language_grammars#rule_keys
How to give more than one scope name to a pattern? I don't want to include ALL the matches for keyword.control.php in my symbol list.
On Tue, 7 Mar 2006 10:47:14 +0100, Allan Odgaard wrote: You can name captures [1], so you want to capture the case part, and likely the label part, and assign an (additional) name to that.
[1] http://macromates.com/textmate/manual/language_grammars#rule_keys
That works. I'm not sure if I did exactly as you suggested, but here is what I came up with:
{ /* Q: Capture for symbol list: case 'xxx' : */ match = "\b((case)\s+('.*?')\s*(:))"; captures = { 1 = { name = 'meta.symbol-list.php'; }; 2 = { name = 'keyword.control.php'; }; 3 = { name = 'string.quoted.single.php'; }; 4 = { name = 'keyword.operator.string.php'; }; }; },
Oh, and a big question just occurred to me in my rampant editing of all my bundles: How will we ever manage merging upgraded bundles into our changes? I've followed the instructions on the website to "svn co" the bundles I want from macromates.com into /Library/Appl...TM/Bundles. But once I make one modification to, say, the language bundle for PHP, isn't the old copy moved to ~/Libarary/... and thus the svn updates ignored? Perhaps "svn co" into my ~/Libarary/... folder would have been smarter since then I could merge changes...but, uh, that's sounds like a lot of work.
What is the "best practice" here?
Q
On 8/3/2006, at 5:48, Quinn Comendant wrote:
That works. I'm not sure if I did exactly as you suggested, but here is what I came up with: [...]
It looks correct :)
Oh, and a big question just occurred to me in my rampant editing of all my bundles: How will we ever manage merging upgraded bundles into our changes? I've followed the instructions on the website to "svn co" the bundles I want from macromates.com into /Library/Appl...TM/Bundles. But once I make one modification to, say, the language bundle for PHP, isn't the old copy moved to ~/Libarary/... and thus the svn updates ignored?
Yes (copied) -- so after a change, you no longer will see updates to that file.
Perhaps "svn co" into my ~/Libarary/... folder would have been smarter since then I could merge changes...but, uh, that's sounds like a lot of work.
If you are semi-skilled with svn, it shouldn’t be that big a problem. svn will generally handle the merging. Only when major changes happen, would merge conflicts arise, which you would then have to resolve by hand.
What is the "best practice" here?
Normally for language grammars, the best practice is to create a new grammar which include the old one. I should write up a section about this in the manual.
However, PHP is problematic because it is included by HTML -- so creating a new PHP grammar would not have that be the one used by HTML files, which makes the above “best practice” useless.
So currently there is none for included grammars (like PHP). I do hope to soon come up with a neat solution for this problem though…
On Mar 7, 2006, at 10:01 PM, Allan Odgaard wrote:
On 8/3/2006, at 5:48, Quinn Comendant wrote:
[snip]
What is the "best practice" here?
Normally for language grammars, the best practice is to create a new grammar which include the old one. I should write up a section about this in the manual.
However, PHP is problematic because it is included by HTML -- so creating a new PHP grammar would not have that be the one used by HTML files, which makes the above “best practice” useless.
So currently there is none for included grammars (like PHP). I do hope to soon come up with a neat solution for this problem though…
Could it be possible to have new mentions of the same scopeName in different bundles be additive, instead of the last one winning?
Then, in MyPHP.tmbundle I could have a language definition for source.php that injects my bundle into the existing PHP bundle. Not sure how to handle the inevitable collisions.
Ken
On 19/3/2006, at 5:17, Ken Scott wrote:
Could it be possible to have new mentions of the same scopeName in different bundles be additive, instead of the last one winning?
That sounds like an awesome idea!
Or maybe more of an “extends” directive. That would also make it clear which one is the extension (I assume that the extension should have the rules injected first in the existing grammar, so that it can override stuff).
Could it be possible to have new mentions of the same scopeName in different bundles be additive, instead of the last one winning?
That sounds like an awesome idea!
Or maybe more of an “extends” directive. That would also make it clear which one is the extension (I assume that the extension should have the rules injected first in the existing grammar, so that it can override stuff).
Which also bring to light the feature I've asked for, a flag to make a syntax not appear in the popup. Just for cases like this. ;)
I like it, i like it. There is some stuff that I'd like to add to a bunch of bundles, but i doubt that all the bundle authors and everyone else in the (TextMate) universe wants all my goofy add-ons.
What I'd like to be able to do is just created a language-extension for ruby (for example) and all I have to do to use it is, nothing. It just knows that it's an extension and TM bolted it onto ruby whenever i'm in ruby, without having to manually select my language-extension from the list.
Can we do that now? without modifying the main bundle we're extending?
subtleGradient
On Mar 18, 2006, at 11:27 PM, Allan Odgaard wrote:
On 19/3/2006, at 5:17, Ken Scott wrote:
Could it be possible to have new mentions of the same scopeName in different bundles be additive, instead of the last one winning?
That sounds like an awesome idea!
Or maybe more of an “extends” directive. That would also make it clear which one is the extension (I assume that the extension should have the rules injected first in the existing grammar, so that it can override stuff).