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.
This commit is contained in:
parent
39380e1bd3
commit
6017c6a986
2 changed files with 23 additions and 1 deletions
|
@ -1166,7 +1166,9 @@ frame to its buffer using the command @code{fit-frame-to-buffer}.
|
|||
This command adjusts the size of @var{frame} to display the contents of
|
||||
its buffer exactly. @var{frame} can be any live frame and defaults to
|
||||
the selected one. Fitting is done only if @var{frame}'s root window is
|
||||
live.
|
||||
a live window. On window systems that use size hints, exact fitting can
|
||||
be often achieved if and only if @code{frame-resize-pixelwise}
|
||||
(@pxref{Frame Size}) is non-@code{nil}.
|
||||
|
||||
The arguments @var{max-height}, @var{min-height}, @var{max-width} and
|
||||
@var{min-width}, if non-@code{nil}, specify bounds on the new body size
|
||||
|
|
|
@ -9921,6 +9921,26 @@ for `fit-frame-to-buffer'."
|
|||
;; Move frame down.
|
||||
(setq top top-margin)))))
|
||||
;; Apply our changes.
|
||||
(unless frame-resize-pixelwise
|
||||
;; When 'frame-resize-pixelwise' is nil, a frame cannot be
|
||||
;; necessarily fit completely even if the window's calculated
|
||||
;; width and height are integral multiples of the frame's
|
||||
;; character width and height. The size hints Emacs produces
|
||||
;; are inept to handle that when the combined sizes of the
|
||||
;; frame's fringes, scroll bar and internal border are not an
|
||||
;; integral multiple of the frame's character width (Bug#74866).
|
||||
;; Consequently, the window manager will round sizes down and
|
||||
;; this may cause lines getting wrapped. To avoid that, round
|
||||
;; sizes up here which will, however, leave a blank space at the
|
||||
;; end of the longest line(s).
|
||||
(setq text-minus-body-width
|
||||
(+ text-minus-body-width
|
||||
(- char-width
|
||||
(% text-minus-body-width char-width))))
|
||||
(setq text-minus-body-height
|
||||
(+ text-minus-body-height
|
||||
(- char-height
|
||||
(% text-minus-body-height char-height)))))
|
||||
(setq text-width
|
||||
(if width
|
||||
(+ width text-minus-body-width)
|
||||
|
|
Loading…
Add table
Reference in a new issue