Emacs

Emacs is my long time favorite code editor (IDE) and for writing documentation (including this book).

Install Emacs

Because Sway runs on Wayland, you’ll want to install the Wayland (pgtk) version of Emacs. In Fedora 40 onwards, the Wayland (pgtk) version is already the default. For Fedora 39, you can use this COPR (a COPR is to Fedora what PPA is to Ubuntu and what AUR is to Arch Linux), which includes a custom build for Wayland (pgtk).

To enable this, you need to be running your dev toolbox:

[bash]: Run this on your workstation:
toolbox enter dev

Install Emacs:

Run this inside the toolbox:
sudo dnf install emacs

Create Emacs script

In order to be able to quickly launch Emacs inside the toolbox from the host, you will need a little script installed on the host.

You can create this script and put it in /usr/local/bin/emacs. Run this on the host (not in the toolbox), to create it as the root user:

[bash]: Run this on your workstation:
cat << EOF | sudo tee /usr/local/bin/emacs
#!/bin/bash
## Run Emacs in the dev toolbox and pass it any args:
toolbox run -c dev emacs $@
EOF
sudo chmod a+x /usr/local/bin/emacs

Now you can run Emacs from the host, and it will run inside the Toolbox.

Install dependencies

Most Emacs packages are written in Emacs Lisp, and therefore have no external dependencies. The one exception is for Vterm terminal support, which requires compiling a C library (libvterm). This compilation can be done automatically by Emacs, but it requires you have some tools preinstalled:

  • CMake
  • libtool

Install the dependencies inside the toolbox:

run this inside the toolbox
sudo dnf install cmake libtool

Remove any existing Emacs config

Assuming you want to use my Emacs config, you need to delete any existing config you already have. Also note that Emacs creates a default config the first time it runs, so if you started Emacs already, you may have a config and not even know it.

Here’s how to remove the existing Emacs config:

[bash]: Run this on your workstation:
rm ~/.emacs ~/.emacs.d -rf

Install my Emacs config

My Emacs config is on github. Install it with the following script:

[bash]: Run this on your workstation:
REMOTE=https://github.com/EnigmaCurry/emacs.git
REPO=${HOME}/git/vendor/enigmacurry/emacs
BRANCH=straight

(set -e
test -d ~/.emacs.d && (echo "~/.emacs.d already exists. Aborting install." && exit 1)
test -d ${REPO} || git clone -b ${BRANCH} ${REMOTE} ${REPO}
mkdir ~/.emacs.d && ls -1 ${REPO}/*.el | xargs -iXX ln -s XX ~/.emacs.d
mkdir ~/.emacs.d/straight && ln -s ${REPO}/straight-versions ~/.emacs.d/straight/versions
ln -s ${REPO}/snippets ~/.emacs.d/snippets
)

Start Emacs to finish the installation

The first time Emacs starts, it will install all of the dependencies listed in the main config file ~/.emacs.d/init.el.

Run:

[bash]: Run this on your workstation:
emacs

Wait for everything to install. You may see a blank screen for up to 10 minutes, but you should see some minimal information of the progress in the bottom minibuffer.

If it gets stuck at any point, quit and restart it, and it should continue where it left off. If you get any error message, you may want to start Emacs again with debug mode turned on:

[bash]: Run this on your workstation:
emacs --debug-init

This will usually give you a more verbose error message which can be helpful in debugging the startup.

Read the README for my config

More notes are available in the README.