简体   繁体   English

Emacs服务器可以编辑Emacs客户端指定的远程文件吗?

[英]Can Emacs server edit remote files specified by Emacs client?

I'm looking to set up an emacs server such that the files specified by emacsclients are relative to the emacsclients' filesystem and not the server's filesystem. 我正在寻找一个emacs服务器 ,以便emacsclients指定的文件是相对于emacsclients的文件系统而不是服务器的文件系统。 For instance, if I set up an emacs server on a machine "darkstar" and I connect to this server through an emacsclient on "brightstar" with the command 例如,如果我在“ darkstar”计算机上设置了一个emacs服务器,并使用以下命令通过“ brightstar”上的emacsclient连接到该服务器

emacsclient -nw '~/fantastic'

The emacs server will attempt to edit the file ~/fantastic on darkstar and not on brightstar. emacs服务器将尝试在darkstar而不是Brightstar上编辑文件〜/ fantastic。 Id like the reverse of this. 我想反过来。 I'm open to all sorts of zany suggestions. 我乐于接受各种滑稽的建议。

*Background note: I want an emacs process that tracks all the buffers I open on various machines, keeps track of my color settings, bindings, etc. I want all of this available and replicated on any arbitrary machine with emacs. *背景说明:我想要一个emacs进程来跟踪我在各种机器上打开的所有缓冲区,跟踪我的颜色设置,绑定等。我希望所有这些可用并在任何具有emacs的机器上复制。 The emacs server seems to do just this but without the ability to edit client's local files! emacs服务器似乎只是这样做,但没有能力编辑客户端的本地文件!

Does the remote machine (the one running Emacs) have mounted the filesystem of the local machine? 远程计算机(运行Emacs的一台计算机)是否已安装本地计算机的文件系统? If so, you could issue something like: 如果是这样,您可以发出以下内容:

 emacsclient --eval ´(my-open-file "~/fantastic" "my-local-machine")´

You could then write the function my-open-file that could, for example, open the file //mounts/my-local-machine/home/YOUR-ACCOUNT/fantastic (assuming this is the mount point). 然后,您可以编写函数my-open-file ,例如,可以打开文件//mounts/my-local-machine/home/YOUR-ACCOUNT/fantastic (假设这是安装点)。

It will require some elisp-hacking and some script hacking (using, for example, Ruby) to build up the emacsclient command-line. 它将需要进行一些elisp黑客和一些脚本黑客(例如,使用Ruby)来构建emacsclient命令行。

You should be able to set to set up a shell function which uses tramp, like 您应该能够设置以设置使用流浪汉的shell函数,例如

edit-local() {
    emacsclient -e "(find-file (expand-file-name \"$1\" \"/ssh:$USER@$(hostname):$PWD\"))"
}

Of course you may have to change the tramp protocol to whatever you have setup. 当然,您可能必须将流浪协议更改为任何已设置的协议。

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

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