<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wikemacs.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Miabraha</id>
	<title>WikEmacs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wikemacs.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Miabraha"/>
	<link rel="alternate" type="text/html" href="https://wikemacs.org/wiki/Special:Contributions/Miabraha"/>
	<updated>2026-04-26T23:43:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47020</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47020"/>
		<updated>2015-06-25T01:07:19Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: /* Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture. The benefit of running emacs in server mode is that new client instances can be started up instantaneously.  If you have 100+ packages and starting Emacs usually takes several three seconds, using server mode creates a much more streamlined workflow without sacrificing customization functionality.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
Configuration through the init daemon &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; is the preferred method of starting Emacs at launch on most major distributions, including Debian, Ubuntu, Fedora, OpenSUSE, Arch, and derivatives.&lt;br /&gt;
&lt;br /&gt;
To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, modifying the binary .  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;~/.config/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=Emacs: the extensible, self-documenting text editor&lt;br /&gt;
 Documentation=man:emacs(1) info:Emacs&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --eval &amp;quot;(progn (setq kill-emacs-hook nil) (kill-emacs))&amp;quot;&lt;br /&gt;
 Restart=on-failure&lt;br /&gt;
 Environment=DISPLAY=:%i&lt;br /&gt;
 TimeoutStartSec=0&lt;br /&gt;
 &lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=default.target&lt;br /&gt;
&lt;br /&gt;
Enable the new module with &amp;lt;code&amp;gt;systemctl --user enable emacsd&amp;lt;/code&amp;gt;; useful commands besides &amp;lt;code&amp;gt;enable&amp;lt;/code&amp;gt; include &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;restart&amp;lt;/code&amp;gt;. After running enable, the service will be enabled permanently.  You can use &amp;lt;code&amp;gt;disable&amp;lt;/code&amp;gt; if you no longer want systemd to run an Emacs daemon.&lt;br /&gt;
&lt;br /&gt;
A few parts of this script are not quite self-documenting.  Two are just technical: &amp;lt;code&amp;gt;Type&amp;lt;/code&amp;gt; tells systemd it should expect &amp;lt;code&amp;gt;emacs --systemd&amp;lt;/code&amp;gt; to fork a server process, and &amp;lt;code&amp;gt;Environment&amp;lt;/code&amp;gt; sets an environment variable to ensure Emacs works properly with multiple X displays.  The Restart command asks systemd to restart Emacs whenever there is a nonzero exit code.  For example, if Emacs hangs in the middle of a loop and you kill it in a task manager or run &amp;lt;code&amp;gt;systemctl --user kill&amp;lt;/code&amp;gt;, systemd will restart Emacs.  Alternative values you may want to use are &amp;lt;code&amp;gt;no&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;always&amp;lt;/code&amp;gt;.  TimeoutStartSec=0 tells systemd it shouldn't worry about how long it takes Emacs to start.  Specifying a timeout might be useful if you occasionally break your Emacs init file.&lt;br /&gt;
&lt;br /&gt;
Systemd will not know what to do if Emacs tries to ask for input before closing, for example, if Desktop mode prompts for confirmation before overwriting a desktop file.  If the simple &amp;lt;code&amp;gt;(progn)&amp;lt;/code&amp;gt; script executed on ExecStop&amp;lt;/code&amp;gt; is not suitable,  You may need to define your own command for a clean exit and call that function instead.&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because of the ability to easily configure Emacs to restart, and because the process will begin at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start.&lt;br /&gt;
&lt;br /&gt;
== OS X ==&lt;br /&gt;
&amp;lt;code&amp;gt;launchd&amp;lt;/code&amp;gt; is the OS X analog of &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; and can be configured just as easily. If someone is familiar with launchd configuration please fill this in.&lt;br /&gt;
&lt;br /&gt;
== MS Windows ==&lt;br /&gt;
Open the startup folder by running the command &amp;lt;code&amp;gt;shell:startup&amp;lt;/code&amp;gt; in a run dialog or by typing it in the Windows Explorer path bar. Place a shortcut to Emacs in this folder to run Emacs at boot. Change the target to &amp;lt;code&amp;gt;emacs --daemon&amp;lt;/code&amp;gt; to run start it in daemon mode. The best option for more advanced Emacs daemon-mode configuration on Windows is still not settled, there is some discussion on the Emacs Wiki which could potentially be sifted through.&lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47019</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47019"/>
		<updated>2015-06-25T01:06:59Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: /* Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture. The benefit of running emacs in server mode is that new client instances can be started up instantaneously.  If you have 100+ packages and starting Emacs usually takes several three seconds, using server mode creates a much more streamlined workflow without sacrificing customization functionality.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
Configuration through the init daemon &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; is the preferred method of starting Emacs at launch on most major distributions, including Debian, Ubuntu, Fedora, OpenSUSE, Arch, and derivatives.&lt;br /&gt;
&lt;br /&gt;
To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, modifying the binary .  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;~/.config/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=Emacs: the extensible, self-documenting text editor&lt;br /&gt;
 Documentation=man:emacs(1) info:Emacs&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --eval &amp;quot;(progn (setq kill-emacs-hook nil) (kill-emacs))&amp;quot;&lt;br /&gt;
 Restart=on-failure&lt;br /&gt;
 Environment=DISPLAY=:%i&lt;br /&gt;
 TimeoutStartSec=0&lt;br /&gt;
&lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=default.target&lt;br /&gt;
&lt;br /&gt;
Enable the new module with &amp;lt;code&amp;gt;systemctl --user enable emacsd&amp;lt;/code&amp;gt;; useful commands besides &amp;lt;code&amp;gt;enable&amp;lt;/code&amp;gt; include &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;restart&amp;lt;/code&amp;gt;. After running enable, the service will be enabled permanently.  You can use &amp;lt;code&amp;gt;disable&amp;lt;/code&amp;gt; if you no longer want systemd to run an Emacs daemon.&lt;br /&gt;
&lt;br /&gt;
A few parts of this script are not quite self-documenting.  Two are just technical: &amp;lt;code&amp;gt;Type&amp;lt;/code&amp;gt; tells systemd it should expect &amp;lt;code&amp;gt;emacs --systemd&amp;lt;/code&amp;gt; to fork a server process, and &amp;lt;code&amp;gt;Environment&amp;lt;/code&amp;gt; sets an environment variable to ensure Emacs works properly with multiple X displays.  The Restart command asks systemd to restart Emacs whenever there is a nonzero exit code.  For example, if Emacs hangs in the middle of a loop and you kill it in a task manager or run &amp;lt;code&amp;gt;systemctl --user kill&amp;lt;/code&amp;gt;, systemd will restart Emacs.  Alternative values you may want to use are &amp;lt;code&amp;gt;no&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;always&amp;lt;/code&amp;gt;.  TimeoutStartSec=0 tells systemd it shouldn't worry about how long it takes Emacs to start.  Specifying a timeout might be useful if you occasionally break your Emacs init file.&lt;br /&gt;
&lt;br /&gt;
Systemd will not know what to do if Emacs tries to ask for input before closing, for example, if Desktop mode prompts for confirmation before overwriting a desktop file.  If the simple &amp;lt;code&amp;gt;(progn)&amp;lt;/code&amp;gt; script executed on ExecStop&amp;lt;/code&amp;gt; is not suitable,  You may need to define your own command for a clean exit and call that function instead.&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because of the ability to easily configure Emacs to restart, and because the process will begin at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start.&lt;br /&gt;
&lt;br /&gt;
== OS X ==&lt;br /&gt;
&amp;lt;code&amp;gt;launchd&amp;lt;/code&amp;gt; is the OS X analog of &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; and can be configured just as easily. If someone is familiar with launchd configuration please fill this in.&lt;br /&gt;
&lt;br /&gt;
== MS Windows ==&lt;br /&gt;
Open the startup folder by running the command &amp;lt;code&amp;gt;shell:startup&amp;lt;/code&amp;gt; in a run dialog or by typing it in the Windows Explorer path bar. Place a shortcut to Emacs in this folder to run Emacs at boot. Change the target to &amp;lt;code&amp;gt;emacs --daemon&amp;lt;/code&amp;gt; to run start it in daemon mode. The best option for more advanced Emacs daemon-mode configuration on Windows is still not settled, there is some discussion on the Emacs Wiki which could potentially be sifted through.&lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47018</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47018"/>
		<updated>2015-06-25T01:06:32Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: Expanded systemd instructions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture. The benefit of running emacs in server mode is that new client instances can be started up instantaneously.  If you have 100+ packages and starting Emacs usually takes several three seconds, using server mode creates a much more streamlined workflow without sacrificing customization functionality.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
Configuration through the init daemon &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; is the preferred method of starting Emacs at launch on most major distributions, including Debian, Ubuntu, Fedora, OpenSUSE, Arch, and derivatives.&lt;br /&gt;
&lt;br /&gt;
To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, modifying the binary .  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;~/.config/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=Emacs: the extensible, self-documenting text editor&lt;br /&gt;
 Documentation=man:emacs(1) info:Emacs&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --eval &amp;quot;(progn (setq kill-emacs-hook nil) (kill-emacs))&amp;quot;&lt;br /&gt;
 Restart=on-failure&lt;br /&gt;
 Environment=DISPLAY=:%i&lt;br /&gt;
 TimeoutStartSec=0&lt;br /&gt;
&lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=default.target&lt;br /&gt;
&lt;br /&gt;
Enable the new module with &amp;lt;code&amp;gt;systemctl --user enable emacsd&amp;lt;/code&amp;gt;; useful commands besides &amp;lt;code&amp;gt;enable&amp;lt;/code&amp;gt; include &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;kill&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;restart&amp;lt;/code&amp;gt;. After running enable, the service will be enabled permanently.  You can use &amp;lt;code&amp;gt;disable&amp;lt;/code&amp;gt; if you no longer want systemd to run an Emacs daemon.&lt;br /&gt;
&lt;br /&gt;
A few parts of this script are not quite self-documenting.  Two are just technical: &amp;lt;code&amp;gt;Type&amp;lt;/code&amp;gt; tells systemd it should expect &amp;lt;code&amp;gt;emacs --systemd&amp;lt;/code&amp;gt; to fork a server process, and &amp;lt;code&amp;gt;Environment sets an environment variable to ensure Emacs works properly with multiple X displays.  The Restart command asks systemd to restart Emacs whenever there is a nonzero exit code.  For example, if Emacs hangs in the middle of a loop and you kill it in a task manager or run &amp;lt;code&amp;gt;systemctl --user kill&amp;lt;/code&amp;gt;, systemd will restart Emacs.  Alternative values you may want to use are &amp;lt;code&amp;gt;no&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;always&amp;lt;/code&amp;gt;.  TimeoutStartSec=0 tells systemd it shouldn't worry about how long it takes Emacs to start.  Specifying a timeout might be useful if you occasionally break your Emacs init file.&lt;br /&gt;
&lt;br /&gt;
Systemd will not know what to do if Emacs tries to ask for input before closing, for example, if Desktop mode prompts for confirmation before overwriting a desktop file.  If the simple &amp;lt;code&amp;gt;(progn)&amp;lt;/code&amp;gt; script executed on ExecStop&amp;lt;/code&amp;gt; is not suitable,  You may need to define your own command for a clean exit and call that function instead.&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because of the ability to easily configure Emacs to restart, and because the process will begin at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start.&lt;br /&gt;
&lt;br /&gt;
== OS X ==&lt;br /&gt;
&amp;lt;code&amp;gt;launchd&amp;lt;/code&amp;gt; is the OS X analog of &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; and can be configured just as easily. If someone is familiar with launchd configuration please fill this in.&lt;br /&gt;
&lt;br /&gt;
== MS Windows ==&lt;br /&gt;
Open the startup folder by running the command &amp;lt;code&amp;gt;shell:startup&amp;lt;/code&amp;gt; in a run dialog or by typing it in the Windows Explorer path bar. Place a shortcut to Emacs in this folder to run Emacs at boot. Change the target to &amp;lt;code&amp;gt;emacs --daemon&amp;lt;/code&amp;gt; to run start it in daemon mode. The best option for more advanced Emacs daemon-mode configuration on Windows is still not settled, there is some discussion on the Emacs Wiki which could potentially be sifted through.&lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47017</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47017"/>
		<updated>2015-06-23T03:21:38Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: /* Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture. The benefit of running emacs in server mode is that new client instances can be started up instantaneously.  If you have 100+ packages and starting Emacs usually takes several three seconds, using server mode creates a much more streamlined workflow without sacrificing customization functionality.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
Configuration through the init daemon &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; is the preferred method of starting Emacs at launch on most major distributions, including Debian, Ubuntu, Fedora, OpenSUSE, Arch, and derivatives.&lt;br /&gt;
&lt;br /&gt;
To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, replacing the location of the emacs executable if necessary.  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;/etc/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=GNU Emacs daemon&lt;br /&gt;
 Documentation=man:emacs(1) info:Emacs&lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --e &amp;quot;(kill-emacs)&amp;quot;&lt;br /&gt;
 Restart=always&lt;br /&gt;
 &lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=console.target&lt;br /&gt;
&lt;br /&gt;
Enable the new module with &amp;lt;code&amp;gt;systemctl --user enable emacsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because the process will begin up at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start first.&lt;br /&gt;
&lt;br /&gt;
== OS X ==&lt;br /&gt;
&amp;lt;code&amp;gt;launchd&amp;lt;/code&amp;gt; is the OS X analog of &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; and can be configured just as easily. If someone is familiar with launchd configuration please fill this in.&lt;br /&gt;
&lt;br /&gt;
== MS Windows ==&lt;br /&gt;
Open the startup folder by running the command &amp;lt;code&amp;gt;shell:startup&amp;lt;/code&amp;gt; in a run dialog or by typing it in the Windows Explorer path bar. Place a shortcut to Emacs in this folder to run Emacs at boot. Change the target to &amp;lt;code&amp;gt;emacs --daemon&amp;lt;/code&amp;gt; to run start it in daemon mode. The best option for more advanced Emacs daemon-mode configuration on Windows is still not settled, there is some discussion on the Emacs Wiki which could potentially be sifted through.&lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47016</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47016"/>
		<updated>2015-06-23T00:21:33Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: /* Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture. The benefit of running emacs in server mode is that new client instances can be started up instantaneously.  If you have 100+ packages and starting Emacs usually takes several three seconds, using server mode creates a much more streamlined workflow without sacrificing customization functionality.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
Configuration through the init daemon &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; is the preferred method of starting Emacs at launch on most major distributions, including Debian, Ubuntu, Fedora, OpenSUSE, Arch, and derivatives.&lt;br /&gt;
&lt;br /&gt;
To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, replacing the location of the emacs executable if necessary.  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;/etc/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=Emacs daemon&lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 WorkingDirectory=%h&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --e &amp;quot;(kill-emacs)&amp;quot;&lt;br /&gt;
 Restart=always&lt;br /&gt;
 &lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=console.target&lt;br /&gt;
&lt;br /&gt;
Enable the new module with &amp;lt;code&amp;gt;systemctl --user enable emacsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because the process will begin up at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start first.&lt;br /&gt;
&lt;br /&gt;
== OS X ==&lt;br /&gt;
&amp;lt;code&amp;gt;launchd&amp;lt;/code&amp;gt; is the OS X analog of &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; and can be configured just as easily. If someone is familiar with launchd configuration please fill this in.&lt;br /&gt;
&lt;br /&gt;
== MS Windows ==&lt;br /&gt;
Open the startup folder by running the command &amp;lt;code&amp;gt;shell:startup&amp;lt;/code&amp;gt; in a run dialog or by typing it in the Windows Explorer path bar. Place a shortcut to Emacs in this folder to run Emacs at boot. Change the target to &amp;lt;code&amp;gt;emacs --daemon&amp;lt;/code&amp;gt; to run start it in daemon mode. The best option for more advanced Emacs daemon-mode configuration on Windows is still not settled, there is some discussion on the Emacs Wiki which could potentially be sifted through.&lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47015</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47015"/>
		<updated>2015-06-23T00:21:21Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: /* Linux */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture. The benefit of running emacs in server mode is that new client instances can be started up instantaneously.  If you have 100+ packages and starting Emacs usually takes several three seconds, using server mode creates a much more streamlined workflow without sacrificing customization functionality.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
Configuration through the init daemon &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; is the preferred method of starting Emacs at launch on most major distributions, including Debian, Ubuntu, Fedora, OpenSUSE, Arch, and derivatives.&lt;br /&gt;
&lt;br /&gt;
To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, replacing the location of the emacs executable if necessary.  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;/etc/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=Emacs daemon&lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 WorkingDirectory=%h&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --e &amp;quot;(kill-emacs)&amp;quot;&lt;br /&gt;
 Restart=always&lt;br /&gt;
 &lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=console.target&lt;br /&gt;
&lt;br /&gt;
Enable the new module with &amp;lt;code&amp;gt;systemctl --user enable emacsd&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can simply add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because the process will begin up at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start first.&lt;br /&gt;
&lt;br /&gt;
== OS X ==&lt;br /&gt;
&amp;lt;code&amp;gt;launchd&amp;lt;/code&amp;gt; is the OS X analog of &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; and can be configured just as easily. If someone is familiar with launchd configuration please fill this in.&lt;br /&gt;
&lt;br /&gt;
== MS Windows ==&lt;br /&gt;
Open the startup folder by running the command &amp;lt;code&amp;gt;shell:startup&amp;lt;/code&amp;gt; in a run dialog or by typing it in the Windows Explorer path bar. Place a shortcut to Emacs in this folder to run Emacs at boot. Change the target to &amp;lt;code&amp;gt;emacs --daemon&amp;lt;/code&amp;gt; to run start it in daemon mode. The best option for more advanced Emacs daemon-mode configuration on Windows is still not settled, there is some discussion on the Emacs Wiki which could potentially be sifted through.&lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47014</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47014"/>
		<updated>2015-06-22T21:30:12Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: Updated intro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture. The benefit of running emacs in server mode is that new client instances can be started up instantaneously.  If you have 100+ packages and starting Emacs usually takes several three seconds, using server mode creates a much more streamlined workflow without sacrificing customization functionality.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
Configuration through the init daemon &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; is the preferred method of starting Emacs at launch on most major distributions, including Debian, Ubuntu, Fedora, OpenSUSE, Arch, and derivatives.&lt;br /&gt;
&lt;br /&gt;
To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, replacing the location of the emacs executable if necessary.  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;/etc/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=Emacs daemon&lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 WorkingDirectory=%h&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --e &amp;quot;(kill-emacs)&amp;quot;&lt;br /&gt;
 Restart=always&lt;br /&gt;
 &lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=console.target&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can simply add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because the process will begin up at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start first.&lt;br /&gt;
&lt;br /&gt;
== OS X ==&lt;br /&gt;
&amp;lt;code&amp;gt;launchd&amp;lt;/code&amp;gt; is the OS X analog of &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; and can be configured just as easily. If someone is familiar with launchd configuration please fill this in.&lt;br /&gt;
&lt;br /&gt;
== MS Windows ==&lt;br /&gt;
Open the startup folder by running the command &amp;lt;code&amp;gt;shell:startup&amp;lt;/code&amp;gt; in a run dialog or by typing it in the Windows Explorer path bar. Place a shortcut to Emacs in this folder to run Emacs at boot. Change the target to &amp;lt;code&amp;gt;emacs --daemon&amp;lt;/code&amp;gt; to run start it in daemon mode. The best option for more advanced Emacs daemon-mode configuration on Windows is still not settled, there is some discussion on the Emacs Wiki which could potentially be sifted through.&lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47013</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47013"/>
		<updated>2015-06-22T21:25:52Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: /* In OS X */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
Configuration through the init daemon &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; is the preferred method of starting Emacs at launch on most major distributions, including Debian, Ubuntu, Fedora, OpenSUSE, Arch, and derivatives.&lt;br /&gt;
&lt;br /&gt;
To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, replacing the location of the emacs executable if necessary.  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;/etc/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=Emacs daemon&lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 WorkingDirectory=%h&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --e &amp;quot;(kill-emacs)&amp;quot;&lt;br /&gt;
 Restart=always&lt;br /&gt;
 &lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=console.target&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can simply add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because the process will begin up at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start first.&lt;br /&gt;
&lt;br /&gt;
== OS X ==&lt;br /&gt;
&amp;lt;code&amp;gt;launchd&amp;lt;/code&amp;gt; is the OS X analog of &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; and can be configured just as easily. If someone is familiar with launchd configuration please fill this in.&lt;br /&gt;
&lt;br /&gt;
== MS Windows ==&lt;br /&gt;
Open the startup folder by running the command &amp;lt;code&amp;gt;shell:startup&amp;lt;/code&amp;gt; in a run dialog or by typing it in the Windows Explorer path bar. Place a shortcut to Emacs in this folder to run Emacs at boot. Change the target to &amp;lt;code&amp;gt;emacs --daemon&amp;lt;/code&amp;gt; to run start it in daemon mode. The best option for more advanced Emacs daemon-mode configuration on Windows is still not settled, there is some discussion on the Emacs Wiki which could potentially be sifted through.&lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47012</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47012"/>
		<updated>2015-06-22T21:25:41Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: Discuss starting on Windows&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Linux ==&lt;br /&gt;
&lt;br /&gt;
Configuration through the init daemon &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; is the preferred method of starting Emacs at launch on most major distributions, including Debian, Ubuntu, Fedora, OpenSUSE, Arch, and derivatives.&lt;br /&gt;
&lt;br /&gt;
To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, replacing the location of the emacs executable if necessary.  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;/etc/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=Emacs daemon&lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 WorkingDirectory=%h&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --e &amp;quot;(kill-emacs)&amp;quot;&lt;br /&gt;
 Restart=always&lt;br /&gt;
 &lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=console.target&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can simply add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because the process will begin up at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start first.&lt;br /&gt;
&lt;br /&gt;
== In OS X ==&lt;br /&gt;
&amp;lt;code&amp;gt;launchd&amp;lt;/code&amp;gt; is the OSX analog of &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; and can be configured just as easily. If someone is familiar with launchd configuration please fill this in. &lt;br /&gt;
&lt;br /&gt;
== MS Windows ==&lt;br /&gt;
Open the startup folder by running the command &amp;lt;code&amp;gt;shell:startup&amp;lt;/code&amp;gt; in a run dialog or by typing it in the Windows Explorer path bar. Place a shortcut to Emacs in this folder to run Emacs at boot. Change the target to &amp;lt;code&amp;gt;emacs --daemon&amp;lt;/code&amp;gt; to run start it in daemon mode. The best option for more advanced Emacs daemon-mode configuration on Windows is still not settled, there is some discussion on the Emacs Wiki which could potentially be sifted through.&lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47011</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47011"/>
		<updated>2015-06-22T21:17:10Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: /* Adding To OS Startup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Using Systemd ==&lt;br /&gt;
&lt;br /&gt;
This is the preferred method of starting Emacs at launch on most major distributions, including Debian, Ubuntu, Fedora, OpenSUSE, Arch, and derivatives.&lt;br /&gt;
&lt;br /&gt;
To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, replacing the location of the emacs executable if necessary.  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;/etc/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=Emacs daemon&lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 WorkingDirectory=%h&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --e &amp;quot;(kill-emacs)&amp;quot;&lt;br /&gt;
 Restart=always&lt;br /&gt;
 &lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=console.target&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can simply add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because the process will begin up at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start first.&lt;br /&gt;
&lt;br /&gt;
== In OS X ==&lt;br /&gt;
&amp;lt;code&amp;gt;launchd&amp;lt;/code&amp;gt; is the OSX analog of &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; and can be configured just as easily. If someone is familiar with launchd configuration please fill this in. &lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47010</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47010"/>
		<updated>2015-06-22T21:15:56Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: /* Using Systemd */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Using Systemd ==&lt;br /&gt;
&lt;br /&gt;
This is the preferred method of starting Emacs at launch on most major distributions, including Debian, Ubuntu, Fedora, OpenSUSE, Arch, and derivatives.&lt;br /&gt;
&lt;br /&gt;
To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, replacing the location of the emacs executable if necessary.  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;/etc/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=Emacs daemon&lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 WorkingDirectory=%h&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --e &amp;quot;(kill-emacs)&amp;quot;&lt;br /&gt;
 Restart=always&lt;br /&gt;
 &lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=console.target&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can simply add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because the process will begin up at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start first.&lt;br /&gt;
&lt;br /&gt;
== In OS X ==&lt;br /&gt;
It is possible to use launchd to perform the very same behavior. If someone is familiar with launchd configuration please fill this in. &lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47009</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47009"/>
		<updated>2015-06-22T21:15:44Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: /* Using Systemd */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Using Systemd ==&lt;br /&gt;
&lt;br /&gt;
This is the preferred method of starting Emacs at launch on most major distributions, including Debian, Ubuntu, Fedora, OpenSUSE, Arch, and derivatives.&lt;br /&gt;
&lt;br /&gt;
To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, replacing the location of the emacs executable if necessary.  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;/etc/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=Emacs daemon&lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 WorkingDirectory=%h&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --e &amp;quot;(kill-emacs)&amp;quot;&lt;br /&gt;
 Restart=always&lt;br /&gt;
 &lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=console.target&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can simply add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because the process will begin up at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start first&lt;br /&gt;
&lt;br /&gt;
== In OS X ==&lt;br /&gt;
It is possible to use launchd to perform the very same behavior. If someone is familiar with launchd configuration please fill this in. &lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47008</id>
		<title>Emacs server</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Emacs_server&amp;diff=47008"/>
		<updated>2015-06-22T21:09:31Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: /* Adding To OS Startup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Emacs includes an optional client-server architecture.&lt;br /&gt;
&lt;br /&gt;
== Starting the Server ==&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;code&amp;gt;server-start&amp;lt;/code&amp;gt; ===&lt;br /&gt;
To start a server in an existing Emacs session, run {{Command|server-start}}. A server started in this manner will close when the last visible Emacs frame closes. If you want Emacs to automatically run a server on startup, add the following to your configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
(server-start)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== With &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; ===&lt;br /&gt;
Emacs 23 and higher provide the &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt; command-line argument, which will cause Emacs to immediately start a server and fork into the background. A server started in this manner is fully daemonized and will remain running even with no visible Emacs frames and after its parent terminal has closed (for example, after an SSH session has disconnected). &lt;br /&gt;
&lt;br /&gt;
Note that, if using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, your configuration file will be run while Emacs is still in a terminal. This may affect your theming if you usually use graphical Emacs.&lt;br /&gt;
&lt;br /&gt;
{{Note}}This option is not supported on [[Windows]].&lt;br /&gt;
&lt;br /&gt;
== Using Clients ==&lt;br /&gt;
&lt;br /&gt;
Once the server is started you may use the &amp;lt;code&amp;gt;emacsclient&amp;lt;/code&amp;gt; command outside of Emacs to send a file to Emacs for editing, e.g. &amp;lt;code&amp;gt;emacsclient ~/.emacs.d/init.el&amp;lt;/code&amp;gt; to modify your init file. On a GNU/Linux system it might be a good idea to set your &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; environment variable to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt;. Using &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; without any arguments will cause the calling process to simply pause and wait for the Emacs server to report that it's done editing. Using &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; will cause the calling process to put up a text-mode frame in the same terminal.&lt;br /&gt;
&lt;br /&gt;
If the server was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, you should run &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -nc&amp;lt;/tt&amp;gt; to create a visible frame to interact with.&lt;br /&gt;
== Finishing Up ==&lt;br /&gt;
&lt;br /&gt;
Once you have finished with a buffer that was opened via &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; you should use the {{CommandKeys|C-x #|server-edit}} to properly close the loop. Killing the buffer normally will not send the signal to &amp;lt;tt&amp;gt;emacsclient&amp;lt;/tt&amp;gt; that Emacs has finished with the file.&lt;br /&gt;
&lt;br /&gt;
If you're in an Emacs session that was started using &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, {{Keys|C-x C-c}} will only close the frame that it was invoked in. It will also signal to the client that owns the frame that its editing job is done, so &amp;lt;tt&amp;gt;emacsclient -c&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacsclient -t&amp;lt;/tt&amp;gt; as &amp;lt;tt&amp;gt;EDITOR&amp;lt;/tt&amp;gt; will behave much like a full &amp;lt;tt&amp;gt;emacs&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;emacs -nw&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To entirely close a server started with &amp;lt;tt&amp;gt;--daemon&amp;lt;/tt&amp;gt;, run {{Command|save-buffers-kill-emacs}} in a frame.&lt;br /&gt;
= Adding To OS Startup =&lt;br /&gt;
== Using Systemd ==&lt;br /&gt;
&lt;br /&gt;
During systemd's widespread adoption, part of the discussion which has been missed is the functionality it offers.  To tell systemd to start Emacs on init, place the following script &amp;lt;code&amp;gt;emacsd.service&amp;lt;/code&amp;gt; in your systemd user configuration folder, replacing the location of the emacs executable if necessary.  On Debian-based distributions, this file should be named &amp;lt;code&amp;gt;/etc/systemd/user/emacsd.service&amp;lt;/code&amp;gt;.  &lt;br /&gt;
&lt;br /&gt;
 [Unit]&lt;br /&gt;
 Description=Emacs daemon&lt;br /&gt;
 &lt;br /&gt;
 [Service]&lt;br /&gt;
 Type=forking&lt;br /&gt;
 WorkingDirectory=%h&lt;br /&gt;
 ExecStart=/usr/bin/emacs --daemon&lt;br /&gt;
 ExecStop=/usr/bin/emacsclient --e &amp;quot;(kill-emacs)&amp;quot;&lt;br /&gt;
 Restart=always&lt;br /&gt;
 &lt;br /&gt;
 [Install]&lt;br /&gt;
 WantedBy=console.target&lt;br /&gt;
&lt;br /&gt;
If systemd is not available on your distribution, you can simply add &amp;lt;code&amp;gt;/usr/bin/emacs --daemon&amp;lt;/code&amp;gt; to your crontab. However using systemd is preferable because the process will begin up at boot, i.e. without depending on the &amp;lt;code&amp;gt;cron&amp;lt;/code&amp;gt; process to start first&lt;br /&gt;
&lt;br /&gt;
== In OS X ==&lt;br /&gt;
It is possible to use launchd to perform the very same behavior. If someone is familiar with launchd configuration please fill this in. &lt;br /&gt;
&lt;br /&gt;
[[Category: Server]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
	<entry>
		<id>https://wikemacs.org/index.php?title=Shell&amp;diff=46989</id>
		<title>Shell</title>
		<link rel="alternate" type="text/html" href="https://wikemacs.org/index.php?title=Shell&amp;diff=46989"/>
		<updated>2015-05-24T16:40:49Z</updated>

		<summary type="html">&lt;p&gt;Miabraha: Cleaned up the shell mode hook stuff&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Shell-mode''' gives access to a shell in a normal emacs buffer, meaning you can move around and edit it as usual. A drawback is that you can not launch programs like htop or other ncurses ones, like you would in term-mode.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
== basics ==&lt;br /&gt;
&lt;br /&gt;
{{Command|shell}}&lt;br /&gt;
&lt;br /&gt;
Look at the menu: you have several keys to interact with the shell. Some of them are:&lt;br /&gt;
&lt;br /&gt;
* {{Keys|M-p}} previous input of command line&lt;br /&gt;
* {{Keys|M-r}} search backward a regexp in commands' history (like C-r in term). Use C-r to cycle.&lt;br /&gt;
* {{Keys|C-c r}} go to beginning of output (useful when you have a large output and want to read through the beginning)&lt;br /&gt;
* {{Keys|C-c-p}} go to beginning of previous output group&lt;br /&gt;
* {{Keys|C-c-c}} send the '''C-c''' command to the shell&lt;br /&gt;
* {{Keys|C-c-o}} delete the output of the last command&lt;br /&gt;
&lt;br /&gt;
To launch a shell in the directory of the current buffer, have a look to '''shell-here''': https://github.com/ieure/shell-here (available through ELPA).&lt;br /&gt;
&lt;br /&gt;
== re-execute successive commands ==&lt;br /&gt;
&lt;br /&gt;
Often it is useful to reexecute several successive shell commands that were previously executed in sequence. To do this, first find and reexecute the first command of the sequence. Then type {{Keys|C-c C-x}}, that will fetch the following command--the one that follows the command you just repeated. Then type RET to reexecute this command. You can reexecute several successive commands by typing {{Keys|C-c C-x RET}} over and over.&lt;br /&gt;
&lt;br /&gt;
= Customisation =&lt;br /&gt;
&lt;br /&gt;
== More colors ==&lt;br /&gt;
&lt;br /&gt;
If you have bad colors in the output, try using '''ansi-mode''': &lt;br /&gt;
&lt;br /&gt;
     (require 'ansi-color)&lt;br /&gt;
     (defun colorize-compilation-buffer ()&lt;br /&gt;
     (toggle-read-only)&lt;br /&gt;
     (ansi-color-apply-on-region (point-min) (point-max))&lt;br /&gt;
       (toggle-read-only))&lt;br /&gt;
       (add-hook 'compilation-filter-hook 'colorize-compilation-buffer)&lt;br /&gt;
&lt;br /&gt;
You can highlight some text based on regexp (useful to see &amp;quot;OK&amp;quot; or warnings):&lt;br /&gt;
&lt;br /&gt;
       (add-hook 'shell-mode-hook (lambda () (highlight-regexp &amp;quot;\\[OK\\]&amp;quot; &amp;quot;hi-green-b&amp;quot;)))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Make URLs clickable ==&lt;br /&gt;
&lt;br /&gt;
    &lt;br /&gt;
    (add-hook 'shell-mode-hook (lambda () (goto-address-mode )))&lt;br /&gt;
&lt;br /&gt;
== Make file paths clickable ==&lt;br /&gt;
&lt;br /&gt;
Every line representing a path to a file will be colorized and made clickable, so that you can jump to that file and that line, like in compilation-mode (specially useful when compiling a program or running tests):&lt;br /&gt;
&lt;br /&gt;
    (add-hook 'shell-mode-hook 'compilation-shell-minor-mode)&lt;br /&gt;
&lt;br /&gt;
Now you can use key bindings from the mode: use {{CommandKeys|C-x `|next-error}} (backquote) to go to the next error detected in the shell. You can't do that in an xterm !&lt;br /&gt;
&lt;br /&gt;
== Shell completion with a nice menu à la zsh ==&lt;br /&gt;
&lt;br /&gt;
So you are in shell-mode and you are annoyed that emacs opens a new window with the list of completions when you press TAB and you like the pop-up menu that zsh offers ? The solution is to ask [http://company-mode.github.io/ company-mode] to do the shell completion. It has a built-in backend ''company-capf'' which fetches completion candidates from emacs' ''completion-at-point-functions'' (the same mechanism that powers completion in the shell) as such completion offered by company is as accurate as the built-in shell-mode while making the user interface very convenient. We can activate it with:&lt;br /&gt;
&lt;br /&gt;
    (add-hook 'shell-mode-hook #'company-mode)&lt;br /&gt;
    (define-key shell-mode-map (kbd &amp;quot;TAB&amp;quot;) #'company-manual-begin))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And the result:&lt;br /&gt;
&lt;br /&gt;
[[File:emacs-shell-company.png]]&lt;br /&gt;
&lt;br /&gt;
== Change directory with ido-mode ==&lt;br /&gt;
&lt;br /&gt;
Using [[ido]]'s completion system for changing directories is a big gain in usability and efficiency for emacs' shell. The little package [https://gitlab.com/emacs-stuff/fasd-shell fasd-shell] allows to use the '''fasd''' shell utility in conjonction with '''ido-completion''' to effectively change directories. Its code comes from this Stack Overflow question: http://stackoverflow.com/questions/20952995/emacs-shell-change-directory-with-ido&lt;br /&gt;
&lt;br /&gt;
== Shared and persistent history ==&lt;br /&gt;
&lt;br /&gt;
By default a shell session inside emacs via '''shell-mode''' won't persist accross sessions and won't read your shell's history. The '''history''' shell command works as expected, but you can't search (with '''M-r''') a command that you typed in shell-mode in another emacs instance or in a term. The following fixes that.&lt;br /&gt;
&lt;br /&gt;
For '''comint-mode''' and derivatives (including '''shell-mode''') the searchable history is read in via '''comint-read-input-ring''', which uses '''comint-input-ring-file-name''' which you can set in a mode hook. However I would suggest that you actually set your HISTFILE environment variable to ~/.zsh_history because shell-mode automatically defers to that.&lt;br /&gt;
&lt;br /&gt;
The documentation suggests that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lisp&amp;quot;&amp;gt;&lt;br /&gt;
    (add-hook 'shell-mode-hook 'my-shell-mode-hook)&lt;br /&gt;
    (defun my-shell-mode-hook ()&lt;br /&gt;
      (setq comint-input-ring-file-name &amp;quot;~/.zsh_history&amp;quot;)  ;; or bash_history&lt;br /&gt;
      (comint-read-input-ring t))&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you want to persist more variables (mini-buffer history,…), enable '''savehist-mode''' and configure the variables you wish to persist between sessions. See {{Command|customize-group RET savehist RET}}.&lt;br /&gt;
&lt;br /&gt;
== Sync environment variables like $PATH from the shell ==&lt;br /&gt;
&lt;br /&gt;
On OSx (and elsewhere ?) the $PATH environment variable and `exec-path' used by a windowed Emacs instance will usually be the system-wide default path, rather than that seen in a terminal window. The library [http://melpa.milkbox.net/#/exec-path-from-shell '''exec-path-from-shell'''] (in MELPA) allows the user to set Emacs' &amp;lt;code&amp;gt;exec-path&amp;lt;/code&amp;gt; and $PATH from the shell path, so that &amp;lt;code&amp;gt;shell-command&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;compile&amp;lt;/code&amp;gt; and the like work as expected. It also allows other environment variables to be retrieved from the shell, so that Emacs will see the same values you get in a terminal.&lt;br /&gt;
&lt;br /&gt;
== Change directory or find files based on &amp;quot;frecency&amp;quot; with z/autojump/fasd ==&lt;br /&gt;
&lt;br /&gt;
[https://github.com/clvv/fasd Fasd], z or autojump are popular shell tools for jumping around commonly used directories and (for fasd) to execute actions on files. It uses &amp;quot;[https://github.com/rupa/z/wiki/frecency frecency]&amp;quot; as a metric for determining which directory you intend to jump to based on keyword completions. So if I commonly cd to {{Filename|~/.ssh}}, I can &amp;lt;code&amp;gt;fasd ssh&amp;lt;/code&amp;gt; to jump there. &lt;br /&gt;
&lt;br /&gt;
The first question is: how to find files with these tools in Emacs ?&lt;br /&gt;
&lt;br /&gt;
And next, since they work but can not use the built-in shell completion, how to get them use ido completion in emacs shell mode ?&lt;br /&gt;
&lt;br /&gt;
=== Find files with fasd ===&lt;br /&gt;
&lt;br /&gt;
There's an emacs package to find files with fasd: https://github.com/steckerhalter/emacs-fasd &lt;br /&gt;
If you want it to be more interactive, you can set:&lt;br /&gt;
&lt;br /&gt;
    (setq fasd-enable-initial-prompt nil)  ;; don't ask for first query but fire fuzzy completion straight away.&lt;br /&gt;
&lt;br /&gt;
=== Get ido completion to cd in shell ===&lt;br /&gt;
&lt;br /&gt;
A great complementary thing with these tools is the use of the shell's completion to change directories, where zsh is a winner. Let's use [[ido]] for that. This feature is available as a minor mode with this code: https://gitlab.com/emacs-stuff/fasd-shell/tree/master&lt;br /&gt;
&lt;br /&gt;
Now you can type &amp;lt;code&amp;gt;d my doc TAB&amp;lt;/code&amp;gt; and ido will ask what directory (a directory that you already visited with the regular cd and that has both &amp;quot;my&amp;quot; and &amp;quot;doc&amp;quot; in its full path) to cd to.&lt;br /&gt;
&lt;br /&gt;
== Use a buffer as $PAGER ==&lt;br /&gt;
&lt;br /&gt;
This is possible with [https://github.com/mbriggs/emacs-pager emacs-pager]. Now things like ''less'' will open in a new buffer with colorized output.&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
&lt;br /&gt;
== shell-pop ==&lt;br /&gt;
&lt;br /&gt;
'''shell-pop''' to pop up and pop out a shell buffer window easily (installable via ELPA), a bit like guake terminal in Gnome.&lt;br /&gt;
&lt;br /&gt;
== Shell-here ==&lt;br /&gt;
&lt;br /&gt;
Use [https://github.com/ieure/shell-here shell-here] to open an Emacs shell in the current directory.&lt;br /&gt;
&lt;br /&gt;
== dirswitch ==&lt;br /&gt;
&lt;br /&gt;
With [https://github.com/mickeynp/dirswitch.el dirswitch], cycle through directories you've visited, like in fish shell.&lt;br /&gt;
&lt;br /&gt;
[[Category:Shell]]&lt;br /&gt;
[[Category:Intermediate]]&lt;/div&gt;</summary>
		<author><name>Miabraha</name></author>
	</entry>
</feed>