Subject: Re: bug#65214: 29.1; Tall images in 'image-mode' can't be scrolled with 'pixel-scroll-precision-mode' on

From: Po Lu <[email-masked]>
Date: Fri, 11 Aug 2023 11:38:28 +0800

Rahguzar <[email-masked]> writes:

> Dear Emacs developers,
>
> To reproduce starting from 'emacs -Q' visit an image file. Then
> repeatedly use 'i +' till the image is taller than the window. The
> image can be scrolled using mouse wheel. Now do
>
> M-x pixel-scroll-precision-mode
>
> After this attempting to scroll the image will set the vscroll to 0
> and then image can't be scrolled at all.
>
>>>From some investigation it seems like this behavior is not specific
> to image-mode. Another way to reproduce the behavior is to evaluate
> the following lisp code,
>
> (let* ((win (display-buffer (get-buffer-create "image-pixel-precision-test")))
>        (height (* (window-text-height win t) 2))
>        (file "path/to/image"))
>   (select-window win)
>   (erase-buffer)
>   (insert-image (create-image file nil nil))
>   (goto-char 1)
>   (pixel-scroll-precision-mode)
>   nil)
>
> This image thus displayed can not be scrolled. However if the code
> above is slightly modified to insert a new line after the image,
> scrolling can be done normally, i.e.
>
> (let* ((win (display-buffer (get-buffer-create "image-pixel-precision-test")))
>        (height (* (window-text-height win t) 2))
>        (file "path/to/image"))
>   (select-window win)
>   (erase-buffer)
>   (insert-image (create-image file nil nil))
>   (insert "\n")
>   (goto-char 1)
>   (pixel-scroll-precision-mode)
>   nil)
>
> produces an image that can be scrolled. Inserting a newline after the
> text covered by the text property holding the image also fixes the
> problem in 'image-mode' but that doesn't seem like the right fix to me.
>
> Rahguzar

This is a known limitation of pixel-scroll-precision-mode: redisplay's
automatic recentering impededs adjustment of the vscroll as the image
moves outside of the window's text area.  Unfortunately, it's not slated
to be fixed any time soon.