bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Juri Linkov
Subject: bug#1806: dired-pop-to-buffer in wrong place
Date: Wed, 07 Jan 2009 19:47:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu)

> Usually this worked correctly due to the fact that directory buffers
> were sufficiently high.  But for `pop-up-frames' non-nil addicts this
> was not necessarily the right behavior.
>
> Anyway, I suppose you mean something like
>
> (defun dired-pop-to-buffer (buf)
>   (let* ((split-height-threshold 8)
>        split-width-threshold
>        (buffer (get-buffer-create buf))
>        (window (window--try-to-split-window (selected-window))))
>     (if window
>       (progn
>         (select-window window)
>         (set-window-buffer window buffer))
>       (pop-to-buffer buffer))
>     (when dired-shrink-to-fit
>       (fit-window-to-buffer nil nil 1))))

Thank you, this works almost ideally.  The only problem I've encountered
is that sometimes it resizes existing windows:

    +------------+------------+        +------------+------------+
    |            |            |        |            |            |
    |            |            |        |            |            |
    |   dired    |   other2   |        |   dired    |   other2   |
    |            |            |        |            |            |
    |            |            |        +------------+            |
    |            |            |        | file list  |            |
    |            |            |  ===>  +------------+            |
    +------------+            |        |            |            |
    |            |            |        |            |            |
    |   other1   |            |        |   other1   |            |
    |            |            |        |            |            |
    |            |            |        |            |            |
    +------------+------------+        +------------+------------+

Please notice how the upper border of the lower window (other1)
was moved up.  I think it should keep the existing configuration
and create a new window at the cost of space from the original
dired buffer like this:

    +------------+------------+        +------------+------------+
    |            |            |        |            |            |
    |            |            |        |            |            |
    |   dired    |   other    |        |   dired    |   other    |
    |            |            |        |            |            |
    |            |            |        |            |            |
    |            |            |        +------------+            |
    |            |            |        | file list  |            |
    +------------+            |  ===>  +------------+            |
    |            |            |        |            |            |
    |   other    |            |        |   other    |            |
    |            |            |        |            |            |
    |            |            |        |            |            |
    +------------+------------+        +------------+------------+

As I can see currently `fit-window-to-buffer' always takes space
from the bottom window, but we need it from the top window.

>> 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.
>
> Would the above code handle that?

I believe it would handle these cases.  Maybe it is possible to create
a single function e.g. `pop-to-buffer-below' that will display a new window
below from the current window taking its space.

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]