Difference between revisions of "Emacs server"

From WikEmacs
Jump to: navigation, search
(Created page with "Emacs includes an optional client-server architecture. To start the server, run <code>server-start</code>. If you want to use this feature it probably makes sense to do this ...")
 
m (Add information about --daemon)
Line 1: Line 1:
 
Emacs includes an optional client-server architecture.
 
Emacs includes an optional client-server architecture.
  
To start the server, run <code>server-start</code>. If you want to use this feature it probably makes sense to do this somewhere in your configuration files.
+
To start the server, run <code>server-start</code> in an existing Emacs, or (in Emacs 24 or higher) run Emacs with the <tt>--daemon</tt> argument to have Emacs start a server and immediately fork into the background. The <tt>--daemon</tt> 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 <code>server-start</code> somewhere in your configuration file.
  
 
Once this is done you may use the <code>emacsclient</code> command outside of Emacs to send a file to Emacs for editing, e.g. <code>emacsclient ~/.emacs.d/init.el</code> to modify your init file. On a GNU/Linux system it might be a good idea to set your <tt>EDITOR</tt> environment variable to <tt>emacsclient</tt>.
 
Once this is done you may use the <code>emacsclient</code> command outside of Emacs to send a file to Emacs for editing, e.g. <code>emacsclient ~/.emacs.d/init.el</code> to modify your init file. On a GNU/Linux system it might be a good idea to set your <tt>EDITOR</tt> environment variable to <tt>emacsclient</tt>.
  
 
Once you have finished with a buffer that was opened via <tt>emacsclient</tt> you should use the <code>C-x #</code> (<code>server-edit</code>) to properly close the loop. Killing the buffer normally will not send the signal to <tt>emacsclient</tt> that Emacs has finished with the file.
 
Once you have finished with a buffer that was opened via <tt>emacsclient</tt> you should use the <code>C-x #</code> (<code>server-edit</code>) to properly close the loop. Killing the buffer normally will not send the signal to <tt>emacsclient</tt> that Emacs has finished with the file.

Revision as of 00:13, 27 March 2012

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.