问题
I use TRAMP a lot with emacs. However, sometimes a server goes down and tramp sits waiting for a timeout. Usually it's after doing a C-x-f
in ido-mode to open a new file. I have to wait an annoyingly long amount of time. Is there an easy way to tell TRAMP to timeout and let ido-mode continue. I try C-g
and the option to open a file never happens.
回答1:
In thoses (frequent) cases when tramp stalls, I just halt the process with C-g
, kill the tramp buffer and I can then save the file.
M-x kill-buffer RET *tramp.*
回答2:
I don't face such timeout situation though I frequently use TRAMP. Try something like
(defun tramp-find-file-timeout ()
(when tramp
(with-timeout (4)
(keyboard-quit))))
(add-hook 'find-file-hook 'tramp-find-file-timeout)
I used this and this to make this suggestion. something better than keyboard-quit
could work for you.
回答3:
I found one hint that can limit the painful wait to 5 seconds. Add this line to .ssh/config:
Host * ServerAliveInterval 5
However, after five seconds, you still can't choose a file. So, when it fails just do a C-x b
to a buffer that's not opened on the downed server and C-x-f
from there will not take forever.
来源:https://stackoverflow.com/questions/4371255/how-to-force-an-emacs-tramp-time-out