Subject: Re: bug#74924: 29.3; Buffer showing manpage jumps back to beginning

From: Juri Linkov <[email-masked]>
Date: Thu, 09 Jan 2025 09:40:44 +0200

>> However, before pushing the patch, let's solve another problem
>> that the manpage window jumps back to the beginning
>> even on a window system.  Here is the reproducible test case:
>>
>> 1. emacs -Q
>> 2. M-x man RET man RET
>> 3. C-M-v (scroll-other-window)
>> 4. Reduce the width of the frame
>> 5. manpage window jumps back to the beginning
>
> Why does it do that?  I can try to find out by myself but I hope you
> already know better.

After resizing the frame, 'man' have to regenerate the buffer's contents
with new width.

>> So unless Martin has objections, I will also change
>> 'with-current-buffer' to 'with-selected-window':
>
> I don't have any objections but we'd have to say why it is necessary for
> curing the above problem.

I didn't realize that the problem is worse and actually
'with-selected-window' is not much of help.  This is the same
problem how to restore the point position after reverting Dired buffer,
but much worse.  In Dired we can remember a file name under point.
But for the Man buffer we can't even use some context around point
because after regeneration, the text layout changes significantly.

For example, in 'M-x man RET man RET' there is such text:

  The  manual  page associated with each of these arguments

We could remember the context "The  manual  page".  But after
resizing it's split to next line:

                                                    The
 manual page associated with each  of  these  arguments

Ok, need to try using 'window-point-context-use-default-function'
and modify it to ignore whitespace changes in context strings.

But first need to move 'window-point-context-use-default-function'
to the new file lisp/window-x.el after you will push
Pranshu's patch that creates the new file lisp/window-x.el ;-)