Can Emacs server edit remote files specified by Emacs client?

557 views Asked by At

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. 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

emacsclient -nw '~/fantastic'

The emacs server will attempt to edit the file ~/fantastic on darkstar and not on brightstar. 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. The emacs server seems to do just this but without the ability to edit client's local files!

2

There are 2 answers

2
Ivan Andrus On BEST ANSWER

You should be able to set to set up a shell function which uses tramp, like

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.

0
Lindydancer On

Does the remote machine (the one running Emacs) have mounted the filesystem of the local machine? 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).

It will require some elisp-hacking and some script hacking (using, for example, Ruby) to build up the emacsclient command-line.