[SVN] Re: Align Source
Allan Odgaard
mailinglist at textmate.org
Tue May 24 21:10:41 UTC 2011
I changed the /,/ pattern to /(,)(?!$)/ to avoid inserting trailing whitespace, e.g.:
$headers = array(
'Date' => gmdate(DATE_RFC2822),
'MIME-Version' => '1.0',
'Content-Type' => 'text/plain; charset=UTF-8; format=flowed',
'Content-Transfer-Encoding' => 'quoted-printable'
);
Though I realize that comma might get us too many false positives due to it also separating function arguments, e.g:
a = foo(x, y)
bb = g(42, "str")
We need to build a test suite for this :)
On 24 May 2011, at 22:59, Allan Odgaard wrote:
> On 24 May 2011, at 22:43, Mads Hartmann Jensen wrote:
>
>> Just improved the code so it will sort the regular expressions such that the
>> regular expression whose captures has the lowest offset (across all lines)
>> is used to align first. Provides a better end result in many cases imo :)
>>
>> This will however means that the developers have no change of choosing the
>> precedence of regular expressions (previously the regexps had to highest
>> precedence from left to right in the array).
>
> Sounds acceptable — since these are regexps, one can actually influence it partially by matching a larger part of the line, for example use negative look-ahead if we don’t want a certain pattern to be active say, when a line contains a trailing line comment, etc.
>
> It would be nice if the algorithm strips whitespace before doing the width calculation, for example:
>
> 1. foo = "bar"
> 2. abracadabra = "magic"
> 3. answer = 42
>
> Now if I remove the second line and run the aligner, it won’t decrease the excessive amount of whitespace.
>
> _______________________________________________
> textmate-dev mailing list
> textmate-dev at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate-dev
More information about the textmate-dev
mailing list