简体   繁体   English

通过emacs和tramp为SSH传递-X参数

[英]Passing -X argument for ssh with emacs and tramp

I am using emacs ess and tramp to remotely execute some R script. 我正在使用emacs ess和tramp远程执行一些R脚本。 I typically have an R script on a server, and I run it interactively on my server, through emacs. 我通常在服务器上有一个R脚本,并通过emacs在服务器上以交互方式运行它。 This work all well and fine. 这项工作一切正常。

However I can not manage to have the plot windows appears from my R script. 但是,我无法在我的R脚本中显示绘图窗口。 I would like to obtain from emacs the same behavior that if I ran ssh -X user@server.com 我想从emacs获得与运行ssh -X user@server.com相同的行为
and then do some R interactively, with plot appearing on my local machine. 然后以交互方式执行一些R,并在本地计算机上显示图。

I have modified my .ssh/config to add the ForwardX11 yes option, which works for a direct ssh query on my sever but not with emacs/trump 我已经修改了.ssh / config以添加ForwardX11 yes选项,该选项适用于服务器上的直接ssh查询,但不适用于emacs / trump

I have also tried the option to customize tramp-default-mode` (see https://superuser.com/questions/609414/emacs-doesnt-use-ssh-config-when-accessing-files-on-a-remote-machine ) but this does not work either. 我还尝试了自定义流浪默认模式的选项(请参阅https://superuser.com/questions/609414/emacs-doesnt-use-ssh-config-when-accessing-files-on-a-remote-机器 ),但这也不起作用。

I also came across this very similar question: How can I launch an x-window from emacs ess when running R on a server? 我也遇到了一个非常类似的问题: 在服务器上运行R时,如何从emacs ess启动x窗口?

However: 然而:

1) The accepted answer is not a direct answer to the forwardX problem 1)接受的答案不是对forwardX问题的直接答案

2) The second answer is not working (am I doing something wrong ? or missing a configuration somewhere?) 2)第二个答案不起作用(我做错了什么吗?还是某处缺少配置?)

Thanks for your help, 谢谢你的帮助,


edit I use Emacs 23.1.1 on a Ubuntu 16.04 编辑我在Ubuntu 16.04上使用Emacs 23.1.1

(with-eval-after-load 'tramp
  (add-to-list 'tramp-methods
               '("sshx11"
                 (tramp-login-program        "ssh")
                 (tramp-login-args           (("-l" "%u") ("-p" "%p") ("%c")
                                              ("-e" "none") ("-X") ("%h")))
                 (tramp-async-args           (("-q")))
                 (tramp-remote-shell         "/bin/sh")
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))
                 (tramp-gw-args              (("-o" "GlobalKnownHostsFile=/dev/null")
                                              ("-o" "UserKnownHostsFile=/dev/null")
                                              ("-o" "StrictHostKeyChecking=no")
                                              ("-o" "ForwardX11=yes")))
                 (tramp-default-port         22)))
  (tramp-set-completion-function "sshx11" tramp-completion-function-alist-ssh))

This is just a copy of the "ssh" method, with the "-X" added to tramp-login-args. 这只是“ ssh”方法的一个副本,在“ tramp-login-args”中添加了“ -X”。 Then you can visit a file/directory with Cx Cf /sshx11:user@host:path/to/target . 然后,您可以使用Cx Cf /sshx11:user@host:path/to/target访问文件/目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM