Timothy Johnson

Emacs as a server Written By Timothy Johnson

Emacs as a Daemon

This guide will get emacs running as a server on Linux systems. This means that each time you load a file emacs is ready and doesn’t need to load. On some systems emacs start up times can be several seconds so having emacs there and ready to go can save you some real time and improve your workflows.

I always forget how to do this so this guide is for me more than anyone else!

First, create the following file:


Within this file paste the following:

Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/

ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(kill-emacs)"


Enable this by running:

systemctl enable --user emacs
systemctl start --user emacs

This starts the server on boot.

Open ~/.bashrc and add the following:

alias emacs="emacsclient --create-frame" 

This means each time you type “emacs” in the terminal, it will open a new instance of the client in a new frame.

Finally run

xdg-mime default emacsclient.desktop text/plain

This will open all text files within the emacs client.

Give the system a reboot and you are good to go.

All done! This has emacs running how I like it. Feel free to change to suit your workflow.