I now came up with a fix for 'fit-window-to-buffer' too which had some strange misbehavior with different size restricting arguments when the window's text size did not change. See attached diffs and Change Log below. > I think I understand better now, I was hampered by some weird debugging > artifacts in my current setup. With the default > `frame-resize-pixelwise' of nil, and the otherwise bug-fixed code, > nothing is cut off, but there is some slack whitespace, indeed. I suppose that part of that whitespace comes from the fact that with 'line-spacing' greater zero, 'window-text-pixel-size' includes the space below the last line of its text. It would be nice to get rid of that but ISTR that a line's text may now get centered within the space reserved for it. So I cannot just remove the entire line space of one line from the return value but probably only half of the line spacing value. How would I know the right value? martin Fixes for fitting windows and frames to their buffers (Bug#37563) * lisp/window.el (window-default-font-height) (window-default-line-height): New functions. (fit-frame-to-buffer): Interpret values of MAX-HEIGHT and MIN-HEIGHT arguments in terms of WINDOW's default line height (Bug#37563). (fit-window-to-buffer): Obey size restricting arguments even when size of WINDOW's text does not change. Do not temporarily select WINDOW and perform height/width related calculations if and only if WINDOW is accordingly combined. Interpret values of MAX-HEIGHT and MIN-HEIGHT arguments in terms of WINDOW's default line height.