简体   繁体   中英

Passing -X argument for ssh with emacs and tramp

I am using emacs ess and tramp to remotely execute some R script. I typically have an R script on a server, and I run it interactively on my server, through emacs. This work all well and fine.

However I can not manage to have the plot windows appears from my R script. I would like to obtain from emacs the same behavior that if I ran ssh -X user@server.com
and then do some R interactively, with plot appearing on my local machine.

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

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.

I also came across this very similar question: How can I launch an x-window from emacs ess when running R on a server?

However:

1) The accepted answer is not a direct answer to the forwardX problem

2) The second answer is not working (am I doing something wrong ? or missing a configuration somewhere?)

Thanks for your help,


edit I use Emacs 23.1.1 on a Ubuntu 16.04

(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. Then you can visit a file/directory with Cx Cf /sshx11:user@host:path/to/target .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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