Subject: bug#41852: 27.0.50; text-scale commands don't scale header of tabulated-list-mode

From: martin rudalics <[email-masked]>
Date: Fri, 30 Oct 2020 18:37:35 +0100

> Could you be more specific?  It already says it's buffer local, but it
 > seems like you think it should say something more?

IIUC one cannot "set" a face buffer-locally.  One has to emulate that
via face remapping.

 > Do you mean to be very explicit about it, like this?
 >
 >    When the new buffer local variable 'text-scale-remap-header-line-face'
 >    is non-nil, 'text-scale-adjust' will also change the font size of the
 >    'header-line' face in the current buffer.

I'd say "will also scale the text in the mode line when displaying that
buffer".

 >  This will also affect any
 >    face that inherits from it.

But if I assign the header line face or some face inheriting from it to
some buffer text (not that I recommend doing that), that text will be
scaled regardless of the value of 'text-scale-remap-header-line-face'.
Right?

 >> (2) that text in the header line or elsewhere in such a buffer not
 >> inheriting from (the remapped) header line face is unaffected, and
 >
 > I'm not sure I understand what you mean.  If text-scale-mode is enabled,
 > typically through running e.g. `text-scale-increase', the `default' face
 > is scaled.

Here too I would say something like "the buffer text is scaled".  The
default face itself is not scaled by face remapping.  The remapping is
applied by the display engine whenever the buffer is displayed after all
faces have been merged.  But maybe that is clear to everyone and you
should simply ignore what I wrote.

 > The result, AFAICT, is that all faces in the buffer change
 > size (well, not the mode line).

The faces do not change size.  They just "appear" larger or smaller.
And mode, header and tab line are not part of the buffer, so face
remapping does not affect them.  So far - I wouldn't mind if your change
affected mode and tab line as well.

 > And that makes sense since all other
 > implicitly inherits from it, right?
 >
 > This works even for anonymous faces, e.g.:
 >
 >     (progn
 >      (fundamental-mode)
 >      (insert (propertize "foo" 'face '(:height 1.5)))
 >      (text-scale-increase))
 >
 > What am I missing?

Inserting "foo" makes it part of the buffer text and thus subject to
text scaling ('text-scale-increase' needs an argument btw).

 >> (3) whether and how existing customizations of the header line face are
 >> taken into account.
 >>
 >> Wrt (3) I assume that 'tabulated-list-mode' can already get derailed
 >> when a user customizes header line face to use some large or small font
 >> size (a scenario where face remapping is not involved at all).
 >
 > I tried customizing the `Height' for the `header-line' face, and it
 > seems to work as expected:
 >
 > With no text-scale-mode it is as big as it is customized to be.  When I
 > run `text-scale-increase', it scales up accordingly (relative to its
 > customized size).  So I don't know what, if anything, should be added
 > here.  Since it works as expected, perhaps there is nothing to add?

OK.

 >> Note that maybe 'text-scale-mode-header-line' should be also watched by
 >> 'set-buffer-redisplay'.
 >
 > I tried adding `text-scale-remap-header-line-face' to the list of
 > variables that are fed to `add-variable-watcher' at the end of frame.el.
 > That doesn't work, unfortunately.
 >
 > I believe that since the remapping is done on a Lisp level,
 > `text-scale-mode' isn't called even with a variable watcher.  Is there a
 > way to work around that?  Or am I doing it wrong?

I'm not sure whether it's needed at all, Eli knows better.  I suppose it
should work out of the box because setting the header line format
already triggers 'set-buffer-redisplay' and the additional setting of
'text-scale-mode-header-line' will be covered by it.  We might have a
problem when these two are set in separate steps.

martin