unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#54894: 28.1; window-body-height returns wrong result if line-spacing is non-nil
@ 2022-04-12 20:38 Christoph Arenz
  2022-04-13  2:27 ` Eli Zaretskii
  2022-04-13  8:47 ` martin rudalics
  0 siblings, 2 replies; 4+ messages in thread
From: Christoph Arenz @ 2022-04-12 20:38 UTC (permalink / raw)
  To: 54894

[-- Attachment #1: Type: text/plain, Size: 2285 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 3627 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#54894: 28.1; window-body-height returns wrong result if line-spacing is non-nil
  2022-04-12 20:38 bug#54894: 28.1; window-body-height returns wrong result if line-spacing is non-nil Christoph Arenz
@ 2022-04-13  2:27 ` Eli Zaretskii
  2022-04-27 13:06   ` Lars Ingebrigtsen
  2022-04-13  8:47 ` martin rudalics
  1 sibling, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2022-04-13  2:27 UTC (permalink / raw)
  To: Christoph Arenz; +Cc: 54894

> Date: Tue, 12 Apr 2022 22:38:30 +0200
> From: Christoph Arenz <tiga.arenz@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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#54894: 28.1; window-body-height returns wrong result if line-spacing is non-nil
  2022-04-12 20:38 bug#54894: 28.1; window-body-height returns wrong result if line-spacing is non-nil Christoph Arenz
  2022-04-13  2:27 ` Eli Zaretskii
@ 2022-04-13  8:47 ` martin rudalics
  1 sibling, 0 replies; 4+ messages in thread
From: martin rudalics @ 2022-04-13  8:47 UTC (permalink / raw)
  To: Christoph Arenz, 54894

 > 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#54894: 28.1; window-body-height returns wrong result if line-spacing is non-nil
  2022-04-13  2:27 ` Eli Zaretskii
@ 2022-04-27 13:06   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-04-27 13:06 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Christoph Arenz, 54894

Eli Zaretskii <eliz@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





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-27 13:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 20:38 bug#54894: 28.1; window-body-height returns wrong result if line-spacing is non-nil Christoph Arenz
2022-04-13  2:27 ` Eli Zaretskii
2022-04-27 13:06   ` Lars Ingebrigtsen
2022-04-13  8:47 ` martin rudalics

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).