Function: internal-lisp-face-equal-p
internal-lisp-face-equal-p is a function defined in xfaces.c.
Signature
(internal-lisp-face-equal-p FACE1 FACE2 &optional FRAME INHERIT)
Documentation
True if FACE1 and FACE2 are equal.
If the optional argument FRAME is given, report on FACE1 and FACE2 in that frame. If FRAME is t, report on the defaults for FACE1 and FACE2 (for new frames). If FRAME is omitted or nil, use the selected frame. Optional fourth argument INHERIT, if non-nil, means the faces are considered equal if one inherits from the other in a way that makes them have the same attributes when used on display.
Source Code
// Defined in /usr/src/emacs/src/xfaces.c
{
bool equal_p;
struct frame *f;
Lisp_Object lface1, lface2;
/* Don't use decode_window_system_frame here because this function
is called before X frames exist. At that time, if FRAME is nil,
selected_frame will be used which is the frame dumped with
Emacs. That frame is not an X frame. */
f = EQ (frame, Qt) ? NULL : decode_live_frame (frame);
lface1 = lface_from_face_name (f, face1, true);
lface2 = lface_from_face_name (f, face2, true);
equal_p = lface_equal_p (XVECTOR (lface1)->contents,
XVECTOR (lface2)->contents);
if (!(NILP (inherit) || equal_p))
{
/* The below is a subset of merging the descendant face with its
parent(s). We only consider a direct inheritance (so no FACE1
that inherits from some other face which inherits from FACE2),
and the values of :inherit that are lists are not considered.
This is enough in simple cases such as the line-number-current
face that inherits from line-number. */
Lisp_Object attrs1[LFACE_VECTOR_SIZE], attrs2[LFACE_VECTOR_SIZE];
int i;
equal_p = true;
memcpy (attrs1, xvector_contents (lface1), sizeof attrs1);
memcpy (attrs2, xvector_contents (lface2), sizeof attrs2);
/* If either face inherits from the other one, and all the other
face attributes of the inheriting face are either unspecified
or equal to those of the parent face, consider the faces equal. */
if (EQ (attrs1[LFACE_INHERIT_INDEX], face2))
{
for (i = 1; i < LFACE_VECTOR_SIZE && equal_p; ++i)
{
if (i == LFACE_INHERIT_INDEX)
continue;
equal_p = face_attr_equal_p (attrs1[i], attrs2[i])
|| UNSPECIFIEDP (attrs1[i]);
}
}
else if (EQ (attrs2[LFACE_INHERIT_INDEX], face1))
{
for (i = 1; i < LFACE_VECTOR_SIZE && equal_p; ++i)
{
if (i == LFACE_INHERIT_INDEX)
continue;
equal_p = face_attr_equal_p (attrs1[i], attrs2[i])
|| UNSPECIFIEDP (attrs2[i]);
}
}
}
return equal_p ? Qt : Qnil;
}