From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kan-Ru Chen (=?UTF-8?Q?=E9=99=B3=E4=BE=83=E5=A6=82?=) Newsgroups: gmane.emacs.bugs Subject: bug#18498: 24.3.93; [PATCH] Fix fit-window-to-buffer's buffer width calculation Date: Thu, 18 Sep 2014 17:46:55 +0800 Message-ID: <87k351uupc.fsf@kanru-mozilla.corp.tpe1.mozilla.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1411033890 29145 80.91.229.3 (18 Sep 2014 09:51:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 18 Sep 2014 09:51:30 +0000 (UTC) To: 18498@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 18 11:51:23 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XUYN1-0007mS-2S for geb-bug-gnu-emacs@m.gmane.org; Thu, 18 Sep 2014 11:51:23 +0200 Original-Received: from localhost ([::1]:49467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUYN0-0003by-H5 for geb-bug-gnu-emacs@m.gmane.org; Thu, 18 Sep 2014 05:51:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUYMs-0003ad-GS for bug-gnu-emacs@gnu.org; Thu, 18 Sep 2014 05:51:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUYMl-0007S4-JW for bug-gnu-emacs@gnu.org; Thu, 18 Sep 2014 05:51:14 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUYMl-0007RL-HC for bug-gnu-emacs@gnu.org; Thu, 18 Sep 2014 05:51:07 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XUYMg-0003lr-2a for bug-gnu-emacs@gnu.org; Thu, 18 Sep 2014 05:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Kan-Ru Chen (=?UTF-8?Q?=E9=99=B3=E4=BE=83=E5=A6=82?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 Sep 2014 09:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 18498 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.141103382014437 (code B ref -1); Thu, 18 Sep 2014 09:51:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 18 Sep 2014 09:50:20 +0000 Original-Received: from localhost ([127.0.0.1]:43954 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XUYLz-0003km-Tz for submit@debbugs.gnu.org; Thu, 18 Sep 2014 05:50:20 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51559) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XUYLw-0003kd-Jj for submit@debbugs.gnu.org; Thu, 18 Sep 2014 05:50:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUYLp-00079u-Gp for submit@debbugs.gnu.org; Thu, 18 Sep 2014 05:50:15 -0400 Original-Received: from lists.gnu.org ([208.118.235.17]:60877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUYLp-00074L-Es for submit@debbugs.gnu.org; Thu, 18 Sep 2014 05:50:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUYIJ-0002OH-0S for bug-gnu-emacs@gnu.org; Thu, 18 Sep 2014 05:46:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUYID-0006Av-Cj for bug-gnu-emacs@gnu.org; Thu, 18 Sep 2014 05:46:30 -0400 Original-Received: from zmmta1.corp.phx1.mozilla.com ([63.245.216.72]:51100 helo=mail.mozilla.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUYID-000684-7T for bug-gnu-emacs@gnu.org; Thu, 18 Sep 2014 05:46:25 -0400 Original-Received: from mail.mozilla.com (localhost6.localdomain [127.0.0.1]) by zmmta1.mail.corp.phx1.mozilla.com (Postfix) with ESMTPS id BCD37106454 for ; Thu, 18 Sep 2014 02:46:18 -0700 (PDT) Original-Received: from kanru-mozilla.corp.tpe1.mozilla.com (zlb1.mail.corp.phx1.mozilla.com [10.20.77.200]) (Authenticated sender: kchen@mozilla.com) by zmmta1.mail.corp.phx1.mozilla.com (Postfix) with ESMTPSA id 87931106443 for ; Thu, 18 Sep 2014 02:46:18 -0700 (PDT) Original-Received: from localhost ([127.0.0.1] helo=kanru-mozilla.corp.tpe1.mozilla.com) by kanru-mozilla.corp.tpe1.mozilla.com with esmtp (Exim 4.80) (envelope-from ) id 1XUYIh-0001Lh-4p for bug-gnu-emacs@gnu.org; Thu, 18 Sep 2014 17:46:55 +0800 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 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.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:93457 Archived-At: --=-=-= Content-Type: text/plain To reproduce: emacs -Q --eval '(progn (setq fit-window-to-buffer-horizontally t) (set-frame-size nil 120 20) (with-current-buffer-window "*scratch*" nil nil (insert (make-string 20 ?x)) (insert (make-string 10 ?\n)) (insert (make-string 90 ?x)) (split-window-horizontally) (fit-window-to-buffer) (message "window width: %d" (window-width))))' Expected result: window width: 90 Actual result: window width: 20 Patch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fix-fit-window-to-buffer-s-buffer-width-calculation.patch >From 3bcdeb847e579981229b065b8dbd01722a94fc18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kan-Ru=20Chen=20=28=E9=99=B3=E4=BE=83=E5=A6=82=29?= Date: Thu, 18 Sep 2014 17:36:54 +0800 Subject: Fix fit-window-to-buffer's buffer width calculation * window.el (fit-window-to-buffer): When counting buffer width, count the whole visible buffer. Correctly convert the body-height to pixel size for window-text-pixel-size. diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c82b6f7..9096b92 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,8 +1,14 @@ +2014-09-18 Kan-Ru Chen + + * window.el (fit-window-to-buffer): When counting buffer width, + count the whole visible buffer. Correctly convert the body-height + to pixel size for window-text-pixel-size. + 2014-09-14 Glenn Morris * image.el (image-multi-frame-p): Fix thinko - do not force a delay if none was specified. (Bug#18334) 2014-09-12 Kan-Ru Chen * window.el (fit-window-to-buffer): Doc fix. diff --git a/lisp/window.el b/lisp/window.el index 4dc30ff..c547725 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -7296,17 +7296,17 @@ accessible position." (width (+ (car (window-text-pixel-size nil (window-start) (point-max) (frame-pixel-width) ;; Add one char-height to assure that ;; we're on the safe side. This ;; overshoots when the first line below ;; the bottom is wider than the window. (* body-height - (if pixelwise char-height 1)))) + (if pixelwise 1 char-height)))) (window-right-divider-width)))) (unless pixelwise (setq width (/ (+ width char-width -1) char-width))) (unless (= width body-width) (window-resize-no-error window (- (max min-width (min max-width -- 1.9.1 --=-=-=--