Screenshot of newly compiled Emacs showing syntax highlighting via tree-sitter and variable renaming via eglot.

Compiling Emacs 29 on Ubuntu LTS 22.04

I’ve been on a kick to better understand my developer toolbox, and I recently decided to start by compiling Emacs from source on my trusty Ubuntu LTS 22.04. In the case of Emacs, my primary motivation was to explore the latest features bundled with version 29, such as tree-sitter and eglot. These two packages bundled into Emacs core means not relying on third-party packages for syntax highlighting or LSP support.

Compiling Emacs from scratch on Linux was a new venture, but it was straightforward. One unfamiliar term that popped up was make bootstrap. In Emacs’ case, this essentially wipes the slate clean, deleting any pre-compiled Elisp modules before building from scratch:

make bootstrap – delete all compiled files to force a new bootstrap from a clean slate, then build in the normal way

Here’s a condensed version of the process I followed:

# Setting up Emacs in our source directory
mkdir -p ~/src && cd ~/src
git clone git://git.savannah.gnu.org/emacs.git
git checkout emacs-29

# Enable development libraries and update apt cache
sudo sed -i 's/# deb-src/deb-src/' /etc/apt/sources.list \
  && apt update

# Install necessary dependencies
sudo apt build-dep -y emacs \
  && sudo apt install libtree-sitter-dev

# Generate the configure file
./autogen.sh

# Configure Emacs with desired options
./configure --with-tree-sitter --with-imagemagick --with-json

# Compile with 4 cores
make -j4 bootstrap

# Verify the version
./src/emacs --version

# Optionally, test things by launching Emacs without any configuration
./src/emacs -Q

# When things look good, install Emacs system-wide
sudo make install


Posted

in

by