Subject: Re: bug#39649: 27.0.60; tab-line doesn't scroll

From: Juri Linkov <[email-masked]>
Date: Sat, 29 Feb 2020 23:44:56 +0200

> Why would we need that?  The related display code is in C, so we never
> needed to expose this to Lisp.

format-mode-line already exposes it, but fails to properly
handle its arg FACE.

> I also don't understand the relation between this question and the
> recipes you show.

format-mode-line can be used to get the same formatted string
as is displayed on the tab-line.

>> The closest function is format-mode-line but still its formatting is
>> different from what display_mode_element really displays in the
>> tab-line.
>
> Why is that a problem?  format-mode-line was not intended to be used
> in display context.

format-mode-line does the right thing for this task, but its handling
of the arg FACE is broken.

>> 1. emacs -Q
>> 2. M-x global-tab-line-mode
>>
>> 3. C-x b test1
>> 4. M-: (insert (format-mode-line (tab-line-format)))
>> 5. Note how the tab uses the face tab-line-tab
>>    with released-button box style, but the tab-line
>>    doesn't use the face tab-line
>
> I don't see tab-line-tab face, I see either tab-line-tab-inactive or
> tab-line-tab-current.  And the button style and its mouse-sensitive
> behavior follows what I see on the real tab-line.

This is correct, I meant tab-line-tab-inactive and tab-line-tab-current
that inherit from tab-line-tab.

> But maybe I don't understand what you allude to here.  What is the
> "tab" in this context, and what is "tab-line"?  You have one inserted
> into buffer text and one displayed on header-line-like tab-line --
> which one do you allude to here?  And why do you think what is
> displayed is some kind of problem?

"tab-line" visually should have an appearance defined by the face "tab-line",
i.e. grey background that can be seen at whitespace between tabs,
like in the case below.  There is no problem here.  The real problem is below.

>> 6. C-x b test2
>> 7. M-: (insert (format-mode-line (tab-line-format) 'tab-line))
>> 8. Note how the the tab-line now uses the face tab-line,
>>    but this face overrides the faces of individual tabs that
>>    should have the face tab-line-tab with released-button box style.
>
> And here I don't understand what you mean by "overrides".

Do you see the same button styles with the faces tab-line-tab-inactive and
tab-line-tab-current as in the case above like they are on the real tab-line?
These faces are lost when the arg FACE is specified.

>> I can't find a function that would insert to the current buffer
>> a string formatted exactly as the tab-line displayed
>> above the window.
>
> Why is that needed?

Actually, no other function needed.  format-mode-line does it job,
but doesn't handle its arg FACE correctly.

No wonder that handling of its arg FACE is not yet implemented.
I grepped the Emacs source code, and none of format-mode-line
function calls uses the arg FACE.

João said that everything already works, so this is
not a problem for the Emacs 27 release.

But in master format-mode-line could be fixed to implement
better merging of its arg FACE with faces already existing
on strings given in its arg FORMAT.