* bug#71085: text-scale-adjust does not adjust margin width @ 2024-05-20 22:50 Emre Yolcu 2024-05-21 11:38 ` Eli Zaretskii 0 siblings, 1 reply; 8+ messages in thread From: Emre Yolcu @ 2024-05-20 22:50 UTC (permalink / raw) To: 71085 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. 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#71085: text-scale-adjust does not adjust margin width 2024-05-20 22:50 bug#71085: text-scale-adjust does not adjust margin width Emre Yolcu @ 2024-05-21 11:38 ` Eli Zaretskii 2024-05-21 16:14 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-05-21 16:14 ` Emre Yolcu 0 siblings, 2 replies; 8+ messages in thread From: Eli Zaretskii @ 2024-05-21 11:38 UTC (permalink / raw) To: Emre Yolcu; +Cc: 71085 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#71085: text-scale-adjust does not adjust margin width 2024-05-21 11:38 ` Eli Zaretskii @ 2024-05-21 16:14 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-05-21 16:14 ` Emre Yolcu 1 sibling, 0 replies; 8+ messages in thread From: Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-21 16:14 UTC (permalink / raw) To: Eli Zaretskii, Emre Yolcu; +Cc: 71085@debbugs.gnu.org > tags 71085 notabug > 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). > I see no bug here. FWIW, I've previously proposed an optional enhancement of resizing the window when you change text size by scaling. I implemented this and proposed the code, as soon as text-scaling was introduced to Emacs. The suggestion/request was summarily rejected. The current request (#71085) is in the same vein. Yes, you can say there's no bug here, because text scaling, as provided so far, is independent of windows, margins, etc. Nevertheless, some users might find it useful to be able to resize such things when they resize the text. Think _enhancement request_, not bug per se. See also "bugs" 7342, 8379, 19194, 39901, 48307, 56357, 57313. ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#71085: text-scale-adjust does not adjust margin width 2024-05-21 11:38 ` Eli Zaretskii 2024-05-21 16:14 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-05-21 16:14 ` Emre Yolcu 2024-05-21 18:17 ` Eli Zaretskii 1 sibling, 1 reply; 8+ messages in thread From: Emre Yolcu @ 2024-05-21 16:14 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 71085 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. 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.) > 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). Thanks for that suggestion. Indeed, I often change text size globally, but sometimes resizing in a buffer-local manner is nice to have. >> 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 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. 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. As a motivating example, let me point out that text-scale-mode defines the variable text-scale-remap-header-line to allow resizing the size of the header line along with buffer text. If a "margin" face existed, we could add a new variable text-scale-remap-margin to achieve the behavior I suggested in an easy way. > I see no bug here. Fair enough. Please consider it a feature request for a "margin" face (for the reasons in the above paragraph). This is admittedly a highly niche problem, so I would understand if you think it is not worth the time. However, if you at least agree that having a face for the margins would be a welcome addition, I could make an attempt at a patch. ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#71085: text-scale-adjust does not adjust margin width 2024-05-21 16:14 ` Emre Yolcu @ 2024-05-21 18:17 ` Eli Zaretskii 2024-05-21 20:10 ` Emre Yolcu 0 siblings, 1 reply; 8+ messages in thread From: Eli Zaretskii @ 2024-05-21 18:17 UTC (permalink / raw) To: Emre Yolcu; +Cc: 71085 > Date: Tue, 21 May 2024 12:14:41 -0400 > Cc: 71085@debbugs.gnu.org > From: Emre Yolcu <mail@emreyolcu.com> > > 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#71085: text-scale-adjust does not adjust margin width 2024-05-21 18:17 ` Eli Zaretskii @ 2024-05-21 20:10 ` Emre Yolcu 2024-05-22 12:03 ` Eli Zaretskii 0 siblings, 1 reply; 8+ messages in thread From: Emre Yolcu @ 2024-05-21 20:10 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 71085 > I don't see a need for it, sorry. Got it. Thanks for discussing it anyway. I don't want to keep the thread going for too long, but I want to reply to some of your comments and leave it at that. (Maybe the discussion will be useful in the future, on the off chance that the issue gets revisited.) >>> 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. FWIW, some wording in the Emacs manual suggests, at least for me, the interpretation that margins are to be viewed as part of the buffer. From Section 41.16.5: "A buffer can have blank areas called display margins on the left and on the right. Ordinary text never appears in these areas, ..." On the other hand, the function for setting margin widths is called "set-window-margins". >> 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. By remap here I mean that it will remap the margin face *back* to the original height. The current behavior does not explicitly touch (remap) the text in the margin, so the height gets determined by the buffer-local height of the default face. If enabled, the option would make text-scale-mode remap the margin face back to the original height to prevent the text from getting clipped. ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#71085: text-scale-adjust does not adjust margin width 2024-05-21 20:10 ` Emre Yolcu @ 2024-05-22 12:03 ` Eli Zaretskii 2024-05-22 17:05 ` Emre Yolcu 0 siblings, 1 reply; 8+ messages in thread From: Eli Zaretskii @ 2024-05-22 12:03 UTC (permalink / raw) To: Emre Yolcu; +Cc: 71085 > From: Emre Yolcu <mail@emreyolcu.com> > Date: Tue, 21 May 2024 16:10:14 -0400 > Cc: 71085@debbugs.gnu.org > > > 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. > By remap here I mean that it will remap the margin face *back* to the > original height. The current behavior does not explicitly touch (remap) > the text in the margin, so the height gets determined by the buffer-local > height of the default face. Which means the text in the margins is "remapped" together with the rest of buffer text. While you want it to retain its original size, so as not to be clipped. > If enabled, the option would make text-scale-mode remap the margin > face back to the original height to prevent the text from getting > clipped. We don't have "remapping back" in Emacs. Face remapping affects the same all the faces that don't have an absolute size specification, so they all grow or shrink in the same manner. The only faces that don't grow/shrink are those which are NOT remapped or have an absolute size spec. ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#71085: text-scale-adjust does not adjust margin width 2024-05-22 12:03 ` Eli Zaretskii @ 2024-05-22 17:05 ` Emre Yolcu 0 siblings, 0 replies; 8+ messages in thread From: Emre Yolcu @ 2024-05-22 17:05 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 71085 > [...] have an absolute size spec. This is what I have been trying to mean by "remap back" but now I see how that can be confusing. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-05-22 17:05 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-05-20 22:50 bug#71085: text-scale-adjust does not adjust margin width Emre Yolcu 2024-05-21 11:38 ` Eli Zaretskii 2024-05-21 16:14 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors 2024-05-21 16:14 ` Emre Yolcu 2024-05-21 18:17 ` Eli Zaretskii 2024-05-21 20:10 ` Emre Yolcu 2024-05-22 12:03 ` Eli Zaretskii 2024-05-22 17:05 ` Emre Yolcu
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.