2012/06/01: emacs buffer names and uniquify

In emacs, buffers need to be uniquely determined by their name. So, if two files in different directories have the same name, the buffer name cannot simply be the local part of the file name. The default solution is to add a number in angle brackets. This is nice and simple, but hard for humans to remember (when you switch-to-buffer) once you have something like 20 Makefiles open.

Today I started using the uniquify library which makes buffer names unique by adding minimal unique pieces of the path to the file name. In particular, if you open or close the second Makefile, the buffer for the first Makefile changes its name as well.

The way uniquify.el adds itself to the rest of emacs is by adding a hook to kill-buffer-hook and after-advising the functions rename-buffer and create-file-buffer.

Quite a nice example for advice.