From df2ead390d7d54cb6c368e3099fb910a182ac7af Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Thu, 18 Sep 2014 14:06:17 +0200 Subject: [PATCH] Fix `fit-window-to-buffer' (Bug#18498). * 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 (Bug#18498). --- lisp/ChangeLog | 6 ++++++ lisp/window.el | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b696eb61ab9..0a72fa4aa2b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +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 (Bug#18498). + 2014-09-14 Glenn Morris * image.el (image-multi-frame-p): Fix thinko - do not force diff --git a/lisp/window.el b/lisp/window.el index 4dc30ff968c..7692c797afe 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -7289,10 +7289,10 @@ accessible position." max-width)) (+ total-width (window-max-delta nil t nil nil nil nil pixelwise)))) - ;; When fitting vertically, assume that WINDOW's start - ;; position remains unaltered. WINDOW can't get wider - ;; than its frame's pixel width, its height remains - ;; unaltered. + ;; When fitting horizontally, assume that WINDOW's + ;; start position remains unaltered. WINDOW can't get + ;; wider than its frame's pixel width, its height + ;; remains unaltered. (width (+ (car (window-text-pixel-size nil (window-start) (point-max) (frame-pixel-width) @@ -7301,7 +7301,7 @@ accessible position." ;; 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))) -- 2.39.2