Subject: Re: dired-pop-to-buffer in wrong place

From: Juri Linkov <[email-masked]>
Date: Fri, 28 Sep 2012 12:38:37 +0300

>> The problem is that it steals space when the upper window is large
>
> ... I suppose you mean "when the upper window is small" here ...

When a window has 30 lines in height, I call it "large" :-)

> IIUC `fit-window-to-buffer' always tried to display as much as possible
> within limits imposed, for example, by `temp-buffer-max-height'.  Can
> you tell me when and where it restricted itself to just some area of the
> frame?

I'll try to provide the exact details:

1. When the Dired window is small (less than 7 lines in height),
   there is no problem because it reuses the lower window.

2. When the Dired window is large (more than 7 lines in height)
   and a list of marked files is small:

2.1. When `window-combination-limit' is nil,
     the result of `dired-mark-pop-up' is horribly ugly
     (when `temp-buffer-resize-mode' is enabled).  But thank you
     `window-combination-limit' is not nil anymore,
     so there is no problem now.

2.2. When `window-combination-limit' is non-nil, the result is still
     bad looking because `fit-window-to-buffer' is missing like in the
     original version of `dired-pop-to-buffer'.  This is a regression.

2.3. When a list of files is too large to fit into split windows, it
     resizes the lower window.  What I misremembered is that actually it
     never tried to avoid resizing the lower window.  Sorry for my amnesia.
     This is not a regression.  Its result looks like when
     `window-combination-limit' is nil, but since a large list of files
     is rarely displayed in Dired, this is a minor problem.

So the main problem that remains is the need to use `fit-window-to-buffer'.
I see three possible variants to fix this:

1. Call `fit-window-to-buffer' directly in `dired-mark-pop-up'.

2. Call `fit-window-to-buffer' in `display-buffer-below-selected'
   using a new action specifier.

3. Enable `temp-buffer-resize-mode'.