Subject: Re: bug#71085: text-scale-adjust does not adjust margin width

From: Eli Zaretskii <[email-masked]>
Date: Tue, 21 May 2024 21:17:37 +0300

> Date: Tue, 21 May 2024 12:14:41 -0400
> Cc: [email-masked]
> From: Emre Yolcu <[email-masked]>
> 
> Eli Zaretskii wrote:
> > I don't understand the expectations: the window and frame geometry are
> > not changed by text-scale-adjust, so why did you expect the window
> > margins to change?  The margins are part of the window geometry.
> I was not thinking of the margins as part of the window geometry but as 
> a special part of the buffer that we set aside and do not interact with. 

Well, but the fact is the margins _are_ part of the window geometry.
And window geometry doesn't change when text size is scaled.  So this
is a de-facto behavior Emacs had for several releases now, and we must
preserve it.

> This is partly because the margins display text, the height of which is 
> affected by text-scale-adjust, and partly because there is no visual 
> separation between the margin and the buffer (assuming fringes are 
> disabled). For comparison, the mode line also displays text, but it has 
> its own face and its text size is not affected by text-scale-adjust (as 
> one would expect). The fringe also has its own face, as do all of the 
> other things that I would consider to be part of the window geometry, 
> but there is no "margin" face. (I am aware that we can affect its 
> display to some degree by propertizing the text in it.)

I see no reason to introduce yet another face.  Most stuff displayed
in the margin doesn't need to be resized, so modes who write some
large enough text there can use a special face as I demonstrated.

> > The above is inaccurate: the text shown in the margin can have its own
> > distinct face.  For example, try this in "emacs -Q":
> >
> >    M-x font-lock-mode RET
> >    M-<
> >    M-: (set-window-margins nil 4 4) RET
> >    M-: (add-text-properties (point) (1+ (point)) (list 'display (list '(margin left-margin) (propertize "FOO" 'face 'warning)))) RET
> >
> > You will see the string "FOO" displayed in the margin with a distinct
> > face.  You could define this face to have an absolute :height
> > attribute, in which case the text in the margin will not scale, and
> > thus will not be clipped when you use text-size-adjust.  So there _is_
> > in fact a way to work around, even if you don't want to use
> > global-text-scale-adjust-resizes-frames and the globalized
> > text-scaling.
> I didn't mean to imply that we cannot affect the appearance of the text 
> displayed in the margins in any way, but simply that there is no 
> "margin" face that a user can modify via, for instance, 
> custom-set-faces. The workaround that you suggested requires the user to 
> patch every single package that displays text in the margins, which is 
> less than ideal.

Not "every package", because not every package has these problems.
But yes, packages that want the text in the margins to remain visible
even when the text is significantly resized need to define a special
face for the margin.  I see no problem here, since this is on a
per-package basis.

> A much nicer workaround would be possible if there 
> existed a "margin" face: text-scale-mode could simply remap it as it 
> does the default face.

Actually, you want a face that will _not_ be remapped, since you want
to make sure the text in the margins will not get clipped.  The
current behavior is that by default the text in the margin is already
remapped, which is why it can get clipped if it becomes too wide.

> > I see no bug here.
> Fair enough. Please consider it a feature request for a "margin" face 

I don't see a need for it, sorry.