1

When I open for example the file syslog.conf on four different hosts with Tramp the buffer names are

  • syslog.conf
  • syslog.conf<2>
  • syslog.conf<3>
  • syslog.conf<4>

When I try to change the buffer with tab completion, this is all I see. The information which buffer belongs to which host is not visible.

Is it possible to tell Emacs to put the name of the remote host into the buffer name?

I would prefer the following buffer names for non local files.

  • syslog.conf@host1
  • syslog.conf@host2
  • syslog.conf@host3
  • syslog.conf@host4

1 Answer 1

1

If the files on each host are in a different directory, you might be able to distinguish them by setting the variable uniquify-buffer-name-style:

From (emacs) Uniquify:

When several buffers visit identically-named files, Emacs must give the buffers distinct names. The default method adds a suffix based on the names of the directories that contain the files. For example, if you visit files /foo/bar/mumble/name and /baz/quux/mumble/name at the same time, their buffers will be named ‘name’ and ‘name’, respectively. Emacs adds as many directory parts as are needed to make a unique name.

You can choose from several different styles for constructing unique buffer names, by customizing the option uniquify-buffer-name-style.

Emacs should do the right thing here. My settings are:

(setq uniquify-buffer-name-style 'reverse)
(setq uniquify-separator "/")
(setq uniquify-after-kill-buffer-p t) ; rename after killing uniquified
(setq uniquify-ignore-buffers-re "^\\*") 

And I get the following buffer names when I open the same file on two hosts:

  • local /etc/hosts is hosts
  • remote /etc/hosts is hosts//scp:<username>@<remotehost>.
3
  • The syslog configuration file is on every host in the same directory.
    – ceving
    Dec 2, 2016 at 15:15
  • I don't have access to a remote host to test this. Can you try setting uniquify-buffer-name-style to something and check what happens when you open the same file on multiple hosts? According to this old bug report, the problem has been reported and fixed for some time: lists.gnu.org/archive/html/bug-gnu-emacs/2008-06/msg00091.html
    – Tyler
    Dec 2, 2016 at 15:21
  • Actually, I found a file I have access to as an example. See my update.
    – Tyler
    Dec 2, 2016 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.