Subject: Re: bug#70038: 29.3.50; Shift up/down in buffer with images on M-x other-window with some fonts

From: Rahguzar <[email-masked]>
Date: Thu, 28 Mar 2024 18:24:32 +0100

Hi Ramon,

Ramon Diaz-Uriarte <[email-masked]> writes:

> Actually, maybe I can claim those bonus points: this does not depend on fonts, though I am triggering it using the package vertico (so maybe this example is vertico's fault):
>
>
> Steps:
>
> 1. emacs -Q
> 2. eval this code
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (package-initialize)
> (vertico-mode 1)
>
> (progn
>   (defun pin-vscroll-down (win)
>     (set-window-vscroll win 200 t))
>    (let* ((height (/ (* 2 (frame-pixel-height)) 15))
>          (image1 (create-image "/tmp/image1.png" nil nil :height height))
>          (image2 (create-image "/tmp/image2.png" nil nil :height height))
>          (image3 (create-image "/tmp/image3.png" nil nil :height height)))
>     (with-current-buffer (get-buffer-create "*image-scroll-test*")
>       (insert " \n \n \n \n \n \n")
>       (put-image image1 1)
>       (put-image image2 5)
>       (put-image image3 9)
>       ;; With larger image sizes (goto-char 3)
>       ;; also consistently triggers the problem.
>       (goto-char 11)
>       (add-hook 'pre-redisplay-functions #'pin-vscroll-down nil t))
>     (split-window-right)
>     (other-window 1)
>     (switch-to-buffer "*image-scroll-test*")))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> 3. Do `M-x` (or C-x b). No need to execute anything or switch buffers, just have the minibuffer show options.
>
> 4. `C-x o`  a few times. You'll see the images move up and down.
>
> I am seeing this in Lucid and GTK builds.

I can also reproduce this now! And vertico mode can be replaced with the
builtin icomplete-vertical-mode. So, the following recipe starting with
emacs -Q works for me:

1) Paste
(let ((height (/ (* 2 (frame-pixel-height)) 15)))
  (icomplete-vertical-mode)
  (defun pin-vscroll-down (win)
    (set-window-vscroll win (/ height 2) t))
  (let ((image1 (create-image "~/Downloads/image1.png" nil nil :height height))
        (image2 (create-image "~/Downloads/image2.png" nil nil :height height))
        (image3 (create-image "~/Downloads/image3.png" nil nil :height height)))
    (with-current-buffer (get-buffer-create "*image-scroll-test*")
      (insert " \n \n \n \n \n \n")
      (put-image image1 1)
      (put-image image2 5)
      (put-image image3 9)
      ;; With larger image sizes (goto-char 3)
      ;; also consistently triggers the problem.
      (goto-char 11)
      (add-hook 'pre-redisplay-functions #'pin-vscroll-down nil t))
    (split-window-right)
    (other-window 1)
    (switch-to-buffer "*image-scroll-test*")))

into scratch buffer.

2) Evaluate the form above using `C-M-x`.

3) Type M-x t

4) Wait till minibuffer expands to show completions, then type `C-g` to
quit minibuffer.

5) Typing `C-x 0` results in the window with images losing vscroll.

> Best,
> R.

Rahguzar