Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
6 removed fluff from title
source | link

I want to use Use several emacsEmacs configurations/versions simultaneously…simultaneously

…soI want to use several emacs configurations/versions simultaneously so that no configuration disturbs each other, each with their own configuration directory and elpa repository. I heard about the trick with symlinking ~/.emacs.d and ~/.emacs, but that is not what I want, because it'd be best if I can run my default emacs installation and simultaneously a testing installation (new emacs releases) or another setup like Spacemacs or Prelude.

Is there any decent way to do this?

I want to use several emacs configurations/versions simultaneously…

…so that no configuration disturbs each other, each with their own configuration directory and elpa repository. I heard about the trick with symlinking ~/.emacs.d and ~/.emacs, but that is not what I want, because it'd be best if I can run my default emacs installation and simultaneously a testing installation (new emacs releases) or another setup like Spacemacs or Prelude.

Is there any decent way to do this?

Use several Emacs configurations/versions simultaneously

I want to use several emacs configurations/versions simultaneously so that no configuration disturbs each other, each with their own configuration directory and elpa repository. I heard about the trick with symlinking ~/.emacs.d and ~/.emacs, but that is not what I want, because it'd be best if I can run my default emacs installation and simultaneously a testing installation (new emacs releases) or another setup like Spacemacs or Prelude.

Is there any decent way to do this?

5 edited tags
| link
4 followed the suggestion to structure as question and answer, not indirect code posting.
source | link

…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 beingconfiguration disturbs each other, in its place imagine a desktopeach with spacemacs, doom emacs and pure GNU Emacs running at the same time.)

The script resides in ~/bin and assumes that <name-of-config>their own configuration directory 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 .emacselpa repository.d inside the <name-of-config> directory since the latter is used as a fake home directory, so that I heard about the actualtrick with symlinking ~/.emacs.d and ~/.emacs do, but that is not get touchedwhat I want, because it'd be best if I can run my default emacs installation and simultaneously a testing installation (new emacs releases) or another setup like Spacemacs or Prelude.

If you think this is useful or suits your needs, feel freeIs there any decent way to use it.do this?


#!/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

…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

…so that no configuration disturbs each other, each with their own configuration directory and elpa repository. I heard about the trick with symlinking ~/.emacs.d and ~/.emacs, but that is not what I want, because it'd be best if I can run my default emacs installation and simultaneously a testing installation (new emacs releases) or another setup like Spacemacs or Prelude.

Is there any decent way to do this?

3 no image, but the text explaining it
source | link
2 forgot to explain the fs structure the script expects
source | link
1
source | link