Blog/Home is where your Emacs is always ready

From ~esantoro
Revision as of 23:27, 23 January 2024 by Esantoro (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Just a quick note (for now), but similarly to Blog/Home is where your screen session is I recently adapted that same technique to keeping an emacs daemon always running.

Enjoy the quick snippet:

[Unit]
Description=Always on GNU Emacs daemon

Wants=default.target
After=default.target

[Service]
Environment="SSH_AUTH_SOCK=/run/user/1000/ssh-agent.sock"
Type=simple
ExecStart=emacs --fg-daemon
Restart=always
RestartSec=3
StartLimitBurst=1

[Install]
WantedBy=default.target

Quick notes

  • the Environment=... is needed to help TRAMP mode work with ssh-agent, so that I'm not asked for password or passphrases
  • the --fg-daemon prevents emacs from forking to background, so it can be managed by systemd