Editing With Emacs

Posted:

Over the years I've written about using Emacs for editing, describing the various patterns I'm using. The goal of this blog entry is to do a rundown of everything involved for an up-to-date look at what I'm actually doing nowadays. Read on for the deep dive!

Why I Use Emacs

Generally speaking, I'm not a big fan on selling something just because I like it. I try to think about if the thing I'd sell would actually be good for this person, or if I'm just soapboxing and being cute. With Emacs and text editors in general it tends to be a highly subjective and personal decision, so I've never really been into trying to preach the good news of Emacs to unsuspecting folks.

With that out of the way: I use Emacs because I love its extensibility and how it gives me the ability to configure virtually all aspects of it with code. There's more to it, like the story of why I ever chose to even try Emacs to begin with, but in a nutshell that's the general reason for my chosing it. 1

Daemon

I've only ever ran the Emacs daemon on Linux, but I'd say it's definitely worth doing. A few reasons:

Specifically and as I've written about before: I run the Emacs daemon as a "user service" under runit. It works fine as either a system-level service or "user service", I mostly do the user service thing just to be doing it.

In any case, here's what my service run script looks like:

#!/bin/sh
export USER=hristos
uid="$(id -g $USER)"
export UID="$uid"
export HOME=/home/$USER
export PATH=$HOME/.local/bin:"$PATH"
export XDG_RUNTIME_DIR=/run/user/"$UID"
export PRINTER=MY_PRINTER_NAME
export DISPLAY=:0
export PYTHONPATH=$HOME/.local/lib/python3.11/site-packages

# This allows the Emacs daemon to work with ssh-agent
eval "$(cat $HOME/.ssh/environment | sed "s|setenv|export|g;s|SOCK |SOCK=|;s|PID |PID=|")"
cd $HOME || echo "OOPS, NO HOME?!"

exec /usr/bin/emacs --fg-daemon=$USER-emacsd

One non-obvious part is the usage of eval; this is done to let the Emacs daemon process work with my ssh-agent. This may or may not fit into your own workflow of course.

External Dependencies

Some modes, lsp-mode in particular and likely also eglot, require an external binary to be present on your system and in PATH. This includes but may not be limited to:

Editing Code

TODO

Eshell

TODO

General Writing

TODO

Extra Stuff

TODO

macOS / Windows

TODO

Footnotes And References

1 It all started when I worked at onShore Development, which at the time developed an application with Common Lisp. I got a crash course in SLIME and customizing Emacs and never looked back!

This page was last modified on: