[TxMt] Re: [Python Bundle] Suggestions "stolen" from Ruby Bundle and bugs from the latest SVN

Jacob Rus jrus at hcs.harvard.edu
Tue Dec 12 12:05:53 UTC 2006


Ryan Wilcox wrote:
> Hello fellow Python Bundle users,
> 
> I've been learning more about the Ruby bundle, and I have some ideas on how to make the Python bundle better. Some of them are blatantly stolen from the Ruby bundle, some of them I came up independently myself when I was using BBEdit, and thought they would be useful in the Python bundle.
> 
> 
> #1: Create Dictionary From:
>     I thought Ruby could take the selected text and make a hash out of
>     it. (looking in the TextMate book now of course I can't find it).
>     I wrote something similar, turning the following text into a
>     dictionary:
>     
>     a = 1
>     b = 2
>     
>     --> result: {'a': '1', 'b': '2'}
> 
>     You'll find my script at the bottom of this email

Like Alex Ross, I don't think this is particularly useful.  Instead, you 
can just add a few characters, turning:

     a = 1
     b = 2

into:

     dict(
       a = 1,
       b = 2
     )

Or you can even take out the line breaks quite simply.  A very simple 
regular expression can do this transformation quite handily.  The main 
reason I see no reason for this though, is that you usually don't 
explicitly construct very big hashes, instead building them from some 
parsed file or something.  Beyond that, your example has at least one 
problem: how do you know whether the 1 and 2 should be integers or strings?

> #2: Support for syntax coloring doctests
> 
>     Wouldn't it be cool to have doctests syntax colored like code, and
>     not comments?

Yeah, save this for scope injection in 2.0.  It will work quite well, 
I'm sure.

>     Likewise, it looks like the folding marker for Python comments
>     folds on a blank line. That means folding doesn't work very well
>     for doctests or comments with blank lines in it.

Yeah, this indeed sucks.  TextMate's folding is kind of broken at the 
moment ;).  Hopefully this one will be fixed when 2.0 comes out in a few 
months.

> #3: super() in class snippet
> 
>     It would be cool if the class snippet inserted super(...) into the
>     constructor for the class. (Is this possible with clever
>     mirroring?)

How would this work?  Can you give an example?

-Jacob




More information about the textmate mailing list