How can I launch an x-window from emacs ess when running R on a server?

狂风中的少年 提交于 2019-12-03 03:45:36

I do it the other way around:

  • ssh -X some.server.com to connect to a remote server with x11 forwarding.

  • emacsclient -nw to restart an Emacs session that is already running

  • plot(cumsum(rnorm(100))) in R as usual

Then the plot windows appears on the initial machine I ssh'ed away from.

Edit: As a follow-up to the comment: This works for any emacs, either emacs or emacs-snapshot. For a long time I used (server-start) in the ~/.emacs but now I prefer that (just once) lauch emacs --daemon after which I can then connect to via emacsclient (which also exists as emacsclient-snapshot). I really like this -- it gives me Emacs around R in a persistent session that I connect, disconnect and reconnect to.

I selected Dirk's answer because he pointed me in the right direction, and especially for lowering the energy of activation required to visualize my data, but here I am going to give the details of how I got this to work on my desktop.

1) set ssh keypairs (I had previously done this, full instructions for Ubuntu here)

mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa
ssh-copy-id username@hostname

2) include the following in ~/.ssh/config

Host any_server_nickname
HostName  hostname
User username
ForwardX11 yes

3) open emacs on local machine

4) C-x C-f

5) /any_server_nickname:dir/file.R for files in home directory or /any_server_nickname:/path/to/file.R

6) plot(1)

7) C-x C-b to evaluate entire buffer.

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