[SVN] Any chance of a little help sorting this language regexp to make php coding less painful in textmate?

Chris Adams wave at chrisadams.me.uk
Tue Dec 14 19:32:23 UTC 2010


Hi there,

I'm been trying for the last few hours to understand how Textmate's
handling of language syntaxes works, and more specifically how it
handles code foldings, and I can't for the life of me work out how to
do something that sounds embarrassingly simple.

I'm trying to make the php language declaration treat 'array()' the
same way as it treats '{}' or '()', where the contents of the closure
can be folded down for greater readability, using the normal text
folding commands available in Textmate.

Here are the standard folding stop and start markers for php:

	foldingStartMarker = '(/\*|\{\s*$|<<<HTML)';
	foldingStopMarker = '(\*/|^\s*\}|^HTML;)';

Based on these regular expressions, I'd expect to need something like this:

	foldingStartMarker = '(/\*|\{\s*$|<<<HTML|array\(\s*$)';
	foldingStopMarker = '(\*/|^\s*\}|^HTML;|^\s*\),)';

Taken more slowly, for the foldingStartMarker, as in:

array\(\s*$

I mean

any pattern starting with 'array(' that then ends then ends with a
linebreak, allowing for any amount of whitespace beforehand

And then ends with

^\s*\),

Or in something closer to english:

Any amount of whitespace from the beginning of a line, ending with a
closing parenthesis and a comma

Yet none of the approaches or variants I have tried now seem to work,
and I'm now reduced to guessing at the right regular expression here.

I can't be the only textmate user who has to use php sometimes, and
being able to fold arrays would make a lot of php code much less
unpleasant to read.

Can a charitable soul help put me right here?

I've put together a sample gist here, to test any working regular
expressions against.


https://gist.github.com/736311


-- 
Chris Adams
mob: 07974 368 229
tel: 0207 558 8971
skype: chris.d.adams
twitter: mrchrisadams



-- 
Chris Adams
mob: 07974 368 229
tel: 0207 558 8971
skype: chris.d.adams
twitter: mrchrisadams


More information about the textmate-dev mailing list