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.
Asked
Active
Viewed 1,859 times
5

User1
- 39,458
- 69
- 187
- 265
-
Whether `C-g` works in this situation may depend on your operating system (and on some “exotic” (i.e. non-unix), platforms, how Emacs was compiled, and perhaps even how the ssh or other helper program was compiled). – Gilles 'SO- stop being evil' Dec 07 '10 at 22:17
-
Ah. I'm using cygwin's emacs and cygwin's scp. – User1 Dec 07 '10 at 22:51
3 Answers
2
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.*

yPhil
- 8,049
- 4
- 57
- 83
-
1Indeed; killing the tramp buffer for the relevant connection is a useful general approach to fixing tramp issues. (I'm not sure it's the best solution to something which is happening really frequently, but it's certainly a good one to keep in mind.) – phils Sep 17 '13 at 22:39
-
When I say frequently, what I really mean is that when I return to edit a tramp-opened file after say, more than an hour (witch is not that frequent) I'm pretty sure that tramp is deep asleep. Ever since I discovered that C-g & killing the tramp buffer works, my relationship with emacs has improved. What prevented you to upvote my answer BTW ? – yPhil Sep 18 '13 at 10:54
-
I didn't upvote because it didn't seem directly relevant to the question -- killing the tramp buffer can be very useful, but it can't bring a remote server back to life. – phils Sep 18 '13 at 11:19
0
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.

vpit3833
- 7,817
- 2
- 25
- 25
-
Oh, this looks like it would work, but it fails for some reason. Bummer! – User1 Dec 07 '10 at 16:24
0
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.

User1
- 39,458
- 69
- 187
- 265