Subject: bug#15687: 24.3.50; custom themes: disabling does not restore initial configuration

From: Drew Adams <[email-masked]>
Date: Tue, 22 Oct 2013 13:55:03 -0700 (PDT)

Dunno whether this is a bug or a missing feature (enhancement request).

Custom themes were presumably inspired from the color themes of library
`color-theme.el'.  However, I do not see, for custom themes, what is an
important feature of `color-theme.el': the ability to take a snapshot of
the current settings (independent of how they were set, whether via
themes or not) as something that can function as a (pseudo)theme.

Here is a use case.  You tell me whether custom themes offer something
in this regard.

You start out with Emacs in your preferred customized state, a result
perhaps of multiple option settings, frame parameter settings, face
settings, etc.  For example, you have used `default-frame-alist' and
customized some particular faces.  No custom theme (except `user') has
been applied.

You enable a custom theme.  Then you disable it.  The settings remain
those of the "disabled" custom theme.  Your initial state is not
restored.

It seems that disabling a theme is only relative to other custom themes.
Disabling does not undo the effect upon Emacs of enabling (in which case
it is a misnomer).  Enabling not only makes a theme current but also
changes variable values, face settings, frame parameters etc., but none
of that is part of disabling, except in so far as it affects or is
affected by other custom themes.  The ex-theme state of Emacs is ignored
wrt both enabling and disabling.  There is no record of anything to
restore.

A more precise use case: As above, but you cycle among a set of custom
themes.  You want C-g during the cycling to cancel (i.e., undo) all
effects, restoring the initial state because you decided not to use any
theme.  With `color-theme.el' this was trivial to do: just take a
(pseudotheme) snapshot before cycling, and then restore the snapshot
upon C-g.

AFAICT, there is no equivalent of such a snapshot with custom themes,
and it's not clear how to create one.  But please prove me wrong.

In particular, all of the custom-theme code requires a theme argument,
which must be defined fully, including actually having been written to a
theme file.  Hardly something that facilitates dynamic state recording
and reverting.

Please let me know if I'm missing something.  If not already available,
please provide such a useful feature: the ability to record settings as
a (pseudo)theme that is not full-blown, e.g., is not associated with a
theme file etc.

If necessary, it would be OK if the function to create such a snapshot
pseudotheme specified the particular settings to record.  Another
possibility would be to record not the current dynamic Emacs state but
the user's initial state as defined by the `custom-set-variables' and
`custom-set-faces' sexps in `(or custom-file user-init-file)'.

In GNU Emacs 24.3.50.1 (i686-pc-mingw32)
 of 2013-10-19 on LEG570
Bzr revision: 114715 [email-masked]
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --enable-checking 'CFLAGS=-O0 -g3' CPPFLAGS=-DGLYPH_DEBUG=1'