+Any theme `foo' should be defined in a file called `foo-theme.el';
+see `custom-make-theme-feature' for more information."
+ (let ((feature (custom-make-theme-feature theme)))
+ ;; It is better not to use backquote in this file,
+ ;; because that makes a bootstrapping problem
+ ;; if you need to recompile all the Lisp files using interpreted code.
+ (nconc (list 'custom-declare-theme
+ (list 'quote theme)
+ (list 'quote feature)
+ doc)
+ args)))
+
+(defun custom-declare-theme (theme feature &optional doc &rest args)
+ "Like `deftheme', but THEME is evaluated as a normal argument.
+FEATURE is the feature this theme provides. This symbol is created
+from THEME by `custom-make-theme-feature'."
+ (add-to-list 'custom-known-themes theme)
+ (put theme 'theme-feature feature)
+ (when doc
+ (put theme 'theme-documentation doc))
+ (while args
+ (let ((arg (car args)))
+ (setq args (cdr args))
+ (unless (symbolp arg)
+ (error "Junk in args %S" args))
+ (let ((keyword arg)
+ (value (car args)))
+ (unless args
+ (error "Keyword %s is missing an argument" keyword))
+ (setq args (cdr args))
+ (cond ((eq keyword :short-description)
+ (put theme 'theme-short-description value))
+ ((eq keyword :immediate)
+ (put theme 'theme-immediate value))
+ ((eq keyword :variable-set-string)
+ (put theme 'theme-variable-set-string value))
+ ((eq keyword :variable-reset-string)
+ (put theme 'theme-variable-reset-string value))
+ ((eq keyword :face-set-string)
+ (put theme 'theme-face-set-string value))
+ ((eq keyword :face-reset-string)
+ (put theme 'theme-face-reset-string value)))))))
+
+(defun custom-make-theme-feature (theme)
+ "Given a symbol THEME, create a new symbol by appending \"-theme\".
+Store this symbol in the `theme-feature' property of THEME.
+Calling `provide-theme' to provide THEME actually puts `THEME-theme'
+into `features'.
+
+This allows for a file-name convention for autoloading themes:
+Every theme X has a property `provide-theme' whose value is \"X-theme\".
+\(require-theme X) then attempts to load the file `X-theme.el'."
+ (intern (concat (symbol-name theme) "-theme")))
+\f
+;;; Loading themes.
+
+;; The variable and face settings of a theme are recorded in
+;; the `theme-settings' property of the theme name.
+;; This property's value is a list of elements, each of the form
+;; (PROP SYMBOL THEME MODE VALUE), where PROP is `theme-value' or `theme-face'
+;; and SYMBOL is the face or variable name.
+;; THEME is the theme name itself; that's redundant, but simplifies things.
+;; MODE is `set' or `reset'.
+;; If MODE is `set', then VALUE is an expression that specifies the
+;; theme's setting for SYMBOL.
+;; If MODE is `reset', then VALUE is another theme,
+;; and it means to use the value from that theme.
+
+;; Each variable has a `theme-value' property that describes all the
+;; settings of enabled themes that apply to it.
+;; Each face name has a `theme-face' property that describes all the
+;; settings of enabled themes that apply to it.
+;; The property value is a list of settings, each with the form
+;; (THEME MODE VALUE). THEME, MODE and VALUE are as above.
+;; Each of these lists is ordered by decreasing theme precedence.
+;; Thus, the first element is always the one that is in effect.
+
+;; Disabling a theme removes its settings from the `theme-value' and
+;; `theme-face' properties, but the theme's own `theme-settings'
+;; property remains unchanged.
+
+;; Loading a theme implicitly enables it. Enabling a theme adds its
+;; settings to the symbols' `theme-value' and `theme-face' properties,
+;; or moves them to the front of those lists if they're already present.