emacsautocompletebufferswitch-statementido-mode

Emacs: Switching Between Buffers with the Same Name but in Different Directories


I have two files with the same name but in different directories:

apples/main.cpp
oranges/main.cpp

I open them in one emacs window via emacs apples/main.cpp oranges/main.cpp

When I use C-x b to switch between these two buffers, the buffer names are "main.cpp" and "main.cpp<2>". I would love to be able to see the full path of these two files when switching buffers, so that I may disambiguate between the apples and the oranges version. Is there a way to do this?

One way could be to modify whatever code generates the <2> after the second main.cpp when Emacs detects that a buffer with that name is already open. However, I couldn't find how to do this.


Solution

  • Use uniquify. I use it like that:

    (require 'uniquify)
    (setq uniquify-buffer-name-style 'forward)