GNU bug report logs - #37563
27.0.50; fit-frame-to-buffer does not account for line-spacing

Previous Next

Package: emacs;

Reported by: Ingo Lohmar <ingo.lohmar <at> posteo.net>

Date: Mon, 30 Sep 2019 19:34:01 UTC

Severity: normal

Found in version 27.0.50

Done: Ingo Lohmar <ingo.lohmar <at> posteo.net>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 37563 <at> debbugs.gnu.org (full text, mbox):

From: Ingo Lohmar <ingo.lohmar <at> posteo.net>
To: 37563 <at> debbugs.gnu.org
Subject: [PATCH] please review
Date: Tue, 01 Oct 2019 09:39:20 +0200
[Message part 1 (text/plain, inline)]
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..

[0001-Fix-frame-height-calculation-from-max-height.patch (text/x-diff, inline)]
From 5b9ee5b913b031fca6f424170d9b61addb090294 Mon Sep 17 00:00:00 2001
From: Ingo Lohmar <ingo.lohmar <at> github.com>
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


This bug report was last modified 5 years and 220 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.