Thank you for looking again at it Eli,

in the recipe, I am printing the buffer-name and the window-start
together (where the buffer-name gets evaluated before window-start),
and it says that the buffer-name is 'example'. So I expected
(window-start) to return the window-start from the window displaying
the example buffer.

I already wanted to write you that this must be the case, but I
thought let me first try to print the buffer of the selected-window.
In that case, indeed, it shows that the selected-window is that of the
warning buffer.

Finally, I understand now that the current-buffer is not per se the same
as the buffer displayed in the selected window. I understand it now, but
until now that was not obvious to me.

Thanks again Eli, for clearing things up!

On Sat, 4 Nov 2023 at 08:13, Eli Zaretskii <eliz@gnu.org> wrote:
> From: dalanicolai <dalanicolai@gmail.com>
> Date: Sat, 4 Nov 2023 00:23:30 +0100
> Cc: 66922@debbugs.gnu.org
>
> Sorry Eli, I don't know what you mean here. Over here the problem does
> occur also in the GUI, and I am using the print to
> 'external-debugging-output' because the lwarn is what causes the
> problem. I explained in the bug report that the window-start does not
> get updated when including the lwarn after the forced redisplay (the
> point is at 11, but window-start is still at 1).

Sorry, I didn't understand what you considered a "bug", because your
original description has all but drowned that in the long description
of what the code does.  So I thought that "messes redisplay" is the
problem, and that it alludes to the text from
external-debugging-output that appears inside the window of the TTY
frame.

If your problem is with window-start, then the reason for that is
simple: lwarn pops up the *Warnings* buffer, so the call to
window-start returns the value for that buffer, not for the "example"
buffer.  If, after running the recipe, you do

  C-x b RET
  M-: (window-start) RET

you will see that window-start in "example" is 11, as you expect.

So I see no bug here.

> (Also obviously, I can not use a normal print/message, when
> 'investigating' redisplay issues)

Of course, you can: use 'message', and then look in the *Messages*
buffer.