[SVN] Re: Align Source

Allan Odgaard mailinglist at textmate.org
Wed May 25 15:34:23 UTC 2011


On 25 May 2011, at 08:58, Mads Hartmann Jensen wrote:

> I don't usually use ruby so I don't know any test tools - can you recommend a
> simple one?

James?

We’ve been talking loosely about providing a testing system for TM commands. IMO this should be language neutral, so I (i.e. TextMate) provides a “command runner” (CLI) that takes input and expected output.

So perhaps this is my cue to put out a prototype for this.

Of course if I provide a test runner, this would require the thing to be a tmCommand, not a stand-alone ruby script. But that’s hardly a concern, what I really is focused on wrt. tests for this command is that we collect a versatile set of test cases, so we can tweak the code and patterns w/o doing the wrong thing on code in the wild and/or see how it affects that code.

> I'll take care of stripping whitespace later today but besides that what do
> we still need to fix?

Nothing really springs to mind. I’ve replaced my Align Assignments with your version and will use it whenever I get a chance — actually considering if I should setup a cron job to regularly poll gist for latest verison ;)

Unfortunately (sort of) I’m traveling for the next two weeks, so amount of coding I’ll get done is likely limited.

> I would really love to be able to right/left align text around a capture so
> it would be able to align the following automatically: 
> 
> private[process] final class Streamed[T](
>  val process:   T => Unit,         // comment 1
>  val    done: Int => Unit,         // comment 2
>  val  stream:  () => Stream[T]     // comment 3
> )
> 
> The rules are as follows:
> 
> - right justified names aligned on the colon
> - arrows with right justified in-types and left justified outs
> - comments with left justified text

A somewhat similar example is this (Objective-C):

  [NSAlert alertWithMessageText:foo
    defaultButton:bar
    alternateButton:fud
    otherButton:baz
    informativeTextWithFormat:bar];

Some like to reformat this as:

  [NSAlert alertWithMessageText:foo
                  defaultButton:bar
                alternateButton:fud
                    otherButton:baz
      informativeTextWithFormat:bar];

Presently this is handled by overloading ⌃Q in the “call selector scope” with a special script to do this reformatting. So I wouldn’t make this a goal, to also be able to handle it with Align Assignments, but of course, if it would be possible, that would be awesome :)

Remember that because we just have a list of regexps, we can add the proper pattern only for the obj-c scope, even limit it to inside […] as we have a scope for that — that is, when we (optionally) read the list from the environment.




More information about the textmate-dev mailing list