Subject: Re: bug#7587: 23.2; `format-mode-line' makes Emacs crash

From: Eli Zaretskii <[email-masked]>
Date: Thu, 16 Dec 2010 00:35:51 -0500

> From: Chong Yidong <[email-masked]>
> Cc: Stefan Monnier <[email-masked]>, Miles Bader <[email-masked]>,
>         [email-masked], [email-masked]
> Date: Thu, 16 Dec 2010 10:17:51 +0800
> 
> format-mode-line should not pass non-basic faces to init_iterator.

Where do you see this condition enforced or assumed in the code?  I
see only the commentary before init_iterator, but I'm not sure which
code (except lookup_basic_face) would really puke or DTWT with a
non-basic face.  And support for face remapping already means that you
can sneak a non-basic face in, anyway.

> I'm not even sure what the FACE argument to format-mode-line is
> useful for

The doc string and the ELisp manual clearly answer that question:
format-mode-line can be used to compute the formatted string without
displaying it.  When you use this API that way, you can specify a face
for the parts of mode line that don't have their faces specified in
the mode-line format.  IOW, it sounds like a deliberate feature, given
the description in the ELisp manual.

> it doesn't seem to be used anywhere in the sources.

?? init_iterator uses it (well, its index in the face cache) to
initialize the appropriate member of the iterator object.

> I've changed format-mode-line so that if you pass a face argument to
> FACES, it should be one of `default', `mode-line', etc.  Any other face
> gets treated as `default'.

Given some history of discussions here, and the fact that no one seems
to be sure how this code should really work and why, I wonder why you
went ahead with the change without discussing it first.  I'm afraid
that this change breaks backward compatibility for no good reason.

Anyway, this being an incompatible change, it should be in NEWS.  In
addition, the ELisp manual should be modified accordingly.

Also, there seems to be a bug in the change itself, in this line:

  +    : EQ (face, Qmode_line_inactive) ? MODE_LINE_FACE_ID