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

From: Juri Linkov <[email-masked]>
Date: Tue, 27 Nov 2018 02:01:08 +0200

> 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.

Good, so buffer-local hooks won't need to use walk-windows.

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

Good.  When needed, it's easy to get the frame from the window argument.

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

What might cause these changes?

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

Good, so initial buffer display will be automatically handled as well.

> 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?

This makes better sense.

>>    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.

It's too ad-hoc to find all Occur buffers created from the Man buffer,
and revert all of them.

> 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.

This means additionally to finding all affected Occur buffers like above,
instead of reverting them, perform much more complex processing of
their markers.

It seems a more practical solution is to limit the width of Man buffers
to at least 80 columns by default, so splitting such windows will not
resize their number of columns, so they won't be reverted and reformatted.