[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#71085: text-scale-adjust does not adjust margin width
From: |
Eli Zaretskii |
Subject: |
bug#71085: text-scale-adjust does not adjust margin width |
Date: |
Tue, 21 May 2024 14:38:19 +0300 |
tags 71085 notabug
thanks
> From: Emre Yolcu <mail@emreyolcu.com>
> Date: Mon, 20 May 2024 18:50:28 -0400
>
> As of Emacs 29.3, changing the text size in a buffer using
> text-scale-adjust has no affect on margin width. Since the text displayed
> in the margins has the same height as the text in the buffer, this
> behavior causes the text in the margin to be clipped if we increase the
> text size too much by using text-scale-adjust. Here are the steps to
> confirm:
>
> 1. Launch with "emacs -Q".
> 2. Evaluate:
>
> (set-window-fringes nil 0)
> (set-window-margins nil 1)
>
> 3. Switch to a scratch buffer.
> 4. Place the cursor, which should be box-shaped by default, on the
> first-column of the buffer.
> 5. Increase the text size in the buffer by pressing C-x C-= several times.
>
> Expected behavior: Left margin has exactly the same width as that of the
> cursor.
> Current behavior: Left margin has width much smaller than that of the
> cursor.
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.
Since Emacs 29.1, we have global-text-scale-adjust-resizes-frames,
which, if non-nil, causes the frame to resize when you change the
text-size globally (e.g., with C-M-+ or C-M-mouse-wheel). If you do
that, the window-margins resize as well, which in this case is indeed
expected (and works for me).
> It also seems to me that there is no way to work around this problem in
> the Elisp layer, because text-scale-mode works by remapping faces in a
> buffer-local manner; however,
> - there is no face defined for the margins, and
> - it seems that the pixel width of the margins is not determined in a
> buffer-local manner.
>
> Given that {left,right}-margin-width are buffer-local variables, I would
> expect their pixel width to be determined in a buffer-local manner.
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 see no bug here.