Figure 1: Emacs WSL

Figure 1: Emacs WSL

For some reason, I needed to work on Windows, and considering my shift is a 12 hours work, I needed something to tinker when I get some quiet time. I just realised it’s been years since I’ve use Windows for something other than web browsing.

So this post is an experience on installing Emacs on Debian.

WSL

You should follow the official documentation on how to install WSL, so I won’t be writing about it here.

As for the reasoning for choosing Debian? Because it’s not Ubuntu, nothing against it, I just wan’t a simpler distro, and I use archlinux, this is WSL, it’s doesn’t make any sense trying to have archlinux inside it.

Updating APT sources

Out of the box, the sources list doesn’t have any of the deb-src and non-free-firmware stuffs.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
deb http://deb.debian.org/debian bookworm main non-free-firmware
deb-src https://deb.debian.org/debian bookworm main non-free-firmware

deb http://deb.debian.org/debian bookworm-updates main non-free-firmware
deb-src https://security.debian.org/debian-security bookworm-security main non-free-firmware

deb http://security.debian.org/debian-security bookworm-security main non-free-firmware
deb-src https://deb.debian.org/debian bookworm-updates main non-free-firmware

deb http://ftp.debian.org/debian bookworm-backports main non-free-firmware
Code Snippet 1: Always check the Debian wiki!

Emacs

After updating apt, run this:

1
sudo apt build-dep emacs

I’m guessing this is for Emacs dependencies. But I still need install other packages via apt:

1
sudo apt install libmagickwand-dev libmagickcore-dev wget curl git

wget and git are for getting the sources.

I also build tree-sitter from source.

1
2
3
4
5
6
mkdir -pv sources
cd ~/source/
git clone https://github.com/tree-sitter/tree-sitter.git
cd tree-sitter
make
sudo make install

or you could also use apt to install it. This is not a hard dependency, so it can be skipped if not used.

As for the Emacs source, I use the tarball, their git repo is just too large. If you want to use their git repo I recommend using the –depth=1 option.

1
2
3
4
cd ~/sources
wget https://ftp.gnu.org/gnu/emacs/emacs-29.4.tar.xz
tar xf emacs-29.4.tar.xz
cd emacs-29.4

So this is my configure options:

1
2
3
./configure --with-native-compilation --with-pgtk --with-tree-sitter --with-modules --with-threads --with-mailutils --with-imagemagick --with-json
make
sudo make install

I suppose you can use other flags, but for now this is more than enough for me.

This will install Emacs using the default prefix (/usr/local), meaning the binary will be placed at /usr/local/bin/. Debian already include them to the shell path.

Others

Running Emacs

I usually just type this in the terminal:

1
setsid emacs

My Emacs packages dependencies

fd-find and ripgrep

1
sudo apt install fd-find ripgrep

cmake

This is for compiling vterm.

1
sudo apt install cmake

all-the-icons

This package have it’s own command for installing icons: all-the-icons-install-fonts, run in inside Emacs using M-x.

nerd-icons

This font collection is not on Debian repository. I just pick some script I got from github, and modified it to store the fonts to ~/.local/share/fonts.

1
sudo apt install unzip

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
fons_list=("Agave" "AnonymousPro" "Arimo" "AurulentSansMono" "BigBlueTerminal" "BitstreamVeraSansMono" "CascadiaCode" "CodeNewRoman" "ComicShannsMono" "Cousine" "DaddyTimeMono" "DejaVuSansMono" "FantasqueSansMono" "FiraCode" "FiraMono" "Gohu" "Go-Mono" "Hack" "Hasklig" "HeavyData" "Hermit" "iA-Writer" "IBMPlexMono" "InconsolataGo" "InconsolataLGC" "Inconsolata" "IosevkaTerm" "Iosevka""JetBrainsMono" "Lekton" "LiberationMono" "Lilex" "Meslo" "Monofur" "Monoid" "Mononoki" "MPlus" "NerdFontsSymbolsOnly" "Noto" "OpenDyslexic" "Overpass" "ProFont" "ProggyClean" "RobotoMono" "ShareTechMono" "SourceCodePro" "SpaceMono" "Terminus" "Tinos" "UbuntuMono" "Ubuntu" "VictorMono")
for font_name in "${fons_list[@]}"; do
    if [ -n "$font_name" ]; then

        echo "Starting download $font_name nerd font"

        if [ "$(command -v curl)" ]; then
            echo "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/$font_name.zip"
            curl -OL "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/$font_name.zip"
            echo "creating fonts folder: ${HOME}/.local/share/fonts"
            mkdir -p  "$HOME/.local/share/fonts"
            echo "unzip the $font_name.zip"
            unzip "$font_name.zip" -d "$HOME/.local/share/fonts/$font_name/"
            fc-cache -fv
            echo "$font_name done!"

        elif [ "$(command -v wget)" ]; then
            echo "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/$font_name.zip"
            wget "https://github.com/ryanoasis/nerd-fonts/releases/latest/download/$font_name.zip"
            echo "creating fonts folder: ${HOME}/.local/share/fonts"
            mkdir -p  "$HOME/.local/share/fonts"
            echo "unzip the $font_name.zip"
            unzip "$font_name.zip" -d "$HOME/.local/share/fonts/$font_name/"
            fc-cache -fv
            echo "done!"

        else
            echo "We cannot find the curl and wget command. First, install the curl and wget command, one of them."
            break
        fi
    fi
done

Please beware this will download automatically all the font in the font_list. And you don’t have to download them all, see all the available fonts at https://www.nerdfonts.com/font-downloads.

Hugo

This is for locally serving my blog.

1
sudo apt install hugo

Spellcheck

1
sudo apt install hunspell wbritish enchant-2 libenchant-2-dev

Password Store

1
sudo apt install pass pass-otp