Function: face-spec-recalc

face-spec-recalc is a byte-compiled function defined in faces.el.gz.

Signature

(face-spec-recalc FACE FRAME)

Documentation

Reset the face attributes of FACE on FRAME according to its specs.

The following sources are applied in this order:

  face reset to default values if it's the default face, otherwise set
  to unspecified (through face-spec-reset-face)
   |
  (theme and user customization)
    or: if none of the above exist, and none match the current frame or
        inherited from the defface spec instead of overwriting it
        entirely, the following is applied instead:
  (defface default spec)
  (X resources (if applicable))
   |
  defface override spec

Source Code

;; Defined in /usr/src/emacs/lisp/faces.el.gz
(defun face-spec-recalc (face frame)
  "Reset the face attributes of FACE on FRAME according to its specs.
The following sources are applied in this order:

  face reset to default values if it's the default face, otherwise set
  to unspecified (through `face-spec-reset-face')
   |
  (theme and user customization)
    or: if none of the above exist, and none match the current frame or
        inherited from the defface spec instead of overwriting it
        entirely, the following is applied instead:
  (defface default spec)
  (X resources (if applicable))
   |
  defface override spec"
  (while (get face 'face-alias)
    (setq face (get face 'face-alias)))
  (face-spec-reset-face face frame)
  ;; If FACE is customized or themed, set the custom spec from
  ;; `theme-face' records.
  (let ((theme-faces (get face 'theme-face))
	(no-match-found 0)
        default-attrs face-attrs theme-face-applied)
    (if theme-faces
	(dolist (elt (reverse theme-faces))
	  (setq face-attrs (face-spec-choose (cadr elt) frame no-match-found))
	  (unless (eq face-attrs no-match-found)
	    (face-spec-set-2 face frame face-attrs)
	    (setq theme-face-applied t))))
    ;; If there was a spec applicable to FRAME, that overrides the
    ;; defface spec entirely rather than inheriting from it, with the
    ;; exception of the :extend attribute (which is inherited).
    ;;
    ;; If there was no spec applicable to FRAME, apply the defface
    ;; spec as well as any applicable X resources.
    (setq default-attrs (face-spec-choose (face-default-spec face) frame))
    (unless theme-face-applied
      (face-spec-set-2 face frame default-attrs)
      (make-face-x-resource-internal face frame))
    (when (and theme-face-applied
               (eq 'unspecified (face-attribute face :extend frame t)))
      (let ((tail (plist-member default-attrs :extend)))
        (and tail (face-spec-set-2 face frame
                                   (list :extend (cadr tail))))))
    (setq face-attrs (face-spec-choose (get face 'face-override-spec) frame))
    (face-spec-set-2 face frame face-attrs)))