Function: faceup-normalize-face-property
faceup-normalize-face-property is a byte-compiled function defined in
faceup.el.gz.
Signature
(faceup-normalize-face-property VALUE)
Documentation
Normalize VALUES into a list of faces and (KEY VALUE) entries.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/faceup.el.gz
;; A face (string or symbol) can be on the top level.
;;
;; A face text property can be a arbitrary deep lisp structure. Each
;; list in the tree structure contains faces (symbols or strings) up
;; to the first keyword, e.g. :foreground, thereafter the list is
;; considered a property list, regardless of the content. A special
;; case are `(foreground-color . COLOR)' and `(background-color
;; . COLOR)', old forms used to represent the foreground and
;; background colors, respectively.
;;
;; Some of this is undocumented, and took some effort to reverse
;; engineer.
(defun faceup-normalize-face-property (value)
"Normalize VALUES into a list of faces and (KEY VALUE) entries."
(cond ((null value)
'())
((symbolp value)
(list value))
((stringp value)
(list (intern value)))
((consp value)
(cond ((eq (car value) 'foreground-color)
(list (list :foreground (cdr value))))
((eq (car value) 'background-color)
(list (list :background (cdr value))))
(t
;; A list
(if (keywordp (car value))
;; Once a keyword has been seen, the rest of the
;; list is treated as a property list, regardless
;; of what it contains.
(let ((res '()))
(while value
(let ((key (pop value))
(val (pop value)))
(when (keywordp key)
(push (list key val) res))))
res)
(append
(faceup-normalize-face-property (car value))
(faceup-normalize-face-property (cdr value)))))))
(t
(error "Unexpected text property %s" value))))