Emacs: more convenient unique buffer names

Christian Kruse,

In Emacs each buffer has a unique name. For file buffers the name is derived from the file name, so for example a buffer associated with the file README is named README. This is fine as long as you don't open files with the same name. To ensure the uniqueness of the buffer name Emacs will append a number to the buffer name, for example README<1>.

This makes it somewhat hard to distinguish file buffers. Gladly there is a solution for that: Uniquify. This module lets you choose a different variant to generate unique buffer names: directories. It will use parts of the directory to make the buffer name unique, for example cforum/README instead of README.

I configured it to append the directory parts to the buffer name instead of prepending it, in this way the name is still the most prominent info:

(require 'uniquify)
(setq uniquify-buffer-name-style
      uniquify-separator ":")