3

I want to use Emacs for programming in Clojure, Mathematica and for taking notes in class. I am using the Emacs configuration provided by "Clojure for the Brave and Bold", which pretty heavily customizes Emacs for Clojure. I would like to have a different environment for Mathematica, and a vanilla environment for note taking?

How can I keep multiple profiles for Emacs?

6
  • Why not one "profile" that does all of the above?
    – PythonNut
    Commented Sep 22, 2015 at 22:14
  • 6
    The environment in Emacs changes with the current activated modes. There is no need for a special setup as far as I understand you question. Every language has it's own profile so to speak, which is determined by the modes you set up for it.
    – clemera
    Commented Sep 22, 2015 at 22:17
  • How would this profile differ from what you currently have? Clojure for the Brave and True sets up Emacs to do things like "when you open a Clojure file, use this mode", or "you can tell Emacs to open a Cider REPL". If you don't open a Clojure file, for example, you can do notetaking in other modes. What specific things do you want to differ?
    – zck
    Commented Sep 22, 2015 at 22:19
  • 1
    You can handle diffent kinds of keybindings according to mode (for editing with clojure, mathematica, etc.), and can customize them with mode hooks. May I suggest that you have a look at the built-in tutorial (with the keybinding C-h t) and browse around for a few more tutorials on customizing your work environment?
    – Dan
    Commented Sep 22, 2015 at 22:21
  • 1
    The general appearance changes with the theme you choose. You can use M-x load-theme to choose one of the installed ones. I wouldn't recommend to change the theme based on the mode but you can do that, too.
    – clemera
    Commented Sep 23, 2015 at 20:08

3 Answers 3

8

How can I keep multiple profiles for Emacs?

In a single init file. As others have suggested in the comments above, this is easily done in emacs without having multiple profiles.

A single init file can keep the settings for multiple modes. Based on your question, those modes would be Clojure, Mathematica, and Text modes, and perhaps others in future. Depending on which file is currently being edited/active, those settings, configurations, keyboard shortcuts, etc., become active. In emacs terminology, grouping such behaviors is called modes, of which there are major and minor kinds.

The effect of this flexibility is that you don't have to restart emacs with different profiles. Nor do you have to run multiple emacs instances. This common misunderstanding comes from other editors, but not emacs. In emacs you switch from a clojure buffer, a mathematica buffer, and a text file without restarting.

You don't have to go into intricacies of modes to just start using them to great benefit. The easiest approach is to load pre-prepared init files that contain those modes. One place to start is the emacs starter kit. It comes with many modes ready for use and has an easy approach to customization for new emacs users.

2
  • I guess to clarify, the book I am using comes with a preloaded set of Init files, which seems to make global changes to Emacs. I would like Emacs to only use this init file when I am working on Clojure projects, and use a different set of init files if I am working with Mathematica or for class notes
    – Arnob
    Commented Sep 23, 2015 at 16:06
  • 1
    No need for "use a different set of init files" in emacs. One init file can handle Mathematica or class notes or any number of other programming tasks.
    – Emacs User
    Commented Sep 23, 2015 at 16:10
2

You could use as many "configurations" as you would like by wrapping your emacs commad to a script that would use different emacs directories (say .emacs.d.clojure .emacs.d.mathematica and .emacs.d.notes) Assuming you are using a Unix type system your emacs incantation would be something like

emacs -Q -l .emacs.d.clojure/init.el

Another alternative is to use the user option from emacs command line.

I have to emphasize that this is not reccommended and very likely to fall in undefined behaviors. As others have pointed out you really should try to reconcile the settings for the different modes you want. Remember that emacs is all about flexibility to the user.

Since you mentioned in your original post you are using an emacs configuration recommende by the book "Clojure for the Brave and True", which is in the following git repository

https://github.com/flyingmachine/emacs-for-clojure

I skimmed through the code and most if not all the modifications are pretty standard and you should benefit from them on all editing modes.

Please consider merging your configurations and use a single emacs instance

2

If you really want to use more than one full emacs configuration at the same time and not only some major mode configurations, then you can use the configuration that I have described here: https://emacs.stackexchange.com/a/20508/934

With this .emacs-file you can start emacs with a configuration directory:

EMACS_USER_DIRECTORY=~/your/emacs.d emacs

This even works as a daemon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.