Subject: Re: bug#45628: 28.0.50; Scrolling on echo area with pixel-scroll-mode enabled locks up Emacs

From: Eli Zaretskii <[email-masked]>
Date: Mon, 04 Jan 2021 17:16:35 +0200

> From: Tak Kunihiro <[email-masked]>
> Date: Mon, 4 Jan 2021 17:57:48 +0900
> Cc: 国広卓也 <[email-masked]>
> 
> I think that following patch would work but usage of `while’
> does not look cool.  If there can is better style, please
> suggest me.

How about a normal while loop with catch before it and throw inside?

> -          (while (pixel-point-at-top-p amt) ; prevent too late (multi tries)
> -            (vertical-motion 1))            ; move point downward
> +          (while (and (pixel-point-at-top-p amt) ; prevent too late (multi tries)
> +                      (equal (vertical-motion 1) 1))) ; move point downward
>            (pixel-scroll-pixel-up amt))))))  ; move scope downward
>  
>  (defun pixel-scroll-down (&optional arg)
> @@ -149,8 +149,8 @@ pixel-scroll-down
>                           pixel-resolution-fine-flag
>                         (frame-char-height))
>                     (pixel-line-height -1))))
> -        (while (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
> -          (vertical-motion -1))              ; move point upward
> +        (while (and (pixel-point-at-bottom-p amt) ; prevent too late (multi tries)
> +                    (equal (vertical-motion -1) -1))) ; move point upward

I think equality to 1 or -1 is too stringent.  vertical-motion could
move more if you have overlay strings or display strings at point that
include embedded newlines.  So I think you should test >= 1 and <= -1
respectively.

Also, I believe this problem exists on the emacs-27 branch as well,
right?  Then we should install there first.

Thanks.