Subject: bug#37563: 27.0.50; fit-frame-to-buffer does not account for line-spacing

From: Ingo Lohmar <[email-masked]>
Date: Tue, 01 Oct 2019 10:28:16 +0200

On Tue, Oct 01 2019 10:10 (+0200), martin rudalics wrote:

>  > thanks for the quick reply!  The fix is working for me.  The separate
>  > window-*-height functions are much better than what I sent a few
>  > minutes ago, I missed all kinds of scenarios, of course.
>
> For consistency, I would use these functions in 'fit-window-to-buffer'
> as well.  But I haven't looked into all consequences yet.  There's
> also Bug#14825 still sitting around the corner, awaiting a proper
> solution.  It's somehow troubling that all these substitute canonical
> character height with real line height fixes are inherently backward
> incompatible.  What if someone did mean to use the canonical character
> height there?

I surely find the complexity of all this code jarring, so I have to
restrict myself to looking at a single issue; and here, it's clearly
fixing a bug, using the char height is simply wrong, IMO.

>
>  > There's one thing from my patch, however, that I think is missing in
>  > yours:
>
> I think you're right but I need to see your patch first.  It's not
> here yet.

Debbugs and the mailing list interaction is another thing I do not
really understand ;)  In any case, the patch would simply be confusing
now, here's the change on top of yours:

@@ -8794,8 +8828,8 @@ fit-frame-to-buffer
       ;; Fit height to constraints.
       (when height
         (unless frame-resize-pixelwise
-          (setq height (* (/ (+ height char-height -1) char-height)
-                          char-height)))
+          (setq height (* (/ (+ height line-height -1) line-height)
+                          line-height)))
         ;; The new outer height.
         (setq outer-height (+ height outer-minus-body-height))
         ;; Preserve margins.

And then char-height can be dropped.

Best,
Ingo