Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reliable loading of custom-file after load #7483

Closed
wants to merge 1 commit into from

Conversation

TheBB
Copy link
Contributor

@TheBB TheBB commented Oct 19, 2016

This lets people use customize to reliably override stuff, even variables that are set in Spacemacs. People who are already modifying the value of custom-file should see no change. People who are relying on customize in their dotfile should probably move them, but the existing forms should continue to work as well as they are now.

Fixes: #5170

Obsoletes quite a few other PRs I expect.

(unless (bound-and-true-p custom-file)
(setq custom-file (dotspacemacs/location)))
(setq custom-file
(concat (or dotspacemacs-directory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use expand-file-name here

@jupl
Copy link
Contributor

jupl commented Oct 19, 2016

Is there going to be any way to avoid custom-set-variables? Every time I updated packages custom-set-variables kept getting written by default to my init.el file which I don't want. I ended up assigning custom-file to a file that gets ignored. With this change I can't see any way of avoiding the auto inclusion of custom-set-variables.

@syl20bnr
Copy link
Owner

syl20bnr commented Oct 19, 2016

I would like to avoid imposing a split by default for people using only the dotfile. People must be able to replicate a Spacemacs config simply by sharing the dotfile. Splitting part of the dotfile by default is a regression.

OTHO I see no problem to use a different file for people using the dotdirectory. We should then restrict the split to only this case.

For the dotfile case, I propose to make the split at runtime with some temp buffer magic. Actually once we have this, we could even avoid to split physically in the dotdirectory.

Also, this way we keep the default Emacs behavior which put customize settings in init.el (which is the dotfile in our case).

@syl20bnr
Copy link
Owner

Mmhh I wonder if we could encapsulate empty customize sexps in a function. Maybe customize will detect them and keep them inside the function...

@syl20bnr
Copy link
Owner

I pushed a solution with commit e699f18
It wraps the custom sexps in a new dotspacemacs function. I took some code from customize to replace the function in the dotfile, I will add some tests later 👊

From the commit message:

Customize cannot write its auto-generated sexps inside a function, to
accomplish this we trick Emacs by setting the custom file to a file
in .cache directory, the path to this file is defined by the variable
spacemacs--custom-file. At the startup of Emacs we read this file
to insert its content inside the function
dotspacemacs/emacs-custom-settings in the dotfile, this is done in the
function spacemacs/write-custom-settings-to-dotfile.

I don't think we need to write the custom settings to the dotfile when
exiting Emacs as well, since we do it at startup at the very beginning
(i.e. before actually loading the dotfile) we should be OK.

@syl20bnr
Copy link
Owner

I think we have now fixed the issue with the custom file so this PR is unnecessary.

@syl20bnr syl20bnr closed this May 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants