You assume that window-start and window-end will reliably tell you the
beginning and end of the window in the middle of a Lisp program?
Their doc strings explicitly say that the values are updated by
redisplay. window-end is specifically documented to be accurate only
after redisplay ends. I believe this is why you need to call sit-for:
that function triggers redisplay.
> From: dalanicolai <dalanicolai@gmail.com>
> Date: Tue, 21 Feb 2023 14:39:36 +0100
> Cc: emacs-devel@gnu.org
>
> In this example code, I am simply displaying all images at once,
> because I am assuming that the images in the directory are not too
> many and that they are small (which is not a very reasonable
> assumption, but this is just my personal 'test' function).
>
> Indeed, the example does not call sit-for, because it should show that
> the printed number of overlays, is the number of all images in the
> directory (instead of only the number of images currently on the
> screen, i.e. within '(overlays-in (window-start) (window-end))' ).
You assume that window-start and window-end will reliably tell you the
beginning and end of the window in the middle of a Lisp program?
Their doc strings explicitly say that the values are updated by
redisplay. window-end is specifically documented to be accurate only
after redisplay ends. I believe this is why you need to call sit-for:
that function triggers redisplay.
> B.t.w. I am using Emacs 29 (and 30), and the overlay-recenter is still there.
> Maybe it would be handy to remove it then?
We don't want to remove it because that could break some third-party
packages. So we made the function do nothing instead.