plexus / chemacs

Emacs profile switcher
652 stars 45 forks source link

use separate files for early-init.el and init.el #40

Closed emacs18 closed 3 years ago

emacs18 commented 3 years ago

This is yet another attempt which seems to be cleaner in that early-init.el and init.el files use different code so that we don't have to try to deduce between the two within the code.

Most of what was in .emacs is now in chemacs-common.el. early-init.el and init.el simply load this common file and call the main function differently. One sets early-init-p argument to t and the other sets it to nil.

plexus commented 3 years ago

Thanks for your various attempts. I think I like this one, it's easier to follow and I think it's a sensible path forward.

That said there are still some things to be figured out, since now we will be taking over ~/.emacs.d.

Currently when there is no ~/.emacs-profile then chemacs defaults to "default", and if there is no ~/.emacs-profiles.el then it defaults to (("default" . ((user-emacs-directory . "~/.emacs.d")))), this is all to mimic the default behavior of loading ~/.emacs.d, but that will no longer make sense.

I think the right way forward is to enforce having a ~/.emacs-profiles.el, so if it's not found then print a warning and exit.

Something like this:

[chemacs] .emacs-profiles.el not found. Create it with
[chemacs] echo '(("default" . ((user-emacs-directory . "~/my-emacs-config"))))' > ~/.emacs-profiles.el

These are all fairly impactful breaking changes, so I would like to create a plexus/chemacs2 repo where we put this new early-init compatible version, and leave the old chemacs as is for people that don't need early-init and like things the way they are. plexus/chemacs can still receive patches if necessary.

Some related things:

A final thought, how about we use a chemacs-early-init variable to signal if we're being loading from early-init or not, and then simply load the main script? That way you could still put chemacs in ~/.emacs if you wanted to.

plexus commented 3 years ago

For folks following along at home, we are going ahead with the early-init support in a separate repo, https://github.com/plexus/chemacs2/pull/1

This PR has been merged into that repo.