unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Aaron Jensen <aaronjensen@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, 56102@debbugs.gnu.org
Subject: bug#56102: 29.0.50; fit-frame-to-buffer's window-text-pixel-size calculation can be incorrect when only is set to vertically
Date: Sun, 26 Jun 2022 12:09:25 +0200	[thread overview]
Message-ID: <1a6138f1-fae9-4d33-28b4-7069028ccc36@gmx.at> (raw)
In-Reply-To: <CAHyO48xEnb4RkAsOkMRegb4rfjMpGgL=hLToS9Scxzizy3Z8CQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1490 bytes --]

 > If I say that I only want it to scale vertically, I would
 > expect no width changes to occur, which means I would expect that
 > max-width and anything else width related would not be relevant.

Sounds reasonable.

 > My concern was this:
 >
 >> Also, the sizes of frame and window decorations would hardly match.
 >
 > Effectively, that there would be some subtle difference between using
 > (frame-parameter frame 'width) as MAX-WIDTH and passing nil to
 > window-text-pixel-size window.

I was wrong earlier.  The doc-string of 'fit-frame-to-buffer' says that

   MAX-HEIGHT, MIN-HEIGHT, MAX-WIDTH and MIN-WIDTH specify bounds on
   the new total size of FRAME’s root window.

But actually it is the _body_ size of FRAME's root window the current
code constrains.  Incidentally, the default body width of a live root
window equals the value of FRAME's width parameter (the native width of
the frame minus the widths of the internal border, the scroll bar and
the fringes) which makes your fix work.  With a non-standard setup, say
after doing

(set-window-margins nil 10 10)

in the root window, your fix will fail with the scenario you provided
earlier.

We could try the following: If the new diff I attach now works for you,
I'll push it to master.  If after some period of grace (whose length you
determine) I manage to come up with a reasonable fix, I'll push that to
master too and you and your clients will have to adapt.  WDYT?

martin

[-- Attachment #2: fit-frame-to-buffer.diff --]
[-- Type: text/x-patch, Size: 1280 bytes --]

diff --git a/lisp/window.el b/lisp/window.el
index eba888a89d..9333f03822 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -9385,14 +9385,15 @@ fit-frame-to-buffer-1
              ((numberp (nth 1 sizes)) (* (nth 1 sizes) line-height))
              (t (window-min-size window nil nil t))))
            (max-width
-            (min
-             (cond
-              ((numberp max-width) (* max-width char-width))
-              ((numberp (nth 2 sizes)) (* (nth 2 sizes) char-width))
-              (t parent-or-display-width))
-             ;; The following is the maximum width that fits into the
-             ;; left and right margins.
-             (max (- right-margin left-margin outer-minus-body-width))))
+            (unless (eq only 'vertically)
+              (min
+               (cond
+                ((numberp max-width) (* max-width char-width))
+                ((numberp (nth 2 sizes)) (* (nth 2 sizes) char-width))
+                (t parent-or-display-width))
+               ;; The following is the maximum width that fits into the
+               ;; left and right margins.
+               (max (- right-margin left-margin outer-minus-body-width)))))
            (min-width
             (cond
              ((numberp min-width) (* min-width char-width))

  reply	other threads:[~2022-06-26 10:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20  3:03 bug#56102: 29.0.50; fit-frame-to-buffer's window-text-pixel-size calculation can be incorrect when only is set to vertically Aaron Jensen
2022-06-22 13:58 ` Eli Zaretskii
2022-06-22 14:15   ` Aaron Jensen
2022-06-23  7:30     ` martin rudalics
2022-06-24  2:28       ` Aaron Jensen
2022-06-24  9:20         ` martin rudalics
2022-06-24 14:28           ` Aaron Jensen
2022-06-26 10:09             ` martin rudalics [this message]
2022-06-26 13:12               ` Aaron Jensen
2022-06-27  8:24                 ` martin rudalics
2022-06-27 13:24                   ` Aaron Jensen
2022-06-28  9:29                     ` martin rudalics
2022-06-28 14:52                       ` Aaron Jensen
2022-07-05 13:07                         ` Aaron Jensen
2022-07-06  7:37                           ` martin rudalics
2022-07-06 13:17                             ` Aaron Jensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1a6138f1-fae9-4d33-28b4-7069028ccc36@gmx.at \
    --to=rudalics@gmx.at \
    --cc=56102@debbugs.gnu.org \
    --cc=aaronjensen@gmail.com \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).