Dear Bazaar...

Our relationship has only just started but it's already time for me to move on. Although I think you're great, Mecurial has become my new best friend. Things with her are just a little easier. We just clicked.

I get along so well with her friends; I never did quite fit in with yours. They always seemed somewhat immature.

It's also hard to ignore recent developments. It seems like Mercurial is going to become quite important in the future.

No hard feelings I hope. I truly wish you all the best for the future.


posted: Wed, 29 Jul 2009 01:03 | permalink | comments

Banishing trailing whitespace with Emacs

One of my pet peeves, especially with Python code, is trailing whitespace. It serves no purpose, introduces noise in diffs and wastes valuable bytes dammit (yes I'm being pedantic).

In order to see make trailing whitespace visible in Emacs you can use the show-trailing-whitespace variable. Emacs of course has a command to remove trailing whitespace: delete-trailing-whitespace.

Better yet, to get rid of trailing whitespace automatically on save you can add a function to the write-contents hook. The following snippet will cause trailing whitespace to be removed on save, but just for Python files.

;; Automatically remove trailing whitespace when saving Python file
(add-hook 'python-mode-hook
          (lambda () (add-hook 'write-contents-hooks 'delete-trailing-whitespace t)))

The one problem with doing this is that when changing an existing codebase your commits could end up with many whitespace deltas, making it difficult to see the meat of your changes. Use with care.

posted: Fri, 03 Jul 2009 12:06 | permalink | comments