Emacs server

From WikEmacs
Revision as of 01:13, 27 March 2012 by Saulrh (talk | contribs) (Add information about --daemon)
Jump to: navigation, search

Emacs includes an optional client-server architecture.

To start the server, run server-start in an existing Emacs, or (in Emacs 24 or higher) run Emacs with the --daemon argument to have Emacs start a server and immediately fork into the background. The --daemon argument allows you to keep Emacs running without any visible frames, but your configuration file will be run as if in a terminal frame and your graphical theming may be affected. If you want to start a server automatically, add server-start somewhere in your configuration file.

Once this is done you may use the emacsclient command outside of Emacs to send a file to Emacs for editing, e.g. emacsclient ~/.emacs.d/init.el to modify your init file. On a GNU/Linux system it might be a good idea to set your EDITOR environment variable to emacsclient.

Once you have finished with a buffer that was opened via emacsclient you should use the C-x # (server-edit) to properly close the loop. Killing the buffer normally will not send the signal to emacsclient that Emacs has finished with the file.