Running Emacs from Systemd

One of the perennial complaints about Emacs is that it takes a long time to start. Of course, the answer to that is just don’t do it. Or at least only do it once when you log in. Many us have long running Emacs sessions, sometimes lasting months. Every Sunday, I update my packages and afterwards I restart Emacs just to be on the safe side so my sessions last a week.

I have Emacs running in its own desktop so it’s always there when I need it but you don’t have to do things that way. Another option is to run Emacs in server mode and then bring up an instance when you need it by calling emacsclient. That’s instantaneous so if you prefer to have Emacs out of the way when you’re not using it, that’s easy too.

Once you decide to run Emacs as a server, the question arises as to how you should start it. It’s easy to do that manually but if you’re a Linux user you can arrange to have Systemd start it for you when you log in. That way, you never have to think about starting Emacs—it’s always there.

Yi Tang has a post that shows you how to use Systemd to start Emacs. It’s simply a matter a adding Emacs to Systemd configuration file and telling Systemd to reread its configuration. After that everything is automatic. Tang also tells you how to start Emacs in server mode manually if you prefer. That works in any system, of course.

It’s possible to do this sort of thing in macOS too but I’ve never felt the need. The longest part of my Emacs startup is its waiting for me to type in the .authinfo password so it’s a painless operation that, in any event, I usually do only once a week.

This entry was posted in General and tagged . Bookmark the permalink.