Archive for October, 2007

Controlling the C in Vim

Friday, October 26th, 2007

So one day you decide to write a fancy plugin for Vim. After months of writing and testing, you let a friend try. Knowing it’s well architected in terms of layered function calls, has error handling for interactions with 3rd party applications, and provides an intuitive key-based user interface — nothing could go wrong!

Then comes along the diabolical CTRL-C. The arch nemesis of event-based programming (esp. in Vim). The ability to arbitrarily cancel any operation in progress, at any step along the way.

You’re friend decides to hit this magic key combination and the plugin comes to a screeching halt…. the status bar is showing an old state; the progress bar is half-way completed but shouldn’t even be visible; and who knows if the 3rd party application was even contacted.

Ugh. back to the drawing board.

After digging through the vim :help docs for the 100th time over the last few months, I found the solution! The exception handling facility lets you capture the CTRL-C interrupt in a catch clause. Here’s the pattern:

try
… <set variables>
… <call 3rd party apps>
… <perform logic>
catch /^Vim:Interrupt$/
… <unset variables>
… <fix user display>
… <display warning/error message>
endtry

One drawback though is that you cannot re-throw the exception once in the catch block. Though, this can easily be remedied by throwing a custom exception, which is probably better anyway — so the higher level layers deal with application-based exceptions, rather than low-level SDK exceptions.

XY Filial 1.1

Tuesday, October 9th, 2007

We’re having a BOY! All the standard tests have shown that development is on track and so-far, so-good! Amy and I are expecting a ton of surprises along the next 6-12 months, so we decided to know the gender up front. And the name… Tyler Patrick Thomas!

Here are some pictures of our son. For obvious reasons, I’ve left out the gender-determining photos ; )

Tyler 22 Weeks - Head

head

Baby Tyler - 22 Weeks - Body

body

Baby Tyler - 22 Weeks - Foot

foot

While Amy is doing most of the clothes shopping and wishlist building these days, I’ve got a few items already on order over at ThinkGeek.com and CafePress.com. Here are two of my favorites:

Binary Kid T-Shirt

Binary Kid

TCP-IP T-shirt

TCP-IP

Baby Tux T-shirt

Baby Tux

WiFi Hi Chair

WiFi HiChair

iPoo T-shirt

iPoo

Input/Output T-shirt

input/output

As the Google flies

Saturday, October 6th, 2007

Lately I’ve been curious about the distance calculator in google Custom Map feature. To provide something to calculate… I went on a jog yesterday leaving and returning from my house.


View Larger Map

As the map shows, I have a 1-mile jog to the ocean and there’s plenty of things to see along the way. The two most prominent features are the 150-step staircase going up the cliff and the old cement boat at the end of the pier.

Total distance: 5.5 miles, as the Google flies.

Given that I didn’t have to bring a pedometer or GPS along, I think this map feature is both handy and close-enough.