Subject: bug#1806: dired-pop-to-buffer in wrong place

From: Juri Linkov <[email-masked]>
Date: Thu, 06 Oct 2011 02:23:59 +0300

> I assume W2 is showing the Dired buffer in this example?

Yes, W2 is showing the Dired buffer.  This is a clearer picture:

          ______________________________________
         | ____________________________________ |
         ||                                    ||
         ||                                    ||
         ||               Dired                ||
         ||                                    ||
         ||_________________W2_________________||
         | ____________________________________ |
         ||                                    ||
         ||_________________W3_________________||
         |__________________W1__________________|

> If so, the proposed patch has no effect---W2 is split, so W3 is
> between the *Marked Files* buffer and the echo area.

The problem is that currently `fit-window-to-buffer' in
`dired-pop-to-buffer' increases the height of the unrelated window W3
like is shown below:

          ______________________________________
         | ____________________________________ |
         ||               Dired                ||
         ||_________________W2_________________||
         | ____________________________________ |
         ||            *Marked Files*          ||
         ||_________________W4_________________||
         | ____________________________________ |
         ||                                    ||
         ||                                    ||
         ||                                    ||
         ||                                    ||
         ||_________________W3_________________||
         |__________________W1__________________|

This is very ugly.

But when the *Marked Files* window is created when `window-nest' is t, then
`fit-window-to-buffer' doesn't enlarge the unrelated window W3 since
a new internal window W5 forces it to resize the Dired window W2:

          ______________________________________
         | ____________________________________ |
         || __________________________________ ||
         |||                                  |||
         |||              Dired               |||
         |||________________W2________________|||
         || __________________________________ ||
         |||           *Marked Files*         |||
         |||________________W4________________|||
         ||_________________W5_________________||
         | ____________________________________ |
         ||                                    ||
         ||_________________W3_________________||
         |__________________W1__________________|

Unless there is a way to tell `fit-window-to-buffer' to change the height
of the upper window instead of the lower window, setting `window-nest' to t
can fix `dired-pop-to-buffer' to not resize other unrelated windows.