The library uniquify overrides Emacs’ default mechanism for making buffer names unique (using suffixes like <2>, <3> etc.) with a more sensible behaviour which use parts of the file names to make the buffer names distinguishable.

For instance, buffers visiting “/u/mernst/tmp/Makefile" and "/usr/projects/zaphod/Makefile” would be named “Makefile|tmp” and “Makefile|zaphod”, respectively (instead of “Makefile” and “Makefile<2>”). Other buffer name styles are also available. To enable this, (require 'uniquify) then customize uniquify-buffer-name-style. (Run M-x customize-option)

uniquify is distributed with GnuEmacs.

About the Unix uniq utility

Note that the uniquify functions provided with Emacs, ‘uniquify-buffer-file-name’, ‘uniquify-rename-buffer’, ‘uniquify-rationalize-file-buffer-names’, deals with the problem of uniqueness of buffer names. It has nothing to do with the problem of removing identical adjacent lines in a given buffer. See DuplicateLines if you want a command which mimics the uniq utility found on Unix systems.

CategoryCustomize CategoryFiles