I have seen similar behavior when using load-theme
. I'm not yet sure if this is an Emacs bug.
The behavior I see is as follows:
- Start Emacs, and customize one or more variables for the current session. I've tried this using
customize-set-variable
in my init file, as well as using the Easy Customization interface and Set for Current Session
.
- Load a theme.
- Customize another option and this time
Save for Future Sessions
.
The result of this sequence is that all the options that I intended to be set only for the current session get written out to the custom file. The act of loading a theme somehow marks them to be saved. You can test this by loading your theme before making other customizations.
This strikes me as wrong, though I am not very familiar with the Emacs theme mechanism. I intend to verify this in a clean environment and file an Emacs bug.
Update
OK, I can reproduce this with a clean environment. Since this issue involves saving customizations you cannot test with emacs -Q
(which disables saving changes), so I tested by starting Emacs 24.4 with an empty user home directory.
Then:
M-x customize-variable user-full-name
; set some value; Set for Current Session
.
M-x load-theme deeper-blue
M-x customize-variable user-mail-address
; set some value; Save for Future Sessions
.
This results in a new .emacs
file that includes both user-full-name
and user-mail-address
, even though the name should have only been set for the current session.
Submitted bug #21355.
setq
, or are you usingcustomize-set-value
? Also, how did you save your changes through the Customize interface? Did you change one setting and useSave for Future Sessions
, or something else? – glucas Aug 26 '15 at 18:55setq
andcustom-set-variables
. In Customize, I useC-x C-s
Save all settings in buffer?y
. – incandescentman Aug 26 '15 at 18:57load-theme
? I was just tracking down an issue where customizations made to the current session before loading a theme end up getting saved to my custom-file. – glucas Aug 26 '15 at 19:05setq
andcustomize-set-value
in your init files? I personally prefer to have as much as possible set by customize incustom.el
. – Trebor Rude Aug 26 '15 at 19:33custom-file
-- a separate file from your init file. (Anything else is silly, IMO.) – Drew Aug 26 '15 at 20:03