💾 Archived View for alltext.umaneti.net › gemlog › Use-Emacs-with-different-profiles.gmi captured on 2024-07-08 at 23:25:32. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
As you may know, I’m maintaining different little packages for Gnu Emacs[1]:
When it comes to testing with various configuration environment, Emacs is not very flexible. The main idea is to be able to test completely different user settings, without polluting my own preferences.
I know about Chemacs[9], but I was looking for a more simple solution, for example to embed it easily in a Makefile.
The first path I follow was to prevent Emacs to load my init file. This is clearly documented in its man page, and as easy as doing:
emacs -Q -l custom_profile.el <file_to_open>
The `-Q' here means "Similar to '-q --no-site-file --no-splash'". `-q', in turn, means "Do not load an init file". Said otherwise, with this lone parameter, we load nothing and prevent Emacs to follow its traditional startup process.
Then, `-l' is used to load a specific lisp file, which can be seen as a profile replacement.
For most of my tests, it did the trick and I was happy with that. However, as Emacs does not really start as expected, a lot of thing may not work as we are used to. Packaging, or `customize' for example. And if you forgot to deactivate some features, you will still be polluting your own settings (yes, I’m looking at you `auto-save-list').
And I finally found an answer on StackOverflow[10] to literally /chroot/ Emacs in a fake home environment. It is a bit weird to write, but it does the job:
HOME=/path/to/my/fakehome emacs <file_to_open>
All we have to do to make it works as expected, is to put our new settings file inside this fake home directory. Meaning either to put there a `.emacs' file, or a `.emacs.d/init.el' file, or a `.config/emacs/init.el' one.
And now, as Emacs will start as usually, we benefit from all its features, and it even lets us easily install new packages without breaking anything on our own profile.
To conclude, both methods are valid, but they answer different use-cases:
Make your choice 😀
[3] flycheck-grammalecte (HTTPS)
[10] an answer on StackOverflow (HTTPS)
--
📅 mardi 6 juillet 2021 à 19:55
📝 Étienne Deparis with GNU/Emacs 29.4 (Org mode 9.7.6)