[SVN] Re: Align Source

Mads Hartmann Jensen Mads379 at gmail.com
Fri Jun 3 16:19:37 UTC 2011


Having thought some more about it over the last couple of days I believe that
it would be nice if the bundle developer could supply more info than just a
list of regular expressions.


The case at hand is the insertion of space before/after the capture of the
regular expression. The heuristics that we’re currently using (insert before
unless no spacing currently exists) is not ideal in two aspects. Firstly, it
will not format a selection uniformly unless the developer already had space
(or no space) before the capture on every line. Secondly I prefer that the
bundle creator has the ability to enforce some standards for aligning the
source. For example in CSS the ‘:’ is used for assignments so it looks
better (IMO) if they are aligned (I.e. space should be inserted before the
capture).


I’m not sure that I fully understand the capabilities of the TextMate
preference items but an example solution could be the following.


General: 


sourceAlignment = (
    (regexp, spaceBeforeCapture|spaceAfterCapture),
    ...
)


For CSS: 


sourceAlignment = (
    (':',  spaceBeforeCapture)
)


What do you think? Would this be possible? 


Now for something a bit different. As mentioned earlier I’m very interested
in left/right aligning source code as well. To do that properly we would
need the following information 



A regexp with three captures: LHS, delimiter, RHS 
For the LHS and RHS captures it should state if it should be left or right
aligned


If I’m correct and all this info is needed I think that trying to make the
align command do this will add to much unnecessary complexity. However, I
think it would be awesome to make a general “reformat source” command just
as the “align command” that we’re working on now. I think it’s something
that is useful in all programming languages and making it easy for the
bundle developers (they just have to specify some info in a preference item)
will make it more possible that they add support for it :)


For me the alignment and reformatting of the source is quite tightly coupled
but I could just create a macro that ran them both on a selection :) 


Cheers,
Mads

-- 
View this message in context: http://old.nabble.com/Align-Source-tp31636561p31766722.html
Sent from the textmate-dev mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate-dev/attachments/20110603/65d89265/attachment.html>


More information about the textmate-dev mailing list