Reputation: 4058
How do you close an emacsclient frame without killing the server/daemon?
Doing C-x C-c
or C-x 5 0
in the gui will exit both frame and server (and other clients), while this just quit the current frame when done from terminal.
(Ps: My emacs version is 24.2,gtk. I've tried without init-file to see if it was coming from my config, but results were the same)
Upvotes: 16
Views: 11849
Reputation: 2743
In modern version GNU Emacs(27+), it says
When done with this frame, type C-x 5 0
Upvotes: 1
Reputation: 25855
From the minibuffer, when emacsclient
starts:
When done with a buffer, type C-x #
Upvotes: 12
Reputation: 9224
Because you ran (server-start)
from an existing frame, that frame is not an emacsclient frame, and closing the last such frame evidently gets the same treatment as C-x C-c
: it will exit Emacs.
If you used emacs --daemon
, possibly using the ALTERNATE_EDITOR=''
trick, you would not have this problem; you could just use emacsclient -n -c
to open a GUI frame, and after closing it the daemon would just sit around waiting for you to open a new frame, whether graphical or terminal-based.
Upvotes: 2
Reputation: 318
I am using both Debian with i3, and OSX. I usually exit emacsclient GUI frame by the window manager's close window shortcut. For example, in OSX, I use "Command + w" to close the client GUI frame without killing the server, and in i3, I use "Super + Shift + q" (the default close window by i3) to exit the client frame.
Upvotes: 1
Reputation: 448
I think the key point here is you need to start the server in daemon mode. If the server runs in an existing emacs process - for instance if you have (server-start)
in your init file - the server dies with the emacs process.
There are a couple of ways of starting the server in daemon mode:
emacs
with the --daemon
command line optionemacsclient
with the --alternate-editor=""
command line option, which will in effect run emacs --daemon
for you then attempt to connect to itOnce you have the server in daemon mode, you should be able to close any frames and the daemon will continue to sit and wait for further connections.
Upvotes: 6
Reputation: 7129
Starting the emacsclient
with -n
/--no-wait
flag will:
Don't wait for the server to return
You won't need to close the client in that case.
And if you have to a close emacsclient
just kill the buffer the server will remain intact.
Upvotes: 4