Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper completion with TRAMP multi-hops #17

Open
olessavluk opened this issue Nov 25, 2017 · 7 comments · May be fixed by #36
Open

Add proper completion with TRAMP multi-hops #17

olessavluk opened this issue Nov 25, 2017 · 7 comments · May be fixed by #36

Comments

@olessavluk
Copy link

olessavluk commented Nov 25, 2017

Hi,

When I use TRAMP multi-hops syntax, for example /ssh:example.com|docker: in the suggestions, I see the list of my local containers, but would like to see the remote one (from example.com).

Is it possible to make suggestions that use remote docker?

@olessavluk
Copy link
Author

I've tried to rewrite function for suggestions using process-file which is aware of the default-directory which means it can be used over tramp:

(defun docker-tramp--running-containers ()
  "Collect docker running containers.
Return a list of containers of the form: \(ID NAME\)"
  (let* ((args (append docker-tramp-docker-options
                       (list "ps" "--format" "{{.ID}}:{{.Names}}")))
         (ps (ignore-errors
               (with-output-to-string
                 (apply #'process-file docker-tramp-docker-executable nil standard-output nil args))))
         (lines (split-string ps))
         (split-by-collon (lambda (str) (split-string str ":"))))
    (mapcar split-by-collon lines)))

full source - https://github.com/olessavluk/docker-tramp.el/blob/multi-hops/docker-tramp.el#L101

But with this changes, when I use multi-hops syntax I still see my local containers. And after I open some file or a dired buffer using ssh method of TRAMP - I see containers from the remote machine. Which is better but not the desired behavior.

Maybe I can somehow get currently entered value e.g. /ssh:example.com|docker and use it as default-directory and use it to specify which docker whould be executed?

@marsam
Copy link
Contributor

marsam commented Dec 5, 2017

Hi, sorry for the late response. I remember also trying to make this work. I patched process-lines to use process-file instead of call-process which is somewhat similar to your patch, but still tramp does not call the completion functions on the remote server. IIRC tramp-completion-dissect-file-name, the function in charge of filename completions, does not seem to work with hops.

I'll try to check this again this weekend, you can also ask in the tramp mailing list btw.

@stardiviner
Copy link

Any update on this function?

@olessavluk
Copy link
Author

olessavluk commented Dec 17, 2017

Hello @stardiviner,
As @marsam pointed, seems like there is no way to do this without patching emacs, but I should ask somewhere first.

As a temporary workaround I'm using my fork olessavluk/docker-tramp branch:multi-hops. It is aware of the TRAMP but not aware of the multi-hops (as I've describe previously). In order to use it:

  1. install forked package
    how to install? I'm using spacemacs so just added this to the dotspacemacs-additional-packages:
    (docker-tramp :location (recipe :fetcher github :repo "olessavluk/docker-tramp.el" :branch "multi-hops"))
    Sure you can do something similar or just clone and require it in your config
  2. open something over TRAMP, I usually open dired buffer
  3. now you should see suggestions from the current TRAMP session

@stardiviner
Copy link

@olessavluk Thanks.

@dvzubarev
Copy link

Hi @olessavluk, Can you make a PR? It is better than current behavior anyway. It is quite common to open a dired buffer or file on a remote host (e.g. via bookmark) and then add hop to the path.

@cl-user cl-user linked a pull request Mar 4, 2022 that will close this issue
@cl-user
Copy link

cl-user commented Mar 4, 2022

Hi,

Maybe I can somehow get currently entered value e.g. /ssh:example.com|docker and use it as default-directory and use it to specify which docker whould be executed?

I did exactly that by using (minibuffer-contents-no-properties) and it works for me. Check out PR #36 when you have time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants