GNU bug report logs - #18498
24.3.93; [PATCH] Fix fit-window-to-buffer's buffer width calculation

Previous Next

Package: emacs;

Reported by: Kan-Ru Chen (陳侃如) <kanru <at> kanru.info>

Date: Thu, 18 Sep 2014 09:51:01 UTC

Severity: normal

Tags: patch

Found in version 24.3.93

Done: martin rudalics <rudalics <at> gmx.at>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18498 in the body.
You can then email your comments to 18498 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18498; Package emacs. (Thu, 18 Sep 2014 09:51:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kan-Ru Chen (陳侃如) <kanru <at> kanru.info>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 18 Sep 2014 09:51:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Kan-Ru Chen (陳侃如) <kanru <at> kanru.info>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.93; [PATCH] Fix fit-window-to-buffer's buffer width calculation
Date: Thu, 18 Sep 2014 17:46:55 +0800
[Message part 1 (text/plain, inline)]
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:

[0001-Fix-fit-window-to-buffer-s-buffer-width-calculation.patch (text/x-diff, inline)]
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?=
 <kanru <at> kanru.info>
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  <kanru <at> kanru.info>
+
+	* 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  <rgm <at> gnu.org>
 
 	* 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  <kanru <at> kanru.info>
 
 	* 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


Reply sent to martin rudalics <rudalics <at> gmx.at>:
You have taken responsibility. (Thu, 18 Sep 2014 12:10:02 GMT) Full text and rfc822 format available.

Notification sent to Kan-Ru Chen (陳侃如) <kanru <at> kanru.info>:
bug acknowledged by developer. (Thu, 18 Sep 2014 12:10:04 GMT) Full text and rfc822 format available.

Message #10 received at 18498-done <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: "Kan-Ru Chen (陳侃如)" <kanru <at> kanru.info>, 
 18498-done <at> debbugs.gnu.org
Subject: Re: bug#18498: 24.3.93; [PATCH] Fix fit-window-to-buffer's buffer
 width calculation
Date: Thu, 18 Sep 2014 14:08:59 +0200
> Patch:

Committed in revision 117506 of the emacs-24 branch.  Bug closed.

Thank you very much, martin





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 17 Oct 2014 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 251 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.