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

From: Stefan Kangas <[email-masked]>
Date: Sat, 31 Oct 2020 00:31:45 +0000

martin rudalics <[email-masked]> writes:

>  >    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".

It doesn't scale the text in the mode line, though.

>  >  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?

Yes.  But that seems (in my testing) to be the case for any face I
tested that doesn't have an absolute value for :height.  So I'm not sure
that it needs to be specifically mentioned in NEWS.

> 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.

I'm not sure it is clear to everyone (it cleared some stuff up for me),
but I worry that this might be too detailed for NEWS.  The interesting
bits is probably not exactly how it works, but rather what its visible
effects are.

> We might have a problem when these two are set in separate steps.

Yes, if the variable is set after scaling, it does not take effect until
another scaling operation is done.

Adding this seems to fix that:

(add-variable-watcher 'text-scale-remap-header-line-face
		      #'text-scale--refresh)

(defun text-scale--refresh (symbol newval operation where)
  (when (and (eq symbol 'text-scale-remap-header-line-face)
             (eq operation 'set)
             text-scale-mode)
    (with-current-buffer where
      (let ((text-scale-remap-header-line-face newval))
	(text-scale-mode 1)))))