Subject: bug#21355: 24.4; Loading a theme causes session customizations to be saved

From: Greg Lucas <[email-masked]>
Date: Wed, 26 Aug 2015 17:04:17 -0400

Loading a theme has the unexpected side of effect of making
customizations in the current session saved to the custom-file the next
time it is updated. 

I reproduced this problem by starting Emacs with an new empty user home
directory (since using -q would prevent saving customizations at all).

Then:

M-x customize-variable sentence-end-double-space -- toggle the value,
and Set for Current Session.
M-x load-theme deeper-blue
M-x customize-variable user-full-name -- set a value and Save for Future
Sessions. 

I would expect only the user-full-name to be saved, but the resulting
.emacs file contains:

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(sentence-end-double-space nil)
 '(user-full-name "Greg Lucas"))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

>From testing this I've found that at the time I call `load-theme` all
customizations made for the current session will get marked to be saved.
Changes made after load-theme behave as expected and do not get saved
unless I explicitly choose to save them.

In GNU Emacs 24.4.1 (i686-pc-mingw32)
 of 2014-10-20 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.3.9600
Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Emacs-Lisp

Minor modes in effect:
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<lwindow> M-x c u s t o m i z e - v a r <tab> <return> 
s h o w - p a <tab> <tab> <tab> <C-backspace> - <backspace> 
<tab> <tab> <C-backspace> <C-backspace> <C-backspace> 
<tab> C-g C-g M-x c u s t - v <tab> a r <tab> <return> 
s e n t e n <tab> <tab> - d <tab> <return> <help-echo> 
<down-mouse-1> <mouse-1> <help-echo> <down-mouse-1> 
<help-echo> <help-echo> M-x l o a d - t h e m e <return> 
d e e <tab> <return> M-x c u s t o m i z e - v <tab> 
<return> s h o w - p a <tab> <C-backspace> <C-backspace> 
<C-backspace> u s e r <tab> f <tab> <return> <down-mouse-1> 
<mouse-1> G r e g SPC L u c a s <help-echo> <help-echo> 
<down-mouse-1> C-x C-f ~ / . e m <tab> <return> M-x 
e m a c s - r e <tab> <C-backspace> <C-backspace> r 
e p o <tab> r <tab> <return>

Recent messages:
Creating customization setup...done
To install your edits, invoke [State] and choose the Set operation
Creating customization items...
Creating customization items ...done
Resetting customization items...done
Creating customization setup...done
(New file)
Saving file c:/temp/emacs-home/.emacs...
Wrote c:/temp/emacs-home/.emacs [2 times]
Making completion list...

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils deeper-blue-theme help-mode help-fns cus-edit
easymenu cus-start cus-load wid-edit cl-loaddefs cl-lib time-date
tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel
dos-w32 ls-lisp w32-common-fns disp-table w32-win w32-vars tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
w32notify w32 multi-tty emacs)

Memory information:
((conses 8 99251 6599)
 (symbols 32 19304 0)
 (miscs 32 270 184)
 (strings 16 15490 4166)
 (string-bytes 1 403422)
 (vectors 8 10810)
 (vector-slots 4 394593 5356)
 (floats 8 68 253)
 (intervals 28 353 19)
 (buffers 508 17))