emacs tramp over an unreliable connection

偶尔善良 提交于 2019-12-03 04:48:06

问题


I want to run R on a remote box under a local Emacs (I do not want to run Emacs on the remote box).

I can run R on a remote host using TRAMP:

(let ((default-directory "/user@remote:~"))
  (R))

and everything works fine except that when the connection to remote is lost, R dies. This is no good because this means that I have to re-load all the data into R after restarting it, which takes time.

Is it possible to tell TRAMP to use a persistent terminal? (GNU Screen or tmux or Mosh or dtach)

See also emacs-devel thread tramp:sshx:(screen|tmux).


回答1:


Here is how to use ESS with R running in a remote screen session:

  • ssh to the remote host (outside of emacs)

  • start screen session

  • detach it

  • open shell in emacs (M-x shell)

  • ssh to the remote host again in the emacs shell

  • resume the screen session (screen -r)

  • start R

  • finally attach ESS to the R process using M-x ess-remote in the shell buffer where you started R

There are more details, screenshots, and keybindings in this post http://blog.nguyenvq.com/2010/07/11/using-r-ess-remote-with-screen-in-emacs/




回答2:


Here is an alternative approach using dtach:

(defvar R-remote-host "remote-server")
(defvar R-remote-session "R")
(defvar R-remote-directory "~")
(defun R-remote (&optional remote-host session directory)
  "Connect to the remote-host's dtach session running R."
  (interactive (list
                (read-from-minibuffer "R remote host: " R-remote-host)
                (read-from-minibuffer "R remote session: " R-remote-session)
                (read-from-minibuffer "R remote directory: " R-remote-directory)))
  (pop-to-buffer (make-comint (concat "remote-" session)
                              "ssh" nil "-t" "-t" remote-host
                              "cd" directory ";"
                              "dtach" "-A" (concat ".dtach-" session)
                              "-z" "-E" "-r" "none"
                              inferior-R-program-name "--no-readline"
                              inferior-R-args))
  (ess-remote (process-name (get-buffer-process (current-buffer))) "R")
  (setq comint-process-echoes t))

Call M-x R-remote RET RET RET RET.

It works for me.

PS. The answer to the problem (as opposed to the question as asked) is to use ein with Jupyter.



来源:https://stackoverflow.com/questions/16819248/emacs-tramp-over-an-unreliable-connection

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