📝 This guide is outdated. There exists an AUR package called
emacs-nativecompwhich you can install to achieve the same result.
Emacs is probably my favourite “text editor” to use on Linux, as it is so extensible. However, the one thing that puts many people off using it (ignoring its complexity), is the fact that it is only single threaded, and can at times feel a little sluggish when compared to other editors like Vim.
With Emacs 28.1, along with the libgccjit (Just-In-Time Compilation with GCC) library, we now have the ability to translate Emacs Lisp into machine code on demand - which will speed things up. With this, you may notice a drastic speed increase during your day-to-day use of Emacs.
If you’ve already installed an older version of Emacs with your package manager - uninstall it:
yay -R emacs
First we need to download the source code for the latest version of Emacs. For this example we’ll be using Emacs 28.2, but the same steps will apply for later versions.
Then we need to unpack it:
tar -xf emacs-28.2.tar.xz
Let’s navigate into the Emacs source folder:
Now let’s install the required JIT compilation with GCC backend library:
yay -S libgccjit
We can now build Emacs:
Now, we can make:
And lastly, install it for use:
sudo make install
# where is it?
# > emacs: /usr/local/bin/emacs /usr/local/lib/emacs /usr/share/emacs
# check version
# > emacsclient 28.2
DOOM Emacs Users
Once you’ve compiled and installed Emacs with native compilation, ensure you run the following command to compile your Emacs packages:
I like to run the emacsclient rather than launching a single instance of Emacs when needed. By doing this I can launch into it faster, as the emacsclient runs continually in the background and will spawn new windows almost instantly..
In your application startup add this:
emacs --daemon &
In your hotkeys, you can add a command to launch Emacs in client mode. This is how I do it using sxhkd:
super + alt + m
emacsclient -c -a emacs
Set Emacs As Default Editor
You can make Emacs your default text editor by setting up a few variables which your system will use when you log in. To do this, edit your
.profile file in your
$HOME and add the following:
export EDITOR="emacsclient -t"
export CODEEDITOR="emacsclient -c -a 'emacs'"
export VISUAL="emacsclient -c -a 'emacs'"
export SUDO_EDITOR="emacsclient -t"