Emacs CVS on Debian

As an avid Emacs user, I like using the CVS version. The emacs-snapshot package in Debian sid isn't as current as I sometimes like it to be, but luckily, it turns out that compiling Emacs yourself can be quite easy, even with using the Debian Emacs infrastructure.

The first thing Emacs needs is a small patch to integrate well with Debian. This patch tells Emacs to initialize the Debian Emacs infrastructure, and declare itself as being the flavor emacs-snapshot. This is the same flavor as the new Debian package, so you can't have both installed at the same time. This is necessary because some Debian packages ignore unknown Emacs flavors, but work well with emacs-snapshot. If you want them both installed at the same time, edit the patch, replacing all occurrences of emacs-snapshot with emacscvs.

I put the compiled Emacs tree into ~/software/emacs/YYYY-MM-DD/ and create a current symlink in the same directory. This allows me to recompile Emacs at will without having to change any other files. From now, I will use the shorthand $EMACSDIR to refer to the full path to the current symlink.

To compile Emacs, you only need three lines. You might want to adjust the --with-* lines to your liking.

./configure \
    --prefix="~/software/emacs/YYYY-MM-DD" \
    --with-xpm --with-jpeg --with-tiff \
    --with-png --with-x
make bootstrap
make install

After this, you can already run the CVS version of Emacs from that directory. To tell Debian about that Emacs, a few more steps are necessary.

Create a symlink from $EMACSDIR/bin/emacs to /usr/bin/emacs-snapshot, and from $EMACSDIR/share/emacs/$VERSION to /usr/share/emacs-snapshot. ($VERSION here is probably 22.0.50 for you, but look in said directory to be sure.) Also create the directories /etc/emacs-snapshot and /etc/emacs-snapshot/site-start.d/.

Now use update-alternatives to install alternatives for the binaries:

update-alternatives \
     --install /usr/bin/emacs emacs \
                 /usr/bin/emacs-snapshot 25
for p in ctags etags emacsclient
do
  update-alternatives \
       --install "/usr/bin/$p" "$p" \
                 "$EMACSDIR/bin/$p" 25
done

After this, you only have to recompile the Debian packages for your new Emacs:

/usr/lib/emacsen-common/emacs-install emacs-snapshot

You won’t have to repeat this process unless Emacs changes the byte code format. Just recompile, change the current symlink appropriately, and repeat the call to emacs-install.