Making Emacs Buffer Names Unique Using the Uniquify Package
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
If you ever work in Emacs with different files that all have the same name, this tip may be very useful for you. In my experience, this most often happens when working with Makefiles from multiple projects or directories. Assuming you have a buffer visiting a file called Makefile, by default Emacs will call the second buffer Makefile<2>. This is not very useful for figuring out which one is which.
The uniquify package
Enter the uniquify package. It offers several options for making buffer names unique. In my .emacs, I have the following two lines of code.
(require 'uniquify) (setq uniquify-buffer-name-style 'forward)
You can set the value to any of the following options, nil being the default. These examples are taken from the help file within Emacs. They use the information from the directories the files are located in to make the names unique. The first buffer called “name” is visiting a file in the directory bar/mumble/, and the second buffer is visiting a file called “name” in directory quux/mumble.
value | first buffer called “name” | second buffer called “name” |
---|---|---|
forward | bar/mumble/name | quux/mumble/name |
reverse | namemumblebar | namemumblequux |
post-forward | name|bar/mumble | name|quux/mumble |
post-forward-angle-brackets | name |
name |
nil | name | name<2> |
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.