- (dolist (face (face-list))
- (let ((spec (or (get face 'saved-face)
- (get face 'face-defface-spec))))
- (when spec
- (face-spec-set face spec frame))
- (internal-merge-in-global-face face frame)
- (when (memq window-system '(x w32))
- (make-face-x-resource-internal face frame))))
-
- ;; Initialize attributes from frame parameters.
- (let ((params '((foreground-color default :foreground)
- (background-color default :background)
- (border-color border :background)
- (cursor-color cursor :background)
- (scroll-bar-foreground scroll-bar :foreground)
- (scroll-bar-background scroll-bar :background)
- (mouse-color mouse :background))))
- (while params
- (let ((param-name (nth 0 (car params)))
- (face (nth 1 (car params)))
- (attr (nth 2 (car params)))
- value)
- (when (setq value (frame-parameter frame param-name))
- (set-face-attribute face frame attr value)))
- (setq params (cdr params)))))
+ (unless inhibit-face-set-after-frame-default
+ (if (face-attribute 'default :font t)
+ (set-face-attribute 'default frame :font
+ (face-attribute 'default :font t))
+ (set-face-attribute 'default frame :family
+ (face-attribute 'default :family t))
+ (set-face-attribute 'default frame :height
+ (face-attribute 'default :height t))
+ (set-face-attribute 'default frame :slant
+ (face-attribute 'default :slant t))
+ (set-face-attribute 'default frame :weight
+ (face-attribute 'default :weight t))
+ (set-face-attribute 'default frame :width
+ (face-attribute 'default :width t))))
+ ;; Find attributes that should be initialized from frame parameters.
+ (let ((face-params '((foreground-color default :foreground)
+ (background-color default :background)
+ (border-color border :background)
+ (cursor-color cursor :background)
+ (scroll-bar-foreground scroll-bar :foreground)
+ (scroll-bar-background scroll-bar :background)
+ (mouse-color mouse :background)))
+ apply-params)
+ (dolist (param face-params)
+ (let* ((value (frame-parameter frame (nth 0 param)))
+ (face (nth 1 param))
+ (attr (nth 2 param))
+ (default-value (face-attribute face attr t)))
+ ;; Compile a list of face attributes to set, but don't set
+ ;; them yet. The call to make-face-x-resource-internal,
+ ;; below, can change frame parameters, and the final set of
+ ;; frame parameters should be the ones acquired at this step.
+ (if (eq default-value 'unspecified)
+ ;; The face spec does not specify a new-frame value for
+ ;; this attribute. Check if the existing frame parameter
+ ;; specifies it.
+ (if value
+ (push (list face frame attr value) apply-params))
+ ;; The face spec specifies a value for this attribute, to be
+ ;; applied to the face on all new frames.
+ (push (list face frame attr default-value) apply-params))))
+ ;; Initialize faces from face specs and X resources. The
+ ;; condition-case prevents invalid specs from causing frame
+ ;; creation to fail.
+ (dolist (face (delq 'default (face-list)))
+ (condition-case ()
+ (progn
+ (face-spec-set face (face-user-default-spec face) frame)
+ (if (memq window-system '(x w32 mac))
+ (make-face-x-resource-internal face frame))
+ (internal-merge-in-global-face face frame))
+ (error nil)))
+ ;; Apply the attributes specified by frame parameters. This
+ ;; rewrites parameters changed by make-face-x-resource-internal
+ (dolist (param apply-params)
+ (apply 'set-face-attribute param))))
+
+(defun tty-handle-reverse-video (frame parameters)
+ "Handle the reverse-video frame parameter for terminal frames."
+ (when (cdr (or (assq 'reverse parameters)
+ (assq 'reverse default-frame-alist)))
+ (let* ((params (frame-parameters frame))
+ (bg (cdr (assq 'foreground-color params)))
+ (fg (cdr (assq 'background-color params))))
+ (modify-frame-parameters frame
+ (list (cons 'foreground-color fg)
+ (cons 'background-color bg)))
+ (if (equal bg (cdr (assq 'mouse-color params)))
+ (modify-frame-parameters frame
+ (list (cons 'mouse-color fg))))
+ (if (equal bg (cdr (assq 'cursor-color params)))
+ (modify-frame-parameters frame
+ (list (cons 'cursor-color fg)))))))