dan...@friendly-machines.com writes:

> Hello,

Hi Danny,

> Multi hop connections seem to react weird.

They don't.

> I'm trying to have the following setup work:
>
> Say I have hosts "test" and "prod" that are accessible via SSH.
>
> Both contain a similar docker setup, among which there is a container
> "server".
>
> Both contain a git checkout of the same project (different branch) in
> some directory (same name on both systems).
>
> Now I want to put an org file called "actions.org" into the git repo and
> thus accessible via SSH from my laptop, let's call the laptop "blub".
> The org file is checked out in the directory mentioned above.
>
> The host "blub" runs emacs.
>
> TRAMP will open "actions.org" in the emacs on blub from "prod"
> (correctly) using a link like /ssh:prod:/foo/actions.org .
>
> But then the trouble starts.

That's OK, AFAICS.

> My ideal actions.org would have exactly the following contents:
>
> - Server, with [[/docker:server:/code/][Server container]]

That's problematic. Tramp runs locally, on your laptop blub. All remote
file names are handled from there. '/docker:server:' is an abbreviation of
thead-hoc multi-hop file name '/ssh:prod|docker:server:' or
'/ssh:test|docker:server:', depending whether you've opened the
connection via prod or test, initially. If you want Tramp to resolve the
file name consistently, write something like
'[[/ssh:prod|docker:server::/code/][Server container]]' in your
actions.org. You can use environment variables for 'prod' or 'test' if
you want to have it generic, see the Tramp manual how to use them.

>    and [[https://???(file-remote-p (buffer-file-name) 'host)???/][Server
> website]]

I don't understand this piece.

> If I do that, often, when clicking on "Server container", it will try to
> open the docker container on "blub"--which is obviously wrong.

Sure. If you havent't told Tramp via ad-hoc multi-hop where to go, it
believes it is locally.

> But, sometimes, it will open the docker container on "prod" correctly.

Then you have access the container already once via an ad-hoc multi-hop
file name.

> But if I then click on "Server container", it will REUSE the docker
> container that is open from "prod". That is...... horrifying.

Sure, because it has stored internally, that the docker container is
rechable via prod.

I seriously recommend you to read about ad-hoc multi-hops in the Tramp
manual in order to understand what happens at your back by Tramp.

> I have a workaround that uses an org file with a BEGIN_SRC block which
> works totally fine (execute using C-c C-c)--but feels strange to do it
> in such a roundabout way.
>
> # cat actions.org
> The nodes of this project are:
>
> #+BEGIN_SRC emacs-lisp :results output raw
>              (let ((host (file-remote-p (buffer-file-name) 'host)))
>                (princ  (format "Host: %s
>    - Server, with [[/ssh:%s|docker:server:/code/][Server container]]
>      and [[/ssh:%s:/srv/entnahme/phyco/][Server source files]]
>      and [[https://%s/][Server website]]
> " host host)))
> #+END_SRC

Yes, something like this is needed. Or you use an environment variable
for the first hop, as said above. This looks more familiar then.

> How is one supposed to do relative links to docker and relative links to
> https?
>
> I apologize if that's actually an org problem.

Yes, the last two questions are org related. I don't use it, so I cannot help.

> Regards,
>     Danny Milosavljevic

Best regards, Michael.

Reply via email to