Subject: bug#76457: 31.0.50; Cannot create bookmark to chained TRAMP connection

From: Sean Whitton <[email-masked]>
Date: Sat, 22 Feb 2025 20:11:25 +0800

Hello,

On Sat 22 Feb 2025 at 10:12am +01, Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:

> Sean Whitton <[email-masked]> writes:
>
>> Hello Michael,
>
> Hi Sean,
>
>>> --8<---------------cut here---------------start------------->8---
>>>    • Why saved multi-hop file names do not work in a new Emacs
>>>      session?
>>>
>>>      When saving ad-hoc multi-hop TRAMP file names (*note Ad-hoc
>>>      multi-hops::) via bookmarks, recent files, filecache, bbdb, or
>>>      another package, use the full ad-hoc file name including all
>>>      hops, like ‘/ssh:bird@bastion|ssh:news.my.domain:/opt/news/etc’.
>>>      This is achieved by setting the user option
>>>      ‘tramp-show-ad-hoc-proxies’ to non-‘nil’.
>>>
>>>      Alternatively, when saving abbreviated multi-hop file names like
>>>      ‘/ssh:[email-masked]:/opt/news/etc’, the user option
>>>      ‘tramp-save-ad-hoc-proxies’ must be set non-‘nil’ value.
>>> --8<---------------cut here---------------end--------------->8---
>>>
>>> Does this help?
>>
>> Thanks!  The first paragraph is helpful, but then the second paragraph
>> confuses me a bit.  What is the relationship between the two options?
>
> I tried to say it with the beginning of the second paragraph.
> "Alternatively, ..." means, that both options are independent from each
> other.
>
> My English is notoriously bad. If you have a better phrasing, pls let me know.

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
    final hop, and so only the Emacs session that generated the
    abbreviated form can understand it.

    For example, after connecting to
    /ssh:bird@bastion|ssh:news.my.domain:/opt/news/etc, the file name
    becomes /ssh:[email-masked]:/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.

    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.

... but is this actually a correct description of the behaviour?

>> Also, why is tramp-show-ad-hoc-proxies not non-nil by default?
>> Just a matter of preserving backwards compatibility?
>
> The majority of Tramp users prefers the abbreviated form "/sudo:root@host:"
> when they have started with "/ssh:host|sudo::". This works as expected,
> unless you want to keep this over Emacs session boundaries. So it is a
> convenience default to initialize this option with nil.

I see, cool.

-- 
Sean Whitton