diff --git a/lisp/window.el b/lisp/window.el index 1b8fe2b262..7b8ca87f6a 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -9382,14 +9382,17 @@ fit-frame-to-buffer-1 ((numberp (nth 1 sizes)) (* (nth 1 sizes) line-height)) (t (window-min-size window nil nil t)))) (max-width - (min - (cond - ((numberp max-width) (* max-width char-width)) - ((numberp (nth 2 sizes)) (* (nth 2 sizes) char-width)) - (t parent-or-display-width)) - ;; The following is the maximum width that fits into the - ;; left and right margins. - (max (- right-margin left-margin outer-minus-body-width)))) + (let ((max-width + (cond + ((numberp max-width) (* max-width char-width)) + ((numberp (nth 2 sizes)) (* (nth 2 sizes) char-width)) + ((not (eq only 'vertically)) parent-or-display-width)))) + (when (numberp max-width) + (min max-width + ;; The following is the maximum width that fits + ;; into the left and right margins. + (max (- right-margin left-margin + outer-minus-body-width)))))) (min-width (cond ((numberp min-width) (* min-width char-width))