Subject: bug#17809: 24.4.50; Completions display

From: martin rudalics <[email-masked]>
Date: Sat, 28 Jun 2014 10:18:02 +0200

> Maybe it would be a good thing to add a new action parameter to
 > `display-buffer' that would be like the existing `quit-function'
 > in `with-current-buffer-window', and will call its body between
 > displaying the buffer and applying final actions alists like
 > (window-height . fit-window-to-buffer)

`display-buffer' has no body and hardly ever will get one.

 > `dired-mark-pop-up' already uses `with-current-buffer-window' that is
 > like `with-temp-buffer-window', but still has the same problem
 > as the screenshot below demonstrates: it inserts the contents
 > to the buffer before displaying it, so it has no way to get the
 > final window dimensions while inserting the contents, and leaves
 > empty columns.
 >
 > It's possible in `dired-mark-pop-up' to move formatting
 > (i.e. the call to `dired-format-columns-of-files')
 > from the BODY arg of `with-current-buffer-window'
 > to its QUIT-FUNCTION arg, and it will fill the empty columns,
 > because the formatting will happen after displaying the buffer.
 >
 > But then (window-height . fit-window-to-buffer) will be called
 > on the empty buffer, that will always produce a small window
 > with 3-lines height.

Then don't do that.  If you want to do both - formatting and fitting -
have QUIT-FUNCTION do that.  So in BODY put the text into the buffer and
in QUIT-FUNCTION first format the text according to what the window size
gives and then try to fit the window to the formatted text.

martin