TextMate Makefile Bundle

Posted by matt
on Saturday, August 01

Recently, I’ve needed to write and use various Makefiles. I was disappointed to find the TM’s syntax highlighting lacking, and just not colourful enough, so I set about adding a few bits and pieces.

You can find the result on GitHub.

I was pleased to find that most of the official TM bundles are now there, so if you’re making small (or massive) tweaks and improvements, it’s should now be easier than ever to get your changes merged into TM proper.

Learning Perl (and Perlcritic for TextMate)

Posted by matt
on Thursday, February 19

Now, just just leave straight away, but I’m learning perl. I know I’ve only just started waxing lyrical about python, but bear with me, I’ve not got any plans to dump anything else: I just need to learn perl for work. (If you read on in this post, you’ll find some ruby code, too!)

So, armed with some of the ideas from comments on my last post, I’ve tried to build make use of some of the most trendy web resources to help me on my way. Ideally, I’d like to pick up on best practices as I go along.

information overload

So far though, I’m not having a huge amount of luck. I’ve worked through learning perl, and I’ve finished reading it feeling like I don’t know anything like the whole story. To be perfectly honest, I’m quite surprised at the complexity of what seems like a small language!

I’ve got a huge pile of books to help though, so I’m going to start digging through programming perl, and setting myself programming goals. My aim is to work out how to write simple modules and unit tests by the end of next week. I’d also like to find some rake/paver equivalent, and work out how to effectively use Devel::REPL (which stackoverflow helped me find.) Soon I’ll have my automation / test safety net at the ready, so things can proceed a little faster.

Whilst casting around, I found Perl::Critic, a module (and front-end) for checking your code’s adherence to best practices (incidentally, there’s a great book called perl best practices – another one on the pile!).

I decided to write a TextMate command for the perl bundle to run code through perlcritic, since there isn’t one. After a little help from the bundle developers mailing list, I came up with the following:

To run this, you will need a new copy of the TextMate Support directory. I’d suggest using GetBundles. I’ve sent a patch to the perl bundle to the ML, but in the mean time, if you paste the above code into a bundle command, set the scope to source.perl, and trigger to ⇧⌘C, you should get it working fine.

Update: I’ve just started reading programming perl, and I wish I’d started with it! I’m already feeling like I’m learning more useful stuff than was contained in learning perl. I guess I’m not the target audience of that, but I wish I’d known last week!

Adverb Detection in TextMate

Posted by matt
on Tuesday, February 10

After seeing lifehacker, I was inspired to add an adverb detector to TextMate’s markdown grammar, since that’s the format I use to write blog posts.

Far from being a couple of hours work, this was dead simple, and involved adding a couple of tiny bits to the grammar, here’s how to do it:

First, fire up TextMate’s Bundle Editor, press ⌃⌥⌘B. Then scroll to markdown, expand it, and find the Markdown Language grammar. This will be marked with a small grey L. Add the following to the repository section:

    adverb-detector = {
        name = 'invalid.adverb';
        match = '(?!\b(supply|apply|family|only|prolly|folly|sully|rally|waverly|reply|early|probably)\b)\b(\w+ly)\b';
    };

Now scroll to the section headed inline, and add:

    {   include = '#adverb-detector'; },

To the patterns part. Finally, check you have a rule called Invalid in your TextMate theme, with the scope selector invalid. This rule is used to highlight a multitude of sins, so it’s probably already in your theme. Mine looks like this:

invalid_selector
Uploaded with plasq’s Skitch!

adverb_detection.mdown

TextMate Command: Add comments to end of line

Posted by matt
on Sunday, December 14

After reading this message on the textmate-users mailing list, I decided to have a go at writing a command to add comment chars to the ends of lines. Here’s what I ended up with:

To use it, create a command in TextMate’s bundle editor, then make a new command, and set the input and output dropdowns to look like this:

end-of-line-comments
Uploaded with plasq’s Skitch!

Finally, set up scope selections (e.g. source.python, source.shell, …), and a key binding if you want one.

IPython TextMate Bundle: Future Directions

Posted by matt
on Tuesday, December 09

IPython Server

Now that the IPython TextMate bundle has been around for a little while, and has struck a chord with the TextMate wielding, IPython hacking community, I decided that now might be a good time to sum up a few of my ideas for the future.

I’ve really been heartened by the response and enthusiasm of the IPython community, and of particular note is the work by Brain Granger. Brian is currently working on a Twisted based editor server for TextMate (and other editors too), with a block based protocol for robust communications. You can find some initial work in Launchpad, and grab it using bazaar using:

lp:~ellisonbg/ipython/textmate-server

Just be aware that this branch/link might not be around for long.

My top priority for the bundle with regards to this is the creation of a client library, probably also based on Twisted. It would be great to have this core library included in IPython, so it can be called on by other editors.

Core Bundle Content

I think that the core of the bundle is fairly coherent (at least for me!), with the most useful commands appearing at the top of the list. I ideally though, all communications with IPython should be done through the server, so the debugging commands need work in that respect.

My top priority for this area is the implementation of a more user-friendly preferences / config. method. Here’s my initial stab at creating a nib. I now need to work out how best to hook it up with tm_dialog, to store the preferences. Hopefully recent changes to dialogs in TM will make this easier.

IPython Preferences
Uploaded with plasq’s Skitch!

Snippets / Scipy

A lot of IPython users, myself included, are using IPython for scientific computing and number crunching. For that reason, decent support for scientific python libraries is essential.

Thanks to Ben Racine, we’ve got some decent snippets for scipy/numpy/pylab, and we’re adding more fairly regularly. Feel free to send me your ideas, and I’ll be sure to implement them if I can.

Documentation and Demos

The bundle documentation is fairly complete, and since it’s combined with the README, it’s fairly easy to maintain. This is a good thing.

Demo-wise, so far there’s only the first screencast I made. I’m extremely surprised to see it has over 200 views, so I’m planning on making more short and sweet screencasts, which we can hopefully integrate with the bundle’s help.

You Contributions

Are very, very welcome. Please join the [google group](http://groups.google.com/group/ipython-tmbundle/ “ipython-tmbundle | Google Groups”), or if you’re a gihubber, you can fork the bundle, make your own changes and send me a pull request. Only with help can we make this bundle all it can be.