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))' ).
For example, I have a directory with 108 images, when I run 'M-x
scrap-dir-images' it print 108, although it should print the number of
images on screen i.e. by '(overlays-in (window-start) (window-end))',
which value is what 'scrap-dir-images' prints. However, the images
are normal 'foto' size, so that I only see two images on screen, and
indeed doing 'M-: (overlays-in (window-start) (window-end))' manually
now prints 2. If I had added the '(sit-for)' in the example
code, then I would have 'fixed' the problem, and 'scrap-dir-images'
would have printed 2 immediately because the display property
('expansion of the overlays') got enough time to take effect.
I hope this clears things up, but of course I would be happy to try
another explanation (e.g. sending by adding an animated gif).
But this function is a no-op in Emacs 29 and later, since the overlays
were reimplemented in a way that makes it unnecessary to "center" the
list of overlays. So you can forget about that and ignore this
function.
Thanks, that is indeed handy to know.