Function: face-spec-choose
face-spec-choose is a byte-compiled function defined in faces.el.gz.
Signature
(face-spec-choose SPEC &optional FRAME NO-MATCH-RETVAL)
Documentation
Return the proper attributes for FRAME, out of SPEC.
Value is a plist of face attributes in the form of attribute-value pairs. If no match is found or SPEC is nil, return nil, unless NO-MATCH-RETVAL is given, in which case return its value instead.
Source Code
;; Defined in /usr/src/emacs/lisp/faces.el.gz
(defun face-spec-choose (spec &optional frame no-match-retval)
"Return the proper attributes for FRAME, out of SPEC.
Value is a plist of face attributes in the form of attribute-value pairs.
If no match is found or SPEC is nil, return nil, unless NO-MATCH-RETVAL
is given, in which case return its value instead."
(unless frame
(setq frame (selected-frame)))
(let ((tail spec)
result defaults match-found)
(while tail
(let* ((entry (pop tail))
(display (car entry))
(attrs (cdr entry))
thisval)
;; Get the attributes as actually specified by this alternative.
(setq thisval
(if (null (cdr attrs)) ;; was (listp (car attrs))
;; Old-style entry, the attribute list is the
;; first element.
(car attrs)
attrs))
;; If the condition is `default', that sets the default
;; for following conditions.
(if (eq display 'default)
(setq defaults thisval)
;; Otherwise, if it matches, use it.
(when (face-spec-set-match-display display frame)
(setq result thisval
tail nil
match-found t)))))
;; If defaults have been found, it's safe to just append those to the result
;; list (which at this point will be either nil or contain actual specs) and
;; return it to the caller. Since there will most definitely be something to
;; return in this case, there's no need to know/check if a match was found.
(if defaults
(append defaults result)
(if match-found
result
no-match-retval))))