Every few years I need to install Emacs on another Linux system and I waste a bunch of time remembering how to do it properly. This time I finally decided to take some notes! I’ve written them up as a blog post in case they’re helpful for other people too.
In the past, I’ve needed to install very recent versions of Emacs, if that’s you, you can install one of the Emacs snapshot packages. These days however, I find that the versions packaged in Debian/Ubuntu are recent enough for my purposes1. For example, at the time of writing, Debian Buster provides 26.1 and Ubuntu Eon provides 26.3. Unless you have a good reason, I recommend just going with the version your Linux distribution provides.
Launching Emacs can take a while if your configuration is of a reasonable size. Luckily though, Emacs has a client/server mode which allows you to have a headless copy of Emacs start as your Emacs server at boot time. Then anytime you open Emacs, you’re really just opening a client which connects to your pre-existing Emacs server. It’s way faster.
Running Emacs like that provides some great flexibility too. For example, I can SSH to my desktop computer, fire up an Emacs client and continue working with all my existing buffers. It also means that if your system’s GUI restarts you don’t lose any work, invaluable!
One thing to note however, the GTK build of Emacs has a nasty problem which means that the Emacs server closes when the system’s GUI restarts. Therefore I recommend going with the Lucid build of Emacs instead. It seems a lot stabler, though a little uglier by default - but we’ll get to that.
So first, let’s install Emacs:
Next, we’ll set up the systemd service to ensure that your Emacs server starts when the computer boots:
When you start Emacs from the application launcher, or by clicking on a file in your file manager, you’ll want it to connect to the existing Emacs server instead of starting whole new copy of Emacs. We can ensure that by installing our own emacs.desktop file:
If you need to connect to your Emacs server from the console, you can do so by typing this:
Some terminal commands, for example
git config --edit, will launch your
default editor. Let’s make sure they make use of the existing Emacs server too:
Next we need to configure Emacs to make the Lucid build look less ugly. I found that by disabling the toolbars and increasing the font size it looks identical to the GTK build. Add this to your Emacs configuration:
You’ll need to get used to looking at the mode line to see your position in a buffer instead of the scrollbars. I found that a little weird initially, but after I adapted I found that it saved screen estate and was less visually distracting.
By default, text which you highlight wont be “yankable”. For example, if you
highlight some text in your web browser, then hit
C-y in Emacs the highlighted
text won’t be pasted. That can be fixed by adding the following to your Emacs
Emacs using some different key-bindings than the Windows etc norm. For example,
C-a moves to the start of the line instead of selecting all. To make the
key-bindings a bit more consistent, you can use the Emacs GTK key theme:
Or, if you’re using XFCE:
I also found that by default special Unicode characters (e.g. 😎) aren’t rendered properly. This can be fixed with help from the Symbola font.
First, install the Symbola font and restart the Emacs server:
Then add this to your Emacs configuration:
Now special characters in Emacs buffers should be displayed properly.
To get spell checking to work, I recommend installing Hunspell and a language pack before restarting the Emacs server:
Unless you also use British English, replace
hunspell-en-gb with the language
pack of your choice.
And finally, add the corresponding Emacs lisp to your configuration (again
you’ll need to replace
"en_GB" with the appropriate language code):
Now you should be good to go, try it out with
Of course, configuring Emacs once it’s installed is a whole other topic! There’s no way to cover that in a blog post, but if you’re curious to take a look my Emacs configuration is online.
One thing that it might be worth using a snapshot build for is colour font support. For example, Ubuntu 20.04 comes with the
fonts-noto-color-emojipackage with great looking colour emojis. If you’d like to try using a snapshot build of Emacs, I recommend going for the Debian APT repository, even if you’re running Ubuntu. That includes the
emacs-snapshot-lucidpackage, unlike the Ubuntu repository. If you are installing it on Ubuntu, you might need to install the
libjpeg62-turboDebian package manually first. Once you have a snapshot build running, you can replace
"Noto Color Emoji"in your Emacs configuration. ↩