Hi,
[novice question alert!]
I would like to tell TextMate that if it encounters a heredoc with the name 'END_SQL' in my perl script, the text within the heredoc is sql. For example:
my $rows = $dbh->selectall_arrayref( <<END_SQL ); SELECT name, city FROM people WHERE country='nl' END_SQL
From
http://macromates.com/blog/archives/2005/07/06/introduction-to-scopes, I get the impression that something like that is possible. But I cannot get it to work. Can someone hint me in the right direction?
It seems TextMate is the only application I know where it is hard to find a solution because there are /too many/ information resources: mailing list, wiki, manual, irc and weblog. ;-)
Thanks
On 11/18/05, Jasper Cramwinckel jasper@cram.nl wrote:
I would like to tell TextMate that if it encounters a heredoc with the name 'END_SQL' in my perl script, the text within the heredoc is sql. For example:
my $rows = $dbh->selectall_arrayref( <<END_SQL ); SELECT name, city FROM people WHERE country='nl' END_SQL
Coincidentally, I just added this type of thing to the PHP bundle -- folding and HTML coloring inside "<<<HTML" heredoc strings. If you do a svn checkout of the bundle repository you can look in Bundles/PHP.tmbundle/Syntaxes/PHP.plist to see it in context. I added this to the "patterns" dictionary:
{ name = 'meta.scope.heredoc'; begin = '(<<<HTML)'; end = '^(HTML);'; captures = { 1 = { name = 'keyword.other.heredoc'; }; }; patterns = ( { include = 'text.html.basic'; } ); },
The other thing I did is add folding (the first two terms in the regex were already there):
foldingStartMarker = '(/*|{\s*$|<<<HTML)'; foldingStopMarker = '(*/|^\s*}|^HTML;)';
I think the changes you'd make for your case are fairly obvious. Hope that helps.
(This was my first commit to the bundle repository, incidentally, so other more experienced TM hackers should jump in if I've made any dumb mistakes.)
pb
-- Paul Bissex http://e-scribe.com/news/ Northampton MA USA 01061-0847