Create To Do Lists from Comments in TextMate

Sunday, May 13th, 2007 at 19:47 Sunday, May 13th, 2007 at 19:47

Test Driven Developemnt and GTD both employ To Do lists to keep track of tasks. I've been a big fan of these task lists, but I've found that I have way too many items on my list to keep them organized. These days I prefer to keep my development-related todo items in the comments of the source code. This allows me to associate the todo item with a specific place in the code, while adding additional documentation to the project. I use a couple of different markers to denote different types of todo items, all based on the C-style single line comment, //:

  1. //! Check this line later on.
  2. //x Delete this line later; only needed during development.
  3. //+ To Do item; an unfinished task.
  4. //- Refactor this line later on.
//! Check this line later on.
//x Delete this line later; only needed during development.
//+ To Do item; an unfinished task.
//- Refactor this line later on.

It's become almost second nature to type //! after a line I think might need some attention, or //x after a line that needs to be removed before going to production. You can do a search for these specific comments to immediately find all lines that need to be reviewed. //- especially has made my life easier; we all know that "Premature optimization is the root of all evil", but I've always been hesitant to leave optimization until later, fearing that I would forget to do it. Now I just mark the line with the comment and forget it, knowing that I'll come back to it later.

The one tool that really makes these comments useful is the TODO bundle in TextMate. After modifying the bundle a bit to search for my comments, I can now type ⌃⇧T to get a complete list of all of these todo items, with links to the exact lines where they appear. Here is how I modified the "Show TODO List" command:

TODO Bundle Modifications

You can change the bundle to search for any specific string, such as //todo or //fixme, so you don't have to change your current practice to take advantage of this. This is just another reason why I am completely hooked on TextMate.

Namespace Preferences Added to the YUI Bundle

Monday, March 5th, 2007 at 20:36 Monday, March 5th, 2007 at 20:36

The YUI bundle for TextMate has been updated for the 2.2.0 release, with support added for the DataTable, Button, History, Element, and DataSource libraries. The most interesting thing about this update, though, is the support for using your own variables in place of the long YAHOO.util.foo style namespaces. To edit these, go to the Bundle Editor and select Namespace Preferences under the JavaScript YUI bundle. You should see something like this:

  1. {shellVariables = (
  2. {name = 'BUILD';
  3. value = '2.2.0';
  4. },
  5. {name = 'YUI_LANG';
  6. value = 'YAHOO.lang';
  7. },
  8. {name = 'YUI_DOM';
  9. value = 'YAHOO.util.Dom';
  10. },
  11. {name = 'YUI_EVENT';
  12. value = 'YAHOO.util.Event;
  13. },
  14. {name = 'YUI_CONNECT';
  15. value = 'YAHOO.util.Connect';
  16. },
  17. {name = 'YUI_ANIM';
  18. value = 'YAHOO.util.Anim';
  19. },
  20. );
  21. }
{	shellVariables = (
		{	name = 'BUILD';
			value = '2.2.0';
		},
		{	name = 'YUI_LANG';
			value = 'YAHOO.lang';
		},
		{	name = 'YUI_DOM';
			value = 'YAHOO.util.Dom';
		},
		{	name = 'YUI_EVENT';
			value = 'YAHOO.util.Event;
		},
		{	name = 'YUI_CONNECT';
			value = 'YAHOO.util.Connect';
		},
		{	name = 'YUI_ANIM';
			value = 'YAHOO.util.Anim';
		},
	);
}

You can replace any of those with whatever variable you prefer to use. I usually set them to two or three letter abbreviations of the full namespace:

  1. {shellVariables = (
  2. {name = 'BUILD';
  3. value = '2.2.0';
  4. },
  5. {name = 'YUI_LANG';
  6. value = 'YL';
  7. },
  8. {name = 'YUI_DOM';
  9. value = 'YD';
  10. },
  11. {name = 'YUI_EVENT';
  12. value = 'YE';
  13. },
  14. {name = 'YUI_CONNECT';
  15. value = 'YC';
  16. },
  17. {name = 'YUI_ANIM';
  18. value = 'YA';
  19. },
  20. );
  21. }
{	shellVariables = (
		{	name = 'BUILD';
			value = '2.2.0';
		},
		{	name = 'YUI_LANG';
			value = 'YL';
		},
		{	name = 'YUI_DOM';
			value = 'YD';
		},
		{	name = 'YUI_EVENT';
			value = 'YE';
		},
		{	name = 'YUI_CONNECT';
			value = 'YC';
		},
		{	name = 'YUI_ANIM';
			value = 'YA';
		},
	);
}

Now anytime you use one of the snippets (for instance, type gettab), you will see YD.get() instead of YAHOO.util.Dom.get(). Every single library has support for this, so if you want to use a namespace for a library not listed in the preferences, you can simply add it yourself. Code in the form of ${YUI_FOO:...} in any of the snippets means that the variable YUI_FOO can be added to the preference file. You can output all of your new variables by typing nametab. You should see something like this:

  1. var YL = YAHOO.lang;
  2. var YD = YAHOO.util.Dom;
  3. var YE = YAHOO.util.Event;
  4. var YC = YAHOO.util.Connect;
  5. var YA = YAHOO.util.Anim;
var YL = YAHOO.lang;
var YD = YAHOO.util.Dom;
var YE = YAHOO.util.Event;
var YC = YAHOO.util.Connect;
var YA = YAHOO.util.Anim;

Add this to the top of your code and you're all set. As always, you can use the GetBundle bundle to download the new version, or grab the zip file directly.

Be a part of the interface.

Friday, February 9th, 2007 at 8:31 Friday, February 9th, 2007 at 8:31



Changing the face of computing

Web 2.0 in under 5 minutes

Friday, February 9th, 2007 at 7:32 Friday, February 9th, 2007 at 7:32

Macworld 2007

Saturday, January 13th, 2007 at 18:01 Saturday, January 13th, 2007 at 18:01

The iPhone, inside a spinning glass case.

I went to the last day of the Macworld Expo yesterday, and took a whole bunch of photos. It was my first Macworld, and I was surprised at how big it was; the entire Moscone North and South buildings were totally filled.

For me, the best parts were the demos that Apple was putting on. The Apple TV and OS X Leopard demos were ok, but the really good one was on the iPhone. I saw a few of these hour-long demos (since I was at the Expo for most of the day), and it was interesting to see some of the problems that the guys giving the demo were having. At the last demo of the day, the iPhone just flat refused to turn on. After taking it backstage for 20 minutes, we saw a boot screen (looks just like recent iPod's boot screen) and finally got the hands-on demo. A few other problem areas came up over the day: merging calls, fetching email from the server, web pages becoming partially transparent when scrolling (while zoomed in), and lots of accidental clicks (some of the UI elements look a little too small to be targeted with a finger).

They have six months to iron out the kinks, so I'm not too worried. It just goes to show how good Steve Jobs is at giving the keynotes. His demos went so flawlessly that you'd never know it was a prerelease version.


Recent Posts

Navigation