GNU bug report logs - #54894
28.1; window-body-height returns wrong result if line-spacing is non-nil

Previous Next

Package: emacs;

Reported by: Christoph Arenz <tiga.arenz <at> web.de>

Date: Tue, 12 Apr 2022 20:39:01 UTC

Severity: normal

Tags: moreinfo

Found in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 54894 in the body.
You can then email your comments to 54894 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#54894; Package emacs. (Tue, 12 Apr 2022 20:39:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christoph Arenz <tiga.arenz <at> web.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 12 Apr 2022 20:39:01 GMT) Full text and rfc822 format available.

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

From: Christoph Arenz <tiga.arenz <at> web.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.1; window-body-height returns wrong result if line-spacing is
 non-nil
Date: Tue, 12 Apr 2022 22:38:30 +0200
[Message part 1 (text/plain, inline)]
Help for window-body-height says:
(window-body-height &optional WINDOW PIXELWISE)

Return the height of WINDOW’s text area.
WINDOW must be a live window and defaults to the selected one.  Optional
argument PIXELWISE non-nil means return the height of WINDOW’s text area
in pixels.  The return value does not include the mode line or header
line or any horizontal divider.

If PIXELWISE is nil, return the largest integer smaller than WINDOW’s
pixel height divided by the character height of WINDOW’s frame.  This
means that if a line at the bottom of the text area is only partially
visible, that line is not counted.
----------

It seems the case with PIXELWISE being nil is not handled correctly when
line-spacing is non-nil.

How to recreate:

Good case:
1. emacs -Q
2. C-h C-c  ;; fill buffer window full of text
3. M-r M-r M-r ;; Note line number of lowest line in window in the mode
line -- in my case L34
4. M-x (window-body-height)  ;; in my case also returning 34

Bad case:
5. M-: (setq line-spacing 2) ;; increase line spacing and create partial
last line
6. M-<  ;; goto beginning of buffer
7. M-r M-r M-r ;; Note line number of lowest FULL line in window in the mode
line; in my case L30
8. M-x (window-body-height)  ;; in my case STILL returning 34

9. M-x (floor (/ (window-body-height nil t) (line-pixel-height))) ;;
this results to 30 as would be the expected result in line 8.



In GNU Emacs 28.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30,
cairo version 1.15.10)
 of 2022-04-08 built on M92p
Repository revision: 5a223c7f2ef4c31abbd46367b6ea83cd19d30aa7
Repository branch: HEAD
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Ubuntu 18.04.6 LTS

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER
PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM
GTK3 ZLIB

Important settings:
  value of $LC_MONETARY: de_DE.UTF-8
  value of $LC_NUMERIC: de_DE.UTF-8
  value of $LC_TIME: de_DE.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54894; Package emacs. (Wed, 13 Apr 2022 02:28:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Christoph Arenz <tiga.arenz <at> web.de>
Cc: 54894 <at> debbugs.gnu.org
Subject: Re: bug#54894: 28.1;
 window-body-height returns wrong result if line-spacing is non-nil
Date: Wed, 13 Apr 2022 05:27:56 +0300
> Date: Tue, 12 Apr 2022 22:38:30 +0200
> From: Christoph Arenz <tiga.arenz <at> web.de>
> 
> Help for window-body-height says:
> (window-body-height &optional WINDOW PIXELWISE)
> 
> Return the height of WINDOW’s text area.
> WINDOW must be a live window and defaults to the selected one.  Optional
> argument PIXELWISE non-nil means return the height of WINDOW’s text area
> in pixels.  The return value does not include the mode line or header
> line or any horizontal divider.
> 
> If PIXELWISE is nil, return the largest integer smaller than WINDOW’s
> pixel height divided by the character height of WINDOW’s frame.  This
> means that if a line at the bottom of the text area is only partially
> visible, that line is not counted.
> ----------
> 
> It seems the case with PIXELWISE being nil is not handled correctly when
> line-spacing is non-nil.

It does handle that correctly.  Like with most (if not all) functions
that return window and frame dimensions, the return value is in unit
of a canonical line height for the frame.  It doesn't count the actual
text lines.  So it isn't affected by stuff like line-spacing, the
actual height of the lines due to changes in fonts, etc.

This is not a bug, but the intended behavior.




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 13 Apr 2022 03:58:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54894; Package emacs. (Wed, 13 Apr 2022 08:48:01 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: Christoph Arenz <tiga.arenz <at> web.de>, 54894 <at> debbugs.gnu.org
Subject: Re: bug#54894: 28.1; window-body-height returns wrong result if
 line-spacing is non-nil
Date: Wed, 13 Apr 2022 10:47:05 +0200
> Help for window-body-height says:
> (window-body-height &optional WINDOW PIXELWISE)
>
> Return the height of WINDOW’s text area.
> WINDOW must be a live window and defaults to the selected one.  Optional
> argument PIXELWISE non-nil means return the height of WINDOW’s text area
> in pixels.  The return value does not include the mode line or header
> line or any horizontal divider.
>
> If PIXELWISE is nil, return the largest integer smaller than WINDOW’s
> pixel height divided by the character height of WINDOW’s frame.  This
> means that if a line at the bottom of the text area is only partially
> visible, that line is not counted.
> ----------
>
> It seems the case with PIXELWISE being nil is not handled correctly when
> line-spacing is non-nil.

Line-spacing does not affect the "character height of WINDOW’s frame".
I have made local changes here that describe that function as follows:

 -- Function: window-body-height &optional window pixelwise
     This function returns the height of WINDOW’s body.  WINDOW must be
     a live window and defaults to the selected one.

     If the optional argument PIXELWISE is non-‘nil’, this function
     returns the height of WINDOW’s body in pixels—the body pixel height
     of WINDOW.

     If PIXELWISE is ‘nil’, the return value depends on the current
     value of ‘window-scale-body’ (*note Window Character Size::) as
     follows:

        • If ‘window-scale-body’ is ‘nil’, this function returns the
          largest integer smaller than WINDOW’s body pixel height
          divided by the character height of WINDOW’s frame.

        • If ‘window-scale-body’ is ‘t’, it returns the largest integer
          smaller than WINDOW’s body pixel height divided by WINDOW’s
          character height.

        • If ‘window-scale-body’ is the symbol ‘spaced’, it returns the
          largest integer smaller than WINDOW’s body pixel height
          divided by WINDOW’s spaced character height.

     If PIXELWISE is non-‘nil’, the return value is always rounded down
     to the nearest integer, if necessary.  This means that if a line at
     the bottom of the text area is only partially visible, that line is
     not counted.  It also means that if ‘window-scale-body’ is ‘nil’,
     the value returned by this function can never exceed the value
     returned by ‘window-total-height’ for WINDOW.

martin

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54894; Package emacs. (Wed, 27 Apr 2022 13:07:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Christoph Arenz <tiga.arenz <at> web.de>, 54894 <at> debbugs.gnu.org
Subject: Re: bug#54894: 28.1; window-body-height returns wrong result if
 line-spacing is non-nil
Date: Wed, 27 Apr 2022 15:06:17 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> It does handle that correctly.  Like with most (if not all) functions
> that return window and frame dimensions, the return value is in unit
> of a canonical line height for the frame.  It doesn't count the actual
> text lines.  So it isn't affected by stuff like line-spacing, the
> actual height of the lines due to changes in fonts, etc.
>
> This is not a bug, but the intended behavior.

I'm therefore closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 54894 <at> debbugs.gnu.org and Christoph Arenz <tiga.arenz <at> web.de> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 27 Apr 2022 13:07:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 26 May 2022 11:24:15 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 307 days ago.

Previous Next


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