Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close a emacsclient gui frame without killing the server

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)

like image 943
AdrieanKhisbe Avatar asked Sep 28 '13 17:09

AdrieanKhisbe


People also ask

How do I turn off EmacsClient?

Kill Emacs ( save-buffers-kill-terminal ). On a text terminal, suspend Emacs; on a graphical display, iconify (or “minimize”) the selected frame ( suspend-frame ). Killing Emacs means terminating the Emacs program. To do this, type C-x C-c ( save-buffers-kill-terminal ).

How does EmacsClient work?

EmacsClient allows one to open a file for editing in an already running Emacs. Because it doesn't start a new Emacs instance at each invocation, you can set up EmacsClient as the default editor, e.g. in the environment variable EDITOR or VISUAL. EmacsClient is part of and works only in conjunction with GNU Emacs.


3 Answers

From the minibuffer, when emacsclient starts:

When done with a buffer, type C-x #

like image 153
Dolda2000 Avatar answered Sep 21 '22 07:09

Dolda2000


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:

  • call emacs with the --daemon command line option
  • call emacsclient with the --alternate-editor="" command line option, which will in effect run emacs --daemon for you then attempt to connect to it

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

like image 34
Craig Waddington Avatar answered Sep 22 '22 07:09

Craig Waddington


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.

like image 27
Bleeding Fingers Avatar answered Sep 20 '22 07:09

Bleeding Fingers