-See `defface' for the format of SPEC."
- (while args
- (let ((entry (car args)))
- (if (listp entry)
- (let ((face (nth 0 entry))
- (spec (nth 1 entry))
- (now (nth 2 entry)))
- (put face 'saved-face spec)
- (when now
- (put face 'force-face t))
- (when (or now (facep face))
- (make-empty-face face)
- (face-spec-set face spec))
+(defun custom-theme-set-faces (theme &rest args)
+ "Initialize faces for theme THEME.
+The arguments should be a list where each entry has the form:
+
+ (FACE SPEC [NOW [COMMENT]])
+
+SPEC is stored as the saved value for FACE, as well as the value for the
+`user' theme. The `user' theme is one of the default themes known to Emacs.
+See `custom-known-themes' for more information on the known themes.
+See `custom-theme-set-faces' for more information on the interplay
+between themes and faces.
+See `defface' for the format of SPEC.
+
+If NOW is present and non-nil, FACE is created now, according to SPEC.
+COMMENT is a string comment about FACE.
+
+Several properties of THEME and FACE are used in the process:
+
+If THEME property `theme-immediate' is non-nil, this is equivalent of
+providing the NOW argument to all faces in the argument list: FACE is
+created now. The only difference is FACE property `force-face': if NOW
+is non-nil, FACE property `force-face' is set to the symbol `rogue', else
+if THEME property `theme-immediate' is non-nil, FACE property `force-face'
+is set to the symbol `immediate'.
+
+SPEC itself is saved in FACE property `saved-face' and it is stored in
+FACE's list property `theme-face' \(using `custom-push-theme')."
+ (custom-check-theme theme)
+ (let ((immediate (get theme 'theme-immediate)))
+ (while args
+ (let ((entry (car args)))
+ (if (listp entry)
+ (let ((face (nth 0 entry))
+ (spec (nth 1 entry))
+ (now (nth 2 entry))
+ (comment (nth 3 entry)))
+ (put face 'saved-face spec)
+ (put face 'saved-face-comment comment)
+ (custom-push-theme 'theme-face face theme 'set spec)
+ (when (or now immediate)
+ (put face 'force-face (if now 'rogue 'immediate)))
+ (when (or now immediate (facep face))
+ (unless (facep face)
+ (make-empty-face face))
+ (put face 'face-comment comment)
+ (face-spec-set face spec))