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

From: Juri Linkov <[email-masked]>
Date: Wed, 07 Jan 2009 14:09:35 +0200

>> I can't image a situation when someone will want to display a narrow
>> window on a full-height side window.  At least I think currently we should
>> restore the old behavior when these commands displayed a narrow window
>> below the original window instead of a side window.
>
> I did this for `dired-pop-to-buffer'.

Thanks, it now works for the one-window configuration.

However, when windows are already split horizontally,
it still doesn't work like it always worked by displaying
a small window below.  As you can see in the code removed
from `dired-pop-to-buffer' it used to call `split-window'
explicitly:

(setq w2 (split-window window
		  (max window-min-height
		       (- (window-height window)
			  (1+ (max window-min-height target-lines))))))

We need a new special function in window.el that will do something
similar.

>> I think a general rule of thumb for finding all such cases should be the
>> following: when there is a call to `fit-window-to-buffer' after calling
>> `pop-to-buffer' then split windows vertically because otherwise
>> `fit-window-to-buffer' makes no sense since it adjusts the window height
>> and can't do this on a full-height horizontally split window.
>
> Good suggestion. I found the following candidates:
>
> `Electric-pop-up-window', `ibuffer-confirm-operation-on',
> `disabled-command-function', `proced-send-signal',
> `fancy-startup-screen', `display-time-world', `widget-choose'.
>
> Can someone comment on these?

`proced-send-signal' is a recent change:

2009-01-03  Roland Winkler <[email-masked]>
	* proced.el (proced-send-signal):
        Use fit-window-to-buffer instead of dired-pop-to-buffer.

Roland, maybe we need a general function for both Proced and Dired?

> We might also have to consider windows affected by
> `temp-buffer-resize-mode'.  I'll leave it to Carsten to figure out
> what's best for `org-mode'.
>
> As for `calendar' I share Stefan's POV ...

Sorry, as a user of a wide-screen configuration I can't use
such layout.  Every time I run `calendar' I need manually fix
the layout by typing something like `C-x o C-x 2 C-x o C-x left C-x -'.
This is a real hassle!  For users who don't want a silly tall
mostly empty 70-line window we should have an option like
`dired-shrink-to-fit' to always show a 7-line window.

This layout also works well with the diary buffer:

    +------------+------------+
    |            |            |
    |            |            |
    |   diary    |            |
    |            |            |
    |            |            |
    |            |            |
    |            |            |
    |            |            |
    +------------+            |
    |            |            |
    |  calendar  |            |
    |            |            |
    +------------+------------+

Please see the code in calendar.el that creates such standard layout
for non-wide-screen configurations (i.e. when there is no right window).
I think we should keep exactly the same logic for wide-screen configurations,
i.e. treating the creation of such small low windows as if there is no
existing side window.

-- 
Juri Linkov
http://www.jurta.org/emacs/