3 of 6 no image, but the text explaining it

I want to use several emacs configurations/versions simultaneously…

…so I came up with the following script, which assumes that alternate configurations are stored in ~/alternate-emacsen/<name-of-config>. I use this eg. to test emacs26 pre-release while working with a plain emacs25 and being able to use spacemacs, doom emacs or any variant configuration whenever I want to.

(I wanted to insert an image here, but I have no account on hosting sites, so for the time being, in its place imagine a desktop with spacemacs, doom emacs and pure GNU Emacs running at the same time.)

The script resides in ~/bin and assumes that <name-of-config> and the name of the softlink which calls it are identical; eg. if you want to launch the config stored in ~/alternate-emacsen/deepin-emacs you need a softlink ~/bin/deepin-emacs.

Be sure to put .emacs.d inside the <name-of-config> directory since the latter is used as a fake home directory, so that the actual ~/.emacs.d and ~/.emacs do not get touched.

If you think this is useful or suits your needs, feel free to use it.

#!/bin/bash

# alternate-emacsen ––  A bash  script to launch  Emacs in  completely different
#                      configurations,   like   GNU   default,   Deepin   Emacs,
#                      Spacemacs, CL  server,… from  their own  config directory
#                      trees.
# Usage:
# – create  a  directory  $HOME/alternate-emacsen/,  containing  an
#   .emacs.d with all the base configuration  inside it.  Put the init file into
#    if necessary.
# – create a link  to this script, eg.
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/emacs-unstable
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/spacemacs
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/doom-emacs
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/deepin-emacs
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/prelude-emacs
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/emacsstarterkit
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/exwm
#           ln -s $HOME/bin/alternate-emacsen,sh $HOME/bin/clemacsd
# – set  $emacsbin  to   the  emacs  version  you  prefer/use.  or   set  it  to
#   /usr/bin/emacs  for  the  system's  default.   I  use  emacs-25.2  with  the
#   Athena/Lucid X widget set  as my default GUI (not GTK because  I do not like
#   it for several reasons), so it is set as default.
# – edit the  emacs2x entries to reflect  your preferences like in  the previous
#   step.

self="emacs config launcher";
emacsconfig=`basename $0`;
userhome=$HOME;
HOME=$HOME/alternate-emacsen/$emacsconfig;

test -d "$HOME" || { \
             echo "$self: ERROR –– $HOME does not exist!";
             exit 1;
};

# On my system, Emacs 23.2/GTK2 (in /usr/bin) is the default, but I prefer Emacs
# 25  with pure  X11  Lucid interface.   Also, the  system  default uses  partly
# incompatible ELisp packages (both to Emacs 23  and Emacs 25), so I ignore them
# by not using /usr/share/* at all (the  other Emacsen are compiled to reside in
# /usr/local and thus ignore the outer /usr tree).
emacsbin=/usr/local/bin/emacs-25.2-lucid;
sysdefaultemacs=/usr/bin/emacs;
emacs23=$sysdefaultemacs;
emacs24=/usr/local/bin/emacs-24.4-lucid;
emacs25=/usr/local/bin/emacs-25.2-lucid;
emacs26=/usr/local/bin/emacs-26;
emacstesting=$emacs26;

case $emacsconfig in
    spacemacs|deepin-emacs|clemacs|doom-emacs|prelude-emacs|emacsstarterkit)
    emacsbin=${emacs25};
    ;;
    exwm)
    emacsbin=${emacs24};
    ;;
    emacs-testing|emacs-unstable)
    emacsbin=${emacstesting};
    ;;
    *)
        HOME=$userhome;
        ;; # use emacsbin as defined in the settings
esac

export HOME;
unset userhome;
cd $HOME;
if test -e "$emacsbin"; then
    $emacsbin $@
else echo "$self: ERROR –– not found: $emacsbin";
fi