From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#70894: [PATCH] * lisp/window.el (fit-window-to-buffer): Fix width calculation Date: Sat, 18 May 2024 12:39:06 +0300 Message-ID: <86jzjre9xh.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="841"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70894@debbugs.gnu.org To: Morgan Smith , martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat May 18 11:40:27 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1s8GYF-000ARN-6B for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 May 2024 11:40:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s8GXo-0008Jp-V0; Sat, 18 May 2024 05:40:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s8GXn-0008JM-AZ for bug-gnu-emacs@gnu.org; Sat, 18 May 2024 05:39:59 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s8GXm-00075S-Ub for bug-gnu-emacs@gnu.org; Sat, 18 May 2024 05:39:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s8GXq-0000TT-8t for bug-gnu-emacs@gnu.org; Sat, 18 May 2024 05:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 May 2024 09:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70894 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70894-submit@debbugs.gnu.org id=B70894.17160251611788 (code B ref 70894); Sat, 18 May 2024 09:40:02 +0000 Original-Received: (at 70894) by debbugs.gnu.org; 18 May 2024 09:39:21 +0000 Original-Received: from localhost ([127.0.0.1]:60622 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8GXB-0000Sm-1b for submit@debbugs.gnu.org; Sat, 18 May 2024 05:39:21 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43286) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s8GX8-0000Sd-U7 for 70894@debbugs.gnu.org; Sat, 18 May 2024 05:39:19 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s8GWz-0006xJ-F8; Sat, 18 May 2024 05:39:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=R2cvCQc6QNkAmtYZrsGsrJhJ5pCfZEdqhWmhg6kwoKE=; b=PQnaCWRq5NIV PItPWluoGBiQEuuJYRjbVXroEGNPHmNeakRV4hSCWaVYkb3UBJT1pV7p00WT/vSL3sCtRZvKPA6HL 2xP7D1whnBBSQaTLx0+aBjK1F3W8hDSloLPgrAfCz4wdlHZe6nj4gjN0d07rZV1VOO12mgDtZn2LL juN9f0HbS380uYBOipg4JUfTHjmOV6pYK91g4peqZUdt9nCytIH3QNAYuF4iUjOwGlsxP4XPlmfuu MvFlHH/lWmNKS8oG7YvOrBYXprqQwniiE+li+6DEaFMdhNKYyGumJy2dGqPA0nIhl7m87JgFckgNB XYGd6g+QesPucQieoSueFg==; In-Reply-To: (message from Morgan Smith on Sun, 12 May 2024 09:25:31 -0400) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:285305 Archived-At: > From: Morgan Smith > Date: Sun, 12 May 2024 09:25:31 -0400 > > 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. Martin, any comments? > >From f906b1a219ae7c9ec1374edf6e02b46b845ab776 Mon Sep 17 00:00:00 2001 > From: Morgan Smith > 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 >