[TxMt] sql in perl
Paul Bissex
paul.bissex at gmail.com
Fri Nov 18 16:57:29 UTC 2005
On 11/18/05, Jasper Cramwinckel <jasper at 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
More information about the textmate
mailing list