How to force an Emacs tramp time out?

白昼怎懂夜的黑 提交于 2019-12-07 08:35:35

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!