[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs server or daemon mode

From: Perry Smith
Subject: emacs server or daemon mode
Date: Sun, 7 Jul 2019 16:00:20 -0500

My laptop is a Mac running the latest.  I have an Ubuntu machine running 18.04. 
 The Mac has emacs 26.1 that I built myself although at this point, its 
completely out of the picture.  The Ubuntu machine now has emacs 26.2 built by 
“KelleyK”.  I also have the latest XQuatz on the Mac.  XQuarts is an X11 port 
to the Mac.

On the Ubuntu machine, my .emacs.d/init.el looks like this:

 server-log t
 server-host ""
 server-port "9999"
 server-use-tcp t)

And I have enabed and started the systemd emacs.server (after slight editing) 
which now looks like this:

## If your Emacs is installed in a non-standard location, you may need
## to copy this file to a standard directory, eg ~/.config/systemd/user/ .
## If you install this file by hand, change the "Exec" lines below
## to use absolute file names for the executables.
Description=Emacs text editor
Documentation=info:emacs man:emacs(1)

ExecStart=/usr/bin/emacs26 --fg-daemon
ExecStop=/usr/bin/emacsclient26 --eval "(kill-emacs)"


On my Mac, I execute a command such as this (I’ve tried many variations):

ssh -Y crystal /usr/bin/emacsclient26 -f server -c

An X11 window pops up on my Mac display.  For those who are not familiar, after 
installing XQuarts, the terminals have a DISPLAY set to a local socket.  The 
ssh -Y propagates this to the other side and that is the socket that 
emacsclient is using to get back to my local display.  All appears good.  There 
is usually (not always) a message that says ^X 5 0 to close the window.  I type 
this and the window disappears but the ssh does not exit.

When I ^C the ssh, the emacs daemon on the Ubuntu host dies (and is restarted 
by systemd).

One quest is to make the daemon not die even if the disconnect is abrupt but I 
can’t even find a way to gracefully exit or disconnect such that the ssh exits. 
 The goal in this case is to use the Ubuntu machine and I’d like the build and 
the shell buffers that contain the build to survive a disconnect (graceful or 

As you can see from my init file, I’ve tried getting the server log but the 
buffer is not created.

Another tactic I’ve tried is to not only connect to the Ubuntu emacs server via 
the Mac but also ssh over and connect to it by running 

emacsclient26 -f server -nw

from the prompt on the Ubuntu machine.  From that terminal I do various things 
like print out server-clients … often it is correct but almost equally as often 
its not — showing fewer clients than are actually present.  I show the buffers 
but there are only two *scratch* and *Messages* … no server log.

With the ssh -Y emacsclient ..., I’ve tried -f and -t and with emacsclient I’ve 
tried -n.  I’ve also tried redirecting stdin, stdout, and stderr to /dev/null 
or close them via <&-, etc.

I’ve also tried removing the init.el file shown above.  I was originally trying 
to do something different and wanted to use a TCP socket but at this point, 
that is no longer a requirement.

I assume I must be doing something fundamentally wrong so I came to this group 
looking for help rather than the bug group.

Thank you for your help,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]