jc_john
jc_john

Reputation: 41

Have two emacs. Want to use spacemacs with one and leave the other intact

I have emacs24 and emacs25 on my machine. I want to use spacemacs with emacs24 and keep emacs25...well...as emacs. When I install spacemacs my ~/.emacs and ~/.emacs.d are changed. Both emacs start using spacemacs, which I do not want. Is there a way to have a spacemacs and an emacs at the same time. Tried looking for a solution and came across a solution to keep separate config files. But how to make emacs look for a specific config file. By the way if you still haven't guessed...I'm a noob.

Upvotes: 1

Views: 895

Answers (4)

Gangula
Gangula

Reputation: 7334

Emacs 29 has a new command-line option, --init-directory [path].

This means you don't need any external packages like chemacs2

Additional Reference:

Upvotes: 1

Mauricio Calvao
Mauricio Calvao

Reputation: 475

The best solution seems to be using chemacs: https://github.com/plexus/chemacs

Upvotes: 0

kuli
kuli

Reputation: 11

you can also use the following approach:

create a directory ~/spacemacs. extract/copy the spacemacs .emacs.d into ~/spacemacs (so that it is ~/spacemacs/.emacs.d). create a desktop link called Spacemacs (or menu entry) and enter the following command:

    HOME=$HOME/spacemacs emacs

You can also start spacemacs from the shell with this command. This way, you can run vanilla emacs and spacemacs simultaneously, each with its own configuration directory and elpa repository. The only disadvantage might be that you need to change a directory level upward to reach your real home directory, not the „fake” one set via the variable. btw, this is how I run several emacs versions and configurations, as needed for diverse stuff.

Upvotes: 1

Tim X
Tim X

Reputation: 4235

At one level, this is quite easy to do. However, at another, there can be some complications, depending on what you really want to do.

Emacs supports a command line switch -l to tell emacs where to find the config file. So, from a very simple perspective, you could just create two wrapper scripts my-spacemacs.sh and my-plainemacs.sh and inside them have the scripts call emacs with a specific -l /path/to/config. You can pass $* to pick up other command line arguments if you want.

The potential problem with this approach is that emacs will still use .emacs.d to store all sorts of other information, including possibly elpa packages and this could cause problems. To be safer, it is better to keep things completely separate.

If you don't need to run both versions at the same time, the easy solution is to have to separate directories, such as ~/.spacemacs-emacs.d and ~/plain-emacs.d and then have a sym link called .emacs.d which points to whichever of the versions you want to run. The two main problems with this approach is that you need to reset the symbolic link whenever you want to change emacs flavors and this won't work if you want to run both versions at the same time.

I guess we really need to know about your actual use case - why do you need two different configurations? Knowing this could help identify a better approach.

As an example, I use org mode and babel to manage my emacs config. I have a number of different versions and a simple script which I can run to generate whichever init.el file I want from the different org files. I have a minimal.org file, which has the most minimal emacs configuration I can bare and I have my standard init.org which generates my working init.el and then I have an experimental.org which is used to generate an init.el file which I use for experimenting with new configurations or packages. It is trivial to switch configurations, but I never need to run two different configurations at the same time.

I often like to check out some of the other pre-cooked emacs setups, like spacemacs, prelude, etc. for these, I just grab the current git version and use a symbolic link to point .emacs.d at the root fo the git repo I want to experiment with.

Upvotes: 1

Related Questions