Subject: Re: bug#32536: displayed width of man pages

From: martin rudalics <[email-masked]>
Date: Mon, 26 Nov 2018 10:32:05 +0100

>> I reported this in bug#32637, please see there.
 >
 > Thanks to Martin, a request in bug#32637 is now implemented and closed.

BTW, I plan to change the behavior of 'window-size-change-functions'
as follows.

(1) Run the buffer-local hook not only once for each buffer per frame
     but for each window showing the buffer.

(2) Run the buffer-local hook with the window as argument instead of
     the frame.

(3) Run the buffer-local hook for changes of the window's body size
     too.

(4) Run the buffer-local hook also when a window has not shown the
     buffer the last time this hook was run.

This way, a function that should be run whenever a window showing a
certain buffer is created/used or changes size is guaranteed to run in
each case and no further checks are needed.

All changes would be strictly based on 'local-variable-p' (and not on
'buffer-local-value') so any calls from 'window-size-change-functions'
in Emacs < 27.1 would remain unaffected.  WDYT?

 > But still this bug#32536 can't be closed because I found an insolvable
 > problem: 'M-x occur' is impossible to use on automatically resized
 > Man-mode buffers: after running 'M-x occur' in a Man buffer, it splits
 > the wide frame horizontally, that changes the width of the Man buffer,
 > that causes window-size-change-functions to run, that starts a new
 > Man process to reformat the Man buffer according to the new width of the
 > Man buffer.  After that, typing RET on all matching lines in the Occur buffer
 > will jump to the beginning of the Man buffer, because reformatting invalidates
 > all markers that point from lines in the Occur buffer to lines in the
 > Man buffer, i.e. typing 'C-u C-x =' on all lines in the Occur buffer
 > displays the same:
 >
 >    There are text properties here:
 >      occur-target         #<marker at 1 in *Man bash*>

So essentially you would have to rerun occur whenever the Man buffer
is reformatted.

Otherwise, I see only one way to handle this.  Before reformatting,
store the context of each marker (in a bookmark-like or diff-like
fashion) and restore the markers from that context.  The matching done
in the restore step would have to identify and ignore "soft" changes
of whitespace.

martin