Setting-up Emacs in Ubuntu

Some notes on getting Emacs up and running in Ubuntu

Using snaps

At snapcraft.io/emacs you can choose an Emacs version to install

Portable installation

A complete IDE for Common Lisp that you can take with you on a USB stick. Multi-platform. portacle.github.io A quick way to get Emacs up and running.

Compiling Emacs yourself

Were you interested in compiling Emacs yourself, you could find helpful hints in some of the following notes.

My target in this case was to compile abd install gnu Emacs (gnu.org/software/emacs) with Doom too (github.com/hlissner/doom-emacs).

  1. Install some dependencies: Less or more dependencies could be installed as needed, according to output of .configure step (see later on in this guide) and your preferences. apt-get install git ripgrep fd-find libxpm-dev libjpeg-dev libgif-dev libtiff-dev gnutls-dev libncurses-dev shellcheck
    and npm install -g marked
    also, to later use --with-mailutils, apt-get install mailutils

  2. Download source code. From gnu.org/software/emacs/download.html#gnu-li.. I get to an official mirror from which I download both .tar.xz and .tar.xz.sig (please download latest version at time of reading): ftp.gnu.org/gnu/emacs/emacs-27.1.tar.xz
    ftp.gnu.org/gnu/emacs/emacs-27.1.tar.xz.sig

  3. Verify source code signatures. Download gnu keyring: wget https://ftp.gnu.org/gnu/gnu-keyring.gpg; place that in the same folder as .tar.xz.sig and .tar.xz. Then verify:

    • gpg --import gnu-keyring.gpg gpg --verify emacs-27.1.tar.xz.sig or

    • You can use this alternatively (without having to use gpg --import gnu-keyring.gpg): gpg --verify --keyring ./gnu-keyring.gpg foo.tar.xz.sig

  4. Extract code tar -xf emacs-27.1.tar.xz. cd inside that extracted folder.

  5. Compile code: ./autogen.sh
    ./configure --with-mailutils --with-json
    make
    sudo checkinstall

    Before applying sudo checkinstall, you can verify that compilation went fine by launching Emacs: src/emacs. You could optionally also check the output of make check.

    In the output of the .configure step, you will see a list of questions and answers related to supported features; an excerpt is present hereafter: [..] Does Emacs use -lXaw3d? no
    Does Emacs use -lXpm? yes
    Does Emacs use -ljpeg? yes
    Does Emacs use -ltiff? yes [..]
    If you want to tweak these supported features, you can apt-get install dependencies and pass optional arguments to the ./configure command. In the configure step I have added --with-json to take advatage of libjansson. Would you want to enable also native compilation, you could check this external post for guidance: masteringemacs.org/article/speed-up-emacs-l..

    Note: if you intend to repeat the configure and make process multiple times (to fine tune available features etc), remember to apply make clean before using make again.

    I am using checkinstall [apt-get install checkinstall, if you do not have it already] to better package the application. Using checkinstall in place of make install grants you an easier, cleaner way to remove the package in case you need so: sudo apt remove packagename, where packagename is the name you assign to the package in the prompt, during installation (ex. it could be "myemacs"). Check more about checkinstall at: help.ubuntu.com/community/CheckInstall

  6. Install Doom (github.com/hlissner/doom-emacs): rm -rf ~/.emacs.d [Attention: this will delete your emacs conf files; ok to do to if it is a fresh install; perform a backup first if you have relevant info there] git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d ~/.emacs.d/bin/doom install doom install will set up your Doom dir at ~/.doom.d (if it doesn’t already exist) and will work you through the first-time setup of Doom Emacs.

    Note: you may move ~/.doom.d inside ~/.conf, if you prefer. Doom will start using that. Do not keep folders in both locations.

    Note: After modifying files inside .doom.d, remember to run doom sync and restart Emacs to see changes enter into effect.

    Note: after doom installation, it is good practice to run doom doctor, to diagnose common issues with your environment and setup.

    Note: Use doom upgrade to update Doom

    Note: Access Doom's documentation from within Emacs via 'SPC h d h' or 'C-h d h' (or 'M-x doom/help')

  7. Add to path It's a good idea to add ~/.emacs.d/bin to your PATH I am adding it in .profile Note: bash as a login shell doesn't parse .profile if either .bash_profile or .bash_login exists.
    export PATH=$PATH:~/.emacs.d/bin
    source .profile [to load that change]
    doom --help should now display the help in the console

  8. Enjoy