all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Morgan Smith <Morgan.J.Smith@outlook.com>
To: 70894@debbugs.gnu.org
Subject: bug#70894: [PATCH] * lisp/window.el (fit-window-to-buffer): Fix width calculation
Date: Sun, 12 May 2024 09:25:31 -0400	[thread overview]
Message-ID: <CH3PR84MB3424400ADD023A59A6678F83C5E12@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM> (raw)

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

Tags: patch

Hello!

I was playing around with `fit-window-to-buffer' after setting
`fit-window-to-buffer-horizontally' to `t'.  I noticed that it kept
setting the window too narrow.  After a quick investigation, I found
some suspicious looking calculation that mixed pixel and column units.

Interactively, it looks like this fixes the issue.

Thanks,

Morgan



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-window.el-fit-window-to-buffer-Fix-width-calcul.patch --]
[-- Type: text/patch, Size: 1205 bytes --]

From f906b1a219ae7c9ec1374edf6e02b46b845ab776 Mon Sep 17 00:00:00 2001
From: Morgan Smith <Morgan.J.Smith@outlook.com>
Date: Sun, 12 May 2024 09:19:30 -0400
Subject: [PATCH] * lisp/window.el (fit-window-to-buffer): Fix width
 calculation

When pixelwise is nil, we still calculate width in pixels and
then convert it to columns.  However, part of the calculation
was using columns where it should have used pixels.
---
 lisp/window.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/window.el b/lisp/window.el
index 639090752be..f03996fb682 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -9906,8 +9906,8 @@ fit-window-to-buffer
 			       ;; the bottom is wider than the window.
 			       (* (window-body-height window pixelwise)
 				  (if pixelwise 1 char-height))))
-                         (- total-width
-                            (window-body-width window pixelwise)))))
+                         (- (* total-width (if pixelwise 1 char-width))
+                            (window-body-width window t)))))
 	  (unless pixelwise
 	    (setq width (/ (+ width char-width -1) char-width)))
           (setq width (max min-width (min max-width width)))
-- 
2.41.0


             reply	other threads:[~2024-05-12 13:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-12 13:25 Morgan Smith [this message]
2024-05-18  9:39 ` bug#70894: [PATCH] * lisp/window.el (fit-window-to-buffer): Fix width calculation Eli Zaretskii
2024-05-19  7:58   ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-19  8:09     ` Eli Zaretskii
2024-05-19  9:22       ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors

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

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

  git send-email \
    --in-reply-to=CH3PR84MB3424400ADD023A59A6678F83C5E12@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM \
    --to=morgan.j.smith@outlook.com \
    --cc=70894@debbugs.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 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.