One problem that I have with emacs is that it doesn’t seem to handle like-named files in different directories very well. For example, if I’m not careful, I’ll end up with 20 __init__.py buffers open. What I’ve been doing is using M-x rename-buffer and renaming it to indicate what package it’s within. However, doing this manually is somewhat tedious.
Does anyone have any strategies for attacking this problem?
I like uniquify, which comes with Emacs:
With those settings, the directory gets added to the buffer name, giving you an indication of where the file is. For example, loading the files
/some/path/to/Makefileand/some/path/to/different/Makefilewould result in the following buffer names:and
uniquifyalso handles updating the buffer names when buffers are deleted, so when one of the twoMakefilebuffers is deleted, the other gets renamed to simplyMakefile.