aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2024-12-23 10:59:11 +0100
committerMartin Rudalics2024-12-23 10:59:11 +0100
commit6017c6a986fd958732facb1bb6ea2c040981b023 (patch)
treee74d3b79d947f0ff5416392d5566664ee9a12a6b
parent39380e1bd3bfc26e355445590e243fcfa940fc9f (diff)
downloademacs-6017c6a986fd958732facb1bb6ea2c040981b023.tar.gz
emacs-6017c6a986fd958732facb1bb6ea2c040981b023.zip
Make 'fit-frame-to-buffer' work around size hints (Bug#74866)
* lisp/window.el (fit-frame-to-buffer-1): When 'frame-resize-pixelwise' is nil, round up requested sizes to avoid that lines get wrapped (Bug#74866). * doc/lispref/windows.texi (Resizing Windows): Mention that with size hints one may have to set 'frame-resize-pixelwise' to make 'fit-frame-to-buffer' fit the buffer exactly.
-rw-r--r--doc/lispref/windows.texi4
-rw-r--r--lisp/window.el20
2 files changed, 23 insertions, 1 deletions
diff --git a/doc/lispref/windows.texi b/doc/lispref/windows.texi
index adc294e4c99..3ff78b599de 100644
--- a/doc/lispref/windows.texi
+++ b/doc/lispref/windows.texi
@@ -1166,7 +1166,9 @@ frame to its buffer using the command @code{fit-frame-to-buffer}.
1166This command adjusts the size of @var{frame} to display the contents of 1166This command adjusts the size of @var{frame} to display the contents of
1167its buffer exactly. @var{frame} can be any live frame and defaults to 1167its buffer exactly. @var{frame} can be any live frame and defaults to
1168the selected one. Fitting is done only if @var{frame}'s root window is 1168the selected one. Fitting is done only if @var{frame}'s root window is
1169live. 1169a live window. On window systems that use size hints, exact fitting can
1170be often achieved if and only if @code{frame-resize-pixelwise}
1171(@pxref{Frame Size}) is non-@code{nil}.
1170 1172
1171The arguments @var{max-height}, @var{min-height}, @var{max-width} and 1173The arguments @var{max-height}, @var{min-height}, @var{max-width} and
1172@var{min-width}, if non-@code{nil}, specify bounds on the new body size 1174@var{min-width}, if non-@code{nil}, specify bounds on the new body size
diff --git a/lisp/window.el b/lisp/window.el
index e9d57652ec6..cd19fd73849 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -9921,6 +9921,26 @@ for `fit-frame-to-buffer'."
9921 ;; Move frame down. 9921 ;; Move frame down.
9922 (setq top top-margin))))) 9922 (setq top top-margin)))))
9923 ;; Apply our changes. 9923 ;; Apply our changes.
9924 (unless frame-resize-pixelwise
9925 ;; When 'frame-resize-pixelwise' is nil, a frame cannot be
9926 ;; necessarily fit completely even if the window's calculated
9927 ;; width and height are integral multiples of the frame's
9928 ;; character width and height. The size hints Emacs produces
9929 ;; are inept to handle that when the combined sizes of the
9930 ;; frame's fringes, scroll bar and internal border are not an
9931 ;; integral multiple of the frame's character width (Bug#74866).
9932 ;; Consequently, the window manager will round sizes down and
9933 ;; this may cause lines getting wrapped. To avoid that, round
9934 ;; sizes up here which will, however, leave a blank space at the
9935 ;; end of the longest line(s).
9936 (setq text-minus-body-width
9937 (+ text-minus-body-width
9938 (- char-width
9939 (% text-minus-body-width char-width))))
9940 (setq text-minus-body-height
9941 (+ text-minus-body-height
9942 (- char-height
9943 (% text-minus-body-height char-height)))))
9924 (setq text-width 9944 (setq text-width
9925 (if width 9945 (if width
9926 (+ width text-minus-body-width) 9946 (+ width text-minus-body-width)