mattsheffield,
@mattsheffield@mastodon.social avatar

A question for the community: Is it possible to use the Tramp feature to connect to a remote Emacs daemon? I ask because I have a file which I always have open on a remote pseudo-tty, but sometimes it would be nice to use my desktop Emacs with its nice proportional fonts and custom sizes to edit.

I want to connect to the same remote daemon so I can see unsaved changes and not have to worry about sync.

mapcar,
@mapcar@mastodon.sdf.org avatar

@mattsheffield I am not sure I fully understand your usecase but it seems that you have a local machine with full graphics environment and a remote machine with emacs but no graphics environment. I am also guessing that the file in question is situated on the remote machine. (1/4)

mapcar,
@mapcar@mastodon.sdf.org avatar

I am pretty sure that tramp does not support any protocol that in itself would correspond to talking a daemonized emacs. If somebody has not thought of that scenario, would require the daemonized to have some sort of server running inside of it that would look like (eg) an FTP server, I know of no such thing. Tramp is, I think, pretty extensible so it should be possible to hack together something that uses tramp on the local end and talks via some custom protocol to the remote emacs. (2/4)

mapcar,
@mapcar@mastodon.sdf.org avatar

It should be doable to use tramp (from local emacs) to access the file via some supported protocol (like SSH) and set up some appropriate save buffer hook to invoke emacsclient on the remote end to sync up the file inside of the remote emacs, on each save done locally. (3/4)

mapcar,
@mapcar@mastodon.sdf.org avatar

Presumably, that could piggyback on the session already set up by tramp to access the remote file and it would use the fact that emacslient also has options to execute elisp expressions within the server it is connected to (the -e argument as I recall). (4/4)

mattsheffield,
@mattsheffield@mastodon.social avatar

@mapcar Thanks for the ideas. I am trying to avoid all synchronizing if possible. I have not tried this yet, but potentially the Emacs daemon could be made to use TCP which could then be accessed via an SSH tunnel. What do you think? https://www.reddit.com/r/emacs/comments/ogejpj/comment/h4im2o0/

noahf,
@noahf@hachyderm.io avatar

@mattsheffield
Run a vnc server with emacs connected to that display.
You can connect to it remotely using any vnc client.
It's more network efficient than using X directly.

There isn't any way of indirectly editing a buffer in one emacs process from another emacs process. You need access to a frame from the original process.

mattsheffield,
@mattsheffield@mastodon.social avatar

@noahf Trying to avoid VNC, X, or anything beyond emacs-nox

noahf,
@noahf@hachyderm.io avatar

@mattsheffield
I don't want to second-guess your workflow but I'm curious why you would leave edits unsaved, at least significant ones. Autosave is partial protection for crash recovery but generally anything not committed to disk is as good as gone.

mattsheffield,
@mattsheffield@mastodon.social avatar

@noahf I want to avoid file sync because the buffer will always be open in one of the many devices I use regularly. Don't want to worry about out of sync copies. There is zero worry about crashes or power failures.

amszmidt,
@amszmidt@mastodon.social avatar

@mattsheffield I don't think the question makes much sense, Tramp is more of a "remote file" system than anything. Can you SSH to the box? Then X11 forwarding would solve it using something like:

ssh FOO.MACHINE -f emacsclient -c --display=$DISPLAY

mattsheffield,
@mattsheffield@mastodon.social avatar

@amszmidt Sure I could do that, but I don't want to put X or GTK on the box for security reasons

hajovonta,
@hajovonta@mastodon.online avatar

@mattsheffield
No you can't - emacs "daemon" is not a server, the name"emacsclient" is confusing.

@amszmidt

mattsheffield,
@mattsheffield@mastodon.social avatar

@hajovonta @amszmidt It uses Unix sockets rather than TCP, but why do you say it's not a server? You can definitely have multiple emacsclients accessing a single daemon.

amszmidt,
@amszmidt@mastodon.social avatar

@mattsheffield Yeah, seems like a distinction without meaning. You have it running in the background, serving a client .. and it can use TCP (https://www.gnu.org/software/emacs/manual/html_node/emacs/TCP-Emacs-server.html). The issue here would be forwarding the GUI part, which would require X11 forwarding or equivialent.

@hajovonta

hajovonta,
@hajovonta@mastodon.online avatar

@mattsheffield
Then you just need to route your ssh over those Unix sockets and you're done.

@amszmidt

amszmidt,
@amszmidt@mastodon.social avatar

@hajovonta Ok, can you show an example of how @mattsheffield would resolve the problem he is having?

hajovonta,
@hajovonta@mastodon.online avatar

@amszmidt
Nah, afaik nobody solved this. That's why I wrote it can't be done. Of course, with some ugly hacking it should be possible, but it's not worth the effort.

It's easier to open the file from the local box and never actually ssh into it, that would also solve the syncing problem.

Depending on the use-case, perhaps more "solutions" can be presented.

@mattsheffield

amszmidt,
@amszmidt@mastodon.social avatar

@hajovonta it is definitely not easier to open the file locally than using TRAMP over SSH.
@mattsheffield actually, that should be good enough if you just wanna see if you have unsaved stuff — you will have a auto save file lurking around, and if you can access the box remotely you can check for that.

amszmidt,
@amszmidt@mastodon.social avatar

@hajovonta @mattsheffield and even a lock file…

mattsheffield,
@mattsheffield@mastodon.social avatar

@amszmidt @hajovonta Someone suggested this idea for me, and potentially it could work https://www.reddit.com/r/emacs/comments/ogejpj/comment/h4im2o0/

hajovonta,
@hajovonta@mastodon.online avatar

@mattsheffield
This is rather a dream instead of a real possibility. I remember exploring this several years ago, then failed.

My experience is that these problems often indicate something's off with the way of working.

@amszmidt

mattsheffield,
@mattsheffield@mastodon.social avatar

@hajovonta @amszmidt I fear I may have to just use Tramp. But it's not the end of the world. It just is interesting to have run into a use case that Emacs maybe can't handle. Never had that before!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • emacs
  • DreamBathrooms
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • GTA5RPClips
  • provamag3
  • ethstaker
  • normalnudes
  • tester
  • osvaldo12
  • everett
  • cubers
  • tacticalgear
  • anitta
  • megavids
  • Leos
  • cisconetworking
  • JUstTest
  • lostlight
  • All magazines