How to start emacs with different configurations

I often come across the following popular emacs builds:

I am currently running custom configuration, but I would like to experiment with these assemblies without compressing my current ~/.emacs.d .

Here are some examples of my current installation:

I installed Emacs via Homebrew, so it is here: /usr/local/Cellar/emacs/HEAD/Emacs.app My current emacs version is: GNU Emacs 24.3.50.1 (i386-apple-darwin13.0.0, NS apple-appkit-1265.00)

Basically, here is what I would like to know:

  • What is the easiest way to switch between these assemblies, as well as my current user configuration?

  • Given the current setup, is it possible to run multiple emacs sessions, each of which has its own configuration / buffers?

+7
source share
3 answers

( Edit: I wrapped this approach in a shell script that I added to EmacsWiki .)

I would be inclined to use the $HOME environment variable:

  • First, copy the โ€œdistributionโ€ (without a better term) into the .emacs.d subdirectory of the directory, which will serve as a replacement for $HOME for this distribution. those. /path/to/(distribution)/.emacs.d :

     $ git clone https://github.com/bbatsov/prelude.git ~/emacs/prelude/.emacs.d $ git clone https://github.com/overtone/emacs-live.git ~/emacs/emacs-live/.emacs.d 
  • You can then start emacs using env to locally set the HOME environment variable for this command:

     $ env HOME=$HOME/emacs/prelude emacs $ env HOME=$HOME/emacs/emacs-live emacs 

They should not interact with each other, so you can run them together and have multiple emacs by-by-side instances, each using a different configuration.

I see that graphene is actually an ELPA package, so it does not have an init.el file and must be installed through the package manager; but you can still use the same method to install it in a separate clean configuration: just create a similar directory structure for others, then create an init.el file (e.g. ~/emacs/graphene/.emacs.d/init.el ), containing the code from the graphene installation instructions, then run emacs (e.g. env HOME=$HOME/emacs/graphene emacs ) and complete the rest of the installation instructions.

Aside from this method, Emacs will not see all your other point files (because it will look like in $HOME ), and therefore starting other processes from Emacs will not necessarily work fine; but this is unlikely to be a big problem if you are just experimenting and you can always reference or copy the bits you need.

You might even prefer it that way: the advantage is that if anything in the distribution you tried writes the files to the home directory, it will not depend on your actual files.

It can also be a useful approach when upgrading Emacs to a new version (if you can run both old and new versions side by side), since you can configure a copy of the existing configuration to use with new Emacs until you make sure everything works and you You can edit a new configuration without the risk of breaking your existing one. Or flip it over and instead save the original configuration in a new / alternative location if you need a backup.

+7
source

You can symbolically refer ~/.emacs.d , this is what I do

1) Try to keep the emacs ~/.emacs.d oriented, that is, all configuration files should live in this folder. For example, I use workgroups2 , by default it saves the workgroup configuration in ~/.emacs_workgroups , but I configured it to store the configuration in ~/.emacs.d/workgroups , so my whole emacs configuration is in the same folder.

2) Then I have a ~/emacs_configs folder where all configuration folders live (basically the init.el folder and the rest of the configuration), so my personal configuration folder will be ~/emacs_configs/iqbal , the foreplay distribution will be in ~/emacs_configs/prelude

3) Then, finally, I symbolically bind ~/.emacs.d to the configuration that I really want to use, for example. to use my configuration I will do ln -s ~/emacs_configs/iqbal .emacs.d . If you want to try some configuration, just copy the configuration folder to ~/emacs_configs/whatever_name and change the symbolic link

Hope this helps

+8
source

I create the file ~/.emacs.1.d/init.el and add the contents to it:

 (setq user-emacs-directory "~/.emacs.1.d/") 

then run emacs like this emacs -q -l ~/.emacs.1.d/init.el , now emacs used the new configuration.

success !!

  • -q means skipping the default configuration ~/.emacs.d/init.el
  • -l means loading a new configuration
0
source

All Articles