Here's an attempt:
Why don't saved multi-hop file names work in a new Emacs session?
By default, multi-hop file names are abbreviated after completing
the initial connection. These abbreviated forms mention only the
I'd say retain instead of mention.
final hop, and so only the Emacs session that generated the
abbreviated form can understand it.
How about ...the originating Emacs session maintains an ephemeral record of the hops, and this will not be available to other Emacs sessions...
For example, after connecting to
/ssh:bird@bastion|ssh:news.my.domain:/opt/news/etc, the file name
becomes /ssh:news@news.my.domain:/opt/news/etc. If the abbreviated
form is saved in a bookmark, the recent files list, bbdb, or
similar, a new Emacs session has no way to know that the connection
must go through bird@bastion first.
There are two mechanisms to deal with this. The first is to
customize tramp-show-ad-hoc-proxies to a non-nil value, which
disables abbreviation. Then the full multi-hop file name is the one
that will be both displayed and saved.
How about ...fully-qualified multi-hop file name...
One nuance is that tramp-show-ad-hoc-proxies must be customized to non-nil _in advance_ of making connections.
Alternatively, you can customize tramp-save-ad-hoc-proxies to a
non-nil value which means to save the full file names, but display
the abbreviated ones.
...fully-qualified file names...
One nuance here is that proxies saved via tramp-save-ad-hoc-proxies are stored in a file local to the originating Emacs session. If one expects to share bookmarks, etc., outside that host, show trumps save, though they are not mutually exclusive options. That would also assume that one's .ssh/config, etc., are also synchronized. Mine are. And I want my Emacs sessions to work as identically as I can manage across hosts modulo platform specifics and perhaps different directory tree contents, and even then, I tend to use identical hierarchies everywhere.
... but is this actually a correct description of the behaviour?
Based on my recent testing and discussions with Michael, this is correct. The Tramp UI could be improved so that fully-qualified names are always retained yet made convenient to use abbreviated file names. That would solve for both persisting remote file names and interactive convenience.
-Stephane