Trying Out Emacs 29

GNU Emacs is a free and open-source text editor, it’s known for its extensibility and the ability to customize almost every aspect of its functionality through the use of Emacs Lisp code. I first started using it many years ago, around 2007 I think. After a hiatus of a few years, I have got back into using it as my daily driver.

There’s a new major release of GNU Emacs in development, and everyone is raving about it. It has got a lot of interesting new features like Eglot, and tree-sitter. In this blog post I will download the source code from Git, and compile to to try out the new features.

git clone -b emacs-29 https://git.savannah.gnu.org/git/emacs.git

If you want to follow this blog post and get similar results, then I compiled the following Git commit: 63cdbd986bb8f841717e2d813df6f75b6b02cf8b. You can checkout this version with Git, but this is optional, you can just download the Emacs 29 release when it comes out and it should work the same. Just skip the “autogen” part as the release tarball should include the “configure” script.

$ git checkout 63cdbd986bb8f841717e2d813df6f75b6b02cf8b

We need to ensure we have all the dependencies that are needed to compile Emacs, I’m using Ubuntu 22.04 and have installed the following packages using APT.

  • build-essential
  • libxaw7-dev, librsvg2-dev, libjpeg-dev, libpng-dev. libxpm-dev, libgif-dev
  • libgtk-3-dev
  • libgnutls28-dev
  • texinfo
  • libgccjit-11-dev
  • libjansson-dev
  • libsystemd-dev
  • libncurses-dev
  • libacl1-dev
  • libwebkit2gtk-4.0-dev (if you want xwidgets support)
  • libtree-sitter-dev

Run the following command to install all the required dependencies for Ubuntu.

$ sudo apt install -y build-essential libxaw7-dev librsvg2-dev libjpeg-dev libpng-dev libxpm-dev libgif-dev libgtk-3-dev libgnutls28-dev texinfo libgccjit-11-dev libjansson-dev libsystemd-dev libncurses-dev libacl1-dev libtree-sitter-dev

The build system that GNU Emacs uses to build from source is called GNU Autotools. If you don’t knwo, then GNU Autotools is a set of tools that is used to build, install, and manage software packages on Unix-like systems. It consists of three main components: Autoconf, Automake, and Libtool. Autoconf is used to create portable configure scripts that can be used to set up a package’s build system. Automake is used to generate Makefiles that are used to build the package. Libtool is used to create portable libraries that can be used in multiple environments. Together, these tools help to automate the process of building, installing, and managing software packages, making it easier for developers to create software that can be easily compiled and installed on a wide range of systems.

As I’m compiling source I pulled from Git, there is not configure script, so the next step is to run Autogen to create the configure script.

$ ./autogen.sh

Nex we run the configure script, this will check the build environment to ensure all the necessary dependencies are present, and then create a Makefile we can run. I have used “–prefix” here to control where Emacs gets installed.

$ ./configure --prefix=$HOME/.local --with-native-compilation

If the build environment is ok, the compiler is there, all the dependencies are there, ect.. Then, this is the summary of features you should see. If something is wrong then you will get errors from configure.

Configured for 'x86_64-pc-linux-gnu'.

  Where should the build process find the source code?    .
  What compiler should emacs be built with?               gcc -g3 -O2
  Should Emacs use the GNU version of malloc?             no
    (The GNU allocators don't work with this system configuration.)
  Should Emacs use a relocating allocator for buffers?    no
  Should Emacs use mmap(2) for buffer allocation?         no
  What window system should Emacs use?                    x11
  What toolkit should Emacs use?                          GTK3
  Where do we find X Windows header files?                Standard dirs
  Where do we find X Windows libraries?                   Standard dirs
  Does Emacs use -lXaw3d?                                 no
  Does Emacs use -lXpm?                                   yes
  Does Emacs use -ljpeg?                                  yes
  Does Emacs use -ltiff?                                  yes
  Does Emacs use a gif library?                           yes -lgif
  Does Emacs use a png library?                           yes -lpng16 -lz
  Does Emacs use -lrsvg-2?                                yes
  Does Emacs use -lwebp?                                  no
  Does Emacs use -lsqlite3?                               yes
  Does Emacs use cairo?                                   yes
  Does Emacs use -llcms2?                                 yes
  Does Emacs use imagemagick?                             no
  Does Emacs use native APIs for images?                  no
  Does Emacs support sound?                               yes
  Does Emacs use -lgpm?                                   no
  Does Emacs use -ldbus?                                  yes
  Does Emacs use -lgconf?                                 no
  Does Emacs use GSettings?                               yes
  Does Emacs use a file notification library?             yes -lglibc (inotify)
  Does Emacs use access control lists?                    yes -lacl
  Does Emacs use -lselinux?                               yes
  Does Emacs use -lgnutls?                                yes
  Does Emacs use -lxml2?                                  yes
  Does Emacs use -lfreetype?                              yes
  Does Emacs use HarfBuzz?                                yes
  Does Emacs use -lm17n-flt?                              no
  Does Emacs use -lotf?                                   no
  Does Emacs use -lxft?                                   no
  Does Emacs use -lsystemd?                               yes
  Does Emacs use -ljansson?                               yes
  Does Emacs use -ltree-sitter?                           yes
  Does Emacs use the GMP library?                         yes
  Does Emacs directly use zlib?                           yes
  Does Emacs have dynamic modules support?                yes
  Does Emacs use toolkit scroll bars?                     yes
  Does Emacs support Xwidgets?                            no
  Does Emacs have threading support in lisp?              yes
  Does Emacs support the portable dumper?                 yes
  Does Emacs support legacy unexec dumping?               no
  Which dumping strategy does Emacs use?                  pdumper
  Does Emacs have native lisp compiler?                   yes
  Does Emacs use version 2 of the X Input Extension?      yes
  Does Emacs generate a smaller-size Japanese dictionary? no

Now the build environment is ready to build Emacs. Let’s run make to do the build. We pass “-j” to parallelise the build if multiple cores are available.

$ make -j$(nproc)

This step takes a long time, be patient. Once it’s finished we can run “make install” to install Emacs.

$ make install

Aswesome, so now we have GNU Emacs compiled, and installed so let’s try it out.

$ ~/.local/bin/emacs --init-directory=/tmp

This was our first opportunity to try out a new feature, the “–init-directory” argument. It allows us to control where Emacs looks for “.emacs.d”, by setting it to “/tmp” we prevent Emacs 29 from loading my configuration.

Now it’s time to play with Emacs 29…