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>
.