Function: face-attrs-more-relative-p

face-attrs-more-relative-p is a byte-compiled function defined in face-remap.el.gz.

Signature

(face-attrs-more-relative-p ATTRS1 ATTRS2)

Documentation

Return non-nil if ATTRS1 is "more relative" than ATTRS2.

We define this as meaning that ATTRS1 contains a greater number of relative face-attributes than ATTRS2. A face attribute is considered relative if face-attribute-relative-p returns non-nil.

ATTRS1 and ATTRS2 may be any value suitable for a face text property, including face names, lists of face names, face-attribute plists, etc.

This function can be used as a predicate with sort, to sort face lists so that more specific faces are located near the end.

Source Code

;; Defined in /usr/src/emacs/lisp/face-remap.el.gz
(defun face-attrs-more-relative-p (attrs1 attrs2)
  "Return non-nil if ATTRS1 is \"more relative\" than ATTRS2.
We define this as meaning that ATTRS1 contains a greater number of
relative face-attributes than ATTRS2.  A face attribute is considered
relative if `face-attribute-relative-p' returns non-nil.

ATTRS1 and ATTRS2 may be any value suitable for a `face' text
property, including face names, lists of face names,
face-attribute plists, etc.

This function can be used as a predicate with `sort', to sort
face lists so that more specific faces are located near the end."
  (unless (vectorp attrs1)
    (setq attrs1 (face-attributes-as-vector attrs1)))
  (unless (vectorp attrs2)
    (setq attrs2 (face-attributes-as-vector attrs2)))
  (let ((rel1-count 0) (rel2-count 0))
    (dotimes (i (length attrs1))
      (let ((attr (aref internal-lisp-face-attributes i)))
	(when attr
	  (when (face-attribute-relative-p attr (aref attrs1 i))
	    (setq rel1-count (+ rel1-count 1)))
	  (when (face-attribute-relative-p attr (aref attrs2 i))
	    (setq rel2-count (+ rel2-count 1))))))
    (< rel1-count rel2-count)))