TextMate strip whitespace and preserve cursor position

There are a lot of bundles and macros out there that exist solely to strip trailing whitespace from the current file whenever you save it. Unfortunately, (almost) all of the whitespace stripping options that I have found share a fatal flaw: they move the cursor to the beginning of the line. This seriously messes with my head, as I never expect saving the file to move the cursor.

I somehow wound up with a bundle that doesn’t move the cursor while it strips whitespace, so I’m posting it here for myself (and anyone else who doesn’t like their cursor jumping around).