I'm helping a group that I consult with in customizing TextMate for their PHP development.
They have a library of functions within their company that they want to have syntax-highlighted, similar to the built-in PHP functions.
I accomplished this by creating a custom bundle, making a scope for their functions and adding the appropriate functions to the patterns section of the new language file.
My problem is this: In order to get this new scope included with PHP files, I modified the default PHP.tmbundle with { include = 'source.php.ccb'; },
This works great, everything highlights. *But*, now this is a custom PHP bundle, and any updates to the default will be masked, until the new default is manually changed.
Is there any way that I can "inject" my new scope into the PHP bundle without modifying the PHP bundle itself? I tried adding another language to my custom bundle, and just putting the include line in for the source.php scope. This disabled all the other PHP functionality.
Thanks for the help, Ken Scott
Reverse your method, include PHP in your syntax. That way you keep getting updates to the PHP syntax and such. All you have to do is then select your new syntax in the language popup at the bottom of the window.
On Mar 18, 2006, at 3:55 PM, Michael Sheets wrote:
Reverse your method, include PHP in your syntax. That way you keep getting updates to the PHP syntax and such. All you have to do is then select your new syntax in the language popup at the bottom of the window.
I think this would work with most languages, but PHP is included into the HTML bundle, and that is the language that is actually selected for doing PHP syntax highlighting.
If I included PHP to mine, I would then want to modify HTML, and have the same issue.
Ken
On 19/3/2006, at 3:47, Ken Scott wrote:
[...] If I included PHP to mine, I would then want to modify HTML, and have the same issue.
Yes -- unfortunately there is no good solution to this problem ATM.
One could create both a new PHP and a new HTML (which include the old HTML and your new PHP).
So something like:
// custom PHP { name = "source.php.custom"; patterns = ( ... // our rules { include = "source.php"; } ); }
// custom HTML { name = "text.html.custom"; ... // folding markers and stuff patterns = ( { begin = '<?php'; end = '?>'; include = "source.php.custom"; }, { include = "text.html.basic"; } ); }
With this approach only the “root” <?php … ?> constructs though would get the custom PHP rules. To have it used e.g. also in attribute values, one would have to replicate more of the HTML grammar.