Subject: Re: bug#23169: 24.5; Inconsistent text reflow in man pages depending on window configuration

From: martin rudalics <[email-masked]>
Date: Fri, 01 Apr 2016 18:20:36 +0200

> Thing is I don't know the width of the window that will be used, since in some
 > cases it does not exist yet:
 >
 >    +-----+                   +--+--+
 >    |     |                   |  |  |
 >    |     | -> M-x man man -> |  |  |
 >    |     |                   |  |  |
 >    +-----+                   +--+--+
 >
 > The ideal without breaking the asynchronicity would be to somehow display the
 > new buffer on a window before populating it (display-buffer might or might not
 > reuse a window here), calculate its window's width, set COLUMNS, asynchronously
 > call man to populate the buffer, and then really show the buffer on the previous
 > window.
 >
 > The only problem is that creating a temporary window just to calculate its width
 > could annoy people because the contents won't be shown yet.

We could add a special alist element, say ‘pretend’, to ‘display-buffer’
that would cause the latter to return the size of the window where
BUFFER-OR-NAME would be displayed _without_ creating or touching that
window.  This will work reliably only if the new window

(1) appears on an existing frame (or we know that the window manager
reliably makes new frames just as large as we want them),

(2) is not created by a user-defined action (an action not predefined
in window.el) that does not understand ‘pretend’, and

(3) no window configuration or ‘display-buffer-alist’ related changes
are performed in the period from when the size was calculated until
‘display-buffer’ is called without "pretending".

martin