[TxMt] Re: textmate perl bundle

Gerd Knops gerti-textmate at bitart.com
Sat Feb 11 18:07:03 UTC 2006


On Fri, Feb 10, at 11:38 PM, Eric Hsu wrote:

> hi Sebastian Friedrich,
>
> I am copying this reply to the textmate user list (which you can  
> join at http://lists.macromates.com/mailman/listinfo/textmate),  
> since I am a bit crunched for time right now.
>
> Original request:
>> i saw that you are maintaining the perl bundle for textmate. if  
>> that's the case, is there any possibility to add html (or even sql  
>> for that matter) syntax coloring in HERE documents in similar ways  
>> that js/css/php scope is activated within html. I find myself  
>> having to edit lots of html within perl scripts (yeah, nobody i  
>> work with uses templating) and it would be quite helpful if  
>> there's a way to turn on HTML scope within those HERE blocks.
>>
>> for instance, a HERE keyword like HTML_BLOCK would trigger all  
>> content to be html scope with variables ($, @) highlighted as such.
>>
>> print <<HTML_BLOCK;
>> [HTML]
>> HTML_BLOCK
>>
>> any chance you would like to implement that or could give me some  
>> hits on how to get this to work. Thanks so much in advance.
>
> I think this should be pretty straightforward, declaring  
> the .heredoc scopes to inherit styling from html (in cases where  
> all heredocs are HTML styled) or making a new .heredoc-html scope  
> to match only names with "HTML" in them which then inherit from  
> HTML styles.
>
> Could someone on the list help out with details?

Below my perl extensions. Create a new language and paste the  
contents. This will (amongst other things) add the desired by calling  
a heredoc 'HTML' or 'CSS'.

Gerd

======cut======

{	scopeName = 'source.perl.gerd';
	firstLineMatch = '^#!.*\bperl\b';
	fileTypes = ( 'pl', 'pm', 'pod' );
	foldingStartMarker = '(/\*|(\{|\[|\()\s*$)';
	foldingStopMarker = '(\*/|^\s*(\}|\]|\)))';
	patterns = (
		{	name = 'comment.very_important';
			match = '^.*@@@.*$\n?';
		},
		{	name = 'comment.line.entire';
			match = '^(#).*$\n?';
		},
		{	name = 'entity.name.class';
			match = '^\s*package\s+.*$\n?';
		},
		{	name = 'other.function';
			match = '^\s*(sub)\s*([^\(]*)(.*)';
			captures =
			{	1 = { name = 'keyword.control.perl'; };
				2 = { name = 'entity.name.function'; };
				3 = { name = 'storage.type.method'; };
			};
		},
		{	name = 'keyword.control.perl';
			match = '\b(sub)\b';
		},
		{	name = 'meta.leading-tabs';
			begin = '^(?=\t)';
			end = '(?=[^\t])';
			patterns = (
				{	match = '(\t)(\t)?';
					captures =
					{	1 = { name = 'meta.odd-tab'; };
						2 = { name = 'meta.even-tab'; };
					};
				}
			);
		},
		{	name = 'string.unquoted.heredoc.doublequote.html.perl';
			begin = '<< *"([	s]*HTML)" *;';
			end = '^\1$';
			patterns = (
				{	name = 'variable.other.readwrite.global.perl';
					match = '[\$\@\%][a-zA-Zx7f-xff\$][a-zA-Z0-9_x7f-xff\$]*\b';
				},
				{	include = 'text.html.basic'; },
			);
		},
		{	name = 'string.unquoted.heredoc.doublequote.css.perl';
			begin = '<< *"([	s]*CSS)" *;';
			end = '^\1$';
			patterns = (
				{	name = 'variable.other.readwrite.global.perl';
					match = '[\$\@\%][a-zA-Zx7f-xff\$][a-zA-Z0-9_x7f-xff\$]*\b';
				},
				{	include = 'source.css'; },
			);
		},
		{	name = 'string.unquoted.heredoc.quote.html.perl';
			begin = "<< *'HTML' *;";
			end = '^HTML$';
			patterns = ( { include = 'text.html.basic'; } );
		},
		{	name = 'string.unquoted.heredoc.quote.css.perl';
			begin = "<< *'CSS' *;";
			end = '^CSS$';
			patterns = ( { include = 'source.css'; } );
		},
		{	include = 'source.perl'; },
	);
}



More information about the textmate mailing list