Subject: bug#37563: [PATCH] please review

From: Ingo Lohmar <[email-masked]>
Date: Tue, 01 Oct 2019 09:39:20 +0200

This has an obvious fix after sleeping on it: Just increase the
char-height by the line-spacing.  The local var `char-height' is used
once again in the function, but also with the correct meaning.

Actually it should be renamed to `line-height', should I do that?
Other than that, waiting for some kind of review before I commit..

>From 5b9ee5b913b031fca6f424170d9b61addb090294 Mon Sep 17 00:00:00 2001
From: Ingo Lohmar <[email-masked]>
Date: Tue, 1 Oct 2019 09:27:55 +0200
Subject: [PATCH] Fix frame height calculation from max-height

When `fit-frame-to-buffer' is given a non-nil `max-height' argument,
we need to work not with the char-height, but with the line-height
including `line-spacing' (Bug#37563).

* lisp/window.el (fit-frame-to-buffer): Account for line-spacing in height.
---
 lisp/window.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/window.el b/lisp/window.el
index 620eacdd29..21b58495fa 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8637,7 +8637,10 @@ fit-frame-to-buffer
   (setq frame (window-normalize-frame frame))
   (when (window-live-p (frame-root-window frame))
     (let* ((char-width (frame-char-width frame))
-           (char-height (frame-char-height frame))
+           (char-height (+ (frame-char-height frame)
+                           ;; Add line-spacing in the selected window's buffer.
+                           (buffer-local-value 'line-spacing
+                                               (window-buffer (car (window-list))))))
            ;; WINDOW is FRAME's root window.
            (window (frame-root-window frame))
            (parent (frame-parent frame))
-- 
2.23.0