-
Notifications
You must be signed in to change notification settings - Fork 44
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Tramp with multihop #16
Comments
Just found out about tramp-default-proxies-alist:
Linking this with my previous comment we have:
If I edit persp-auto-save by hand to make it look like this:
It works. So I think it would be just a matter of checking the tramp-default-proxies-alist and concatenating the corresponding hosts to the path of the file. What do you think? |
But how will we know which item from proxies-alist to concatenate? I can not check that by myself, so could you post here a value of the |
heh nevermind, I misunderstood you. Just realised that the |
Yes, but I still didn't find a way to know for sure that the buffer is a tramp buffer. I don't think checking the start of the buffer name for '/ssh:' is very reliable. And btw, tramp-current-connection will not help us very much because it just shows the latest connection stabilished. I'll look further into this today. Perhaps there is a 'trampp' predicate. =) |
Hi, just an update on this. There really is a tramp-p predicate: I'll get back to you when I have something. |
Ok, then something like this should work for you, I think: (with-eval-after-load "persp-mode-autoloads"
(defun persp-tramp-multi-hop-save-buffer-file-name (b)
(let ((ret (buffer-file-name b))
(tmh (tramp-compute-multi-hops
(tramp-dissect-file-name (buffer-file-name b)))))
(when tmh
(let* (method user host filename proxy (out "")
(temp-out
(concat "/"
(dolist (item tmh out)
(setq method (aref item 0)
user (aref item 1)
host (aref item 2)
filename (aref item 3)
proxy (aref item 4))
(setq out
(concat proxy
out method ":" user "@" host
(if (= (string-width filename) 0)
"|"
(concat ":" filename))))))))
(setq ret
(if (yes-or-no-p (concat
"You are about to save a tramp file. Is it a correct file name to save?"
"(" temp-out ")"))
temp-out
(read-string "Please enter a correct file name: " temp-out nil ret)))))
ret))
(add-to-list 'persp-save-buffer-functions
#'(lambda (b)
(when (tramp-tramp-file-p (buffer-file-name b))
`(def-buffer ,(buffer-name b)
,(persp-tramp-multi-hop-save-buffer-file-name b)
,(buffer-local-value 'major-mode b)))))) |
Cool, it worked! I used a slightly different function though (but it does the same):
Do you intend to merge this? I could send a pull request with the new function. Anyway, I think we can close this, thanks! =) |
It would be great. |
When using tramp with multihop (local host --> intermediate host --> remote host):
the persp-auto-save file gets written with:
when restoring persp contents, tramp will timeout because remote_user@remote_host is not accessible.
Is there a way to restore these tramp buffers?
EDIT: I just noticed that after tramp times out, persp-mode will output a warning saying that the file no longer exists.
The text was updated successfully, but these errors were encountered: