Up to this point, I used to have a separate configuration for each major mode, e.g.
init.c++.el etc. I would invoke
Emacs using an one of the aliases like these:
alias emacs-org='emacs -q --load ~/.emacs.d/init.org.el' alias emacs-cpp='emacs -q --load ~/.emacs.d/init.c++.el'
At last, I got tired of having to run a different emacs instance every time I need to work with a different major mode, so I would like to unify my configuration.
I am thinking that the easiest way to do this is to put into
init.el a hook for each major mode to load the corresponding configuration. So,
init.el would have lines of the form:
(add-hook 'org-mode-hook (load-file "init.org.el)) (add-hook 'c++-mode-hook (load-file "init.c++.el))
I like this approach for the minimal number of changes that it requires. Also, having a hook in
init.el, spares me from the need to put a lot of hooks in the files of individual modes.
However, there seems to be a problem. Namely, once say
init.c++.el is loaded, all the configuration changes it performed will remain even when I switch to another mode... Is this correct? Is it possible solve this problem? And, more generally, is this approach to organizing configuration sound?