Emacs For The Win

3 minute read


WSL2 woes

My IDE of choice for the past year has been Emacs, more specfically Doom Emacs. However in changing jobs I’ve found myself cornered on a Windows desktop. This has posed some challenges, specifically around having a fast and smooth development experience using Emacs. My get up and running approach was to install Emacs vanilla with a pre-built binary.

But alas, this resulted in a 20+ second load time. So I chose the next best thing, WSL2. WSL2 on Windows 11 is an amazing option given that you can now leverage GTK. For instructions on doing this look no further then Bozhidar Batsov.

I followed this process, compiled Emacs 29 with PGTK and even added the hack for copying from Windows to Emacs. But I was disappointed with an experience of instability, where Emacs would occassionally crash (without warning) and at times copying being sporadic or not working in certain screens. But the real killer was the networking from WSL2 to my Windows Host.

While everything worked largely, I run a VPN for work purposes. I solved that largely using WSL VpnKit. This however broke at times. Thereafter further complications resulted from requiring OpenSSL certificates found in Windows that were not in WSL2. So between random crashes, sporadic network failures and configuration pains was a huge loss of time. And for that I ditched Emacs, and moved to VSCode.

Emacs joy

But despite the smooth experience and easy configuration of VsCode, I just couldn’t push past the missing workflow, the keyboard shortcuts and the design. I will take my hat of to the amazing VsCode community, they have even taken some of the best things about Emacs and incorporated it, like Magit and an almost Org Roam or Custom second brain.

So I scratched the itch and found that I could significantly improve performance using MSYS2. While this is based of Cygwin, it first natively compiles and leverages off Cygwin secondarily.


  1. Install MSYS2
  2. Run “MSYS2 Msys”, and install some key compilation requirements:
    pacman -Sy --needed filesystem msys2-runtime bash libreadline libiconv libarchive libgpgme libcurl pacman ncurses libintl
  3. Run the following, and then close and re-open.
    pacman -Su
  4. Install the Emacs dependencies
    pacman -Su autoconf autogen automake automake-wrapper diffutils git guile libgc libguile libltdl libunistring  make mingw-w64-x86_64-binutils mingw-w64-x86_64-bzip2 mingw-w64-x86_64-cairo mingw-w64-x86_64-cloog mingw-w64-x86_64-crt-git mingw-w64-x86_64-dbus mingw-w64-x86_64-expat mingw-w64-x86_64-fontconfig mingw-w64-x86_64-freetype mingw-w64-x86_64-gcc mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-gdk-pixbuf2 mingw-w64-x86_64-gettext mingw-w64-x86_64-giflib mingw-w64-x86_64-glib2 mingw-w64-x86_64-gmp mingw-w64-x86_64-gnutls mingw-w64-x86_64-harfbuzz mingw-w64-x86_64-headers-git mingw-w64-x86_64-imagemagick mingw-w64-x86_64-isl mingw-w64-x86_64-libcroco mingw-w64-x86_64-libffi mingw-w64-x86_64-libgccjit mingw-w64-x86_64-libiconv  mingw-w64-x86_64-libjpeg-turbo mingw-w64-x86_64-libpng mingw-w64-x86_64-librsvg mingw-w64-x86_64-libtiff mingw-w64-x86_64-libwinpthread-git mingw-w64-x86_64-libxml2 mingw-w64-x86_64-mpc mingw-w64-x86_64-mpfr mingw-w64-x86_64-pango mingw-w64-x86_64-pixman mingw-w64-x86_64-winpthreads mingw-w64-x86_64-xpm-nox mingw-w64-x86_64-lcms2 mingw-w64-x86_64-xz mingw-w64-x86_64-zlib tar wget
  5. Clone Emacs
    git clone http://git.savannah.gnu.org/r/emacs.git emacs-29
  6. Git Config requirement
    git config core.autocrlf false
  7. Setup
      cd emacs-29
  8. Configure Configure the features and functionality you may require. With the last argument ‘prefix’, you can define the location for your installation.
     ./configure     --host=x86_64-w64-mingw32     --target=x86_64-w64-mingw32     --build=x86_64-w64-mingw32     --with-native-compilation     --with-gnutls     --with-imagemagick     --with-jpeg     --with-json     --with-png     --with-rsvg     --with-tiff     --with-wide-int     --with-xft     --with-xml2     --with-xpm     'CFLAGS=-I/mingw64/include/noX'     prefix=/c/emacs/
  9. Build and Install
    make install prefix=/c/emacs/


Here on out you should have a successful build. It is from here I then install Doom Emacs. A key step I initially missed was setting an environment variable for the mingw64 libraries and binaries as a Windows environment variable.


After Doom install, I use command prompt or Powershell to start Emacs

doom run

Installation Options Pros and Cons

Type of Install Peformant Native Image paste Broken dependencies Complex setup Networking issues Terminal Stability Host OS Version
Windows Binary Slow Y Y N N N Eshell Very good Windows 28
Msys2 Binary Very fast Y Y Y (no java, dotnet) Y N Eshell Very good Msys2 28
Msys2 Source Very fast Y Y Y (no java, dotnet) Y N Eshell Good Msys2 29
WSL2 Fast N N N Y Y VTerm Good Linux 29