Setting up (doom) emacs on a new machine
Disclaimer: Everything I write comes from those tiny funny neurons firing in my own brain. Nobody (especially my employer) told me what to write in this article.
A quick note on how I install (doom) emacs on a new computer. For a guide on how to use Doom once it's installed, see my doom-emacs-handbook article instead.
Prelude
First of all: I build emacs from source. The reason for that is that your distro might package a version that is too old. For example, on PopOS/Ubuntu the last version packaged (last time I checked) was Emacs 27.1. Ew.
The other reason is that I can specify the compile flags that I want, and there's quite a few one on emacs.
I have been using Linux for long enough that building from source doesn't scare me as much as when I started, but I'm putting my install script here on the web in case it helps somebody at the beginning of their Linux journey.
Step 1
Download the source code.
For example, provided you have git
installed, one quick way would be:
cd ~/some/path/that/you/like
git clone https://git.savannah.gnu.org/git/emacs.git
Step 2
To compile emacs, I use this script:
#!/usr/bin/env sh
set -e
# You should update this variable to your liking!
PREFIX="$HOME/dev/emacs-install-dir"
mkdir -p "$PREFIX"
echo "Running autogen.."
./autogen.sh
echo "Running configure.."
./configure --enable-checking='yes,glyphs' \
--enable-check-lisp-object-type \
--prefix "$PREFIX" \
--with-native-compilation \
--with-json \
--with-pgtk
echo "Running make.."
make -j "$(nproc)"
echo "Installing to $PREFIX .."
make install
Step 3
Et voilá.
Now I just need to add this custom emacs to my path and I'm done!
A quick way to achieve this would be to add something like this to your ~/.bashrc
:
if [ $(echo "$PATH" | grep -c "$HOME/dev/emacs-install-dir") == 0 ]; then
export PATH=""$HOME/dev/emacs-install-dir/bin/:$PATH"
fi