[Top][All Lists]

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

bug#32825: 27.0.50; Deterministic window management

From: martin rudalics
Subject: bug#32825: 27.0.50; Deterministic window management
Date: Tue, 04 Dec 2018 09:32:37 +0100

> Another reason why this urgently needs to be fixed using
> 'display-buffer-below-selected' with 'window-height' is that
> for example visiting a gpg file that fails to decrypt displays
> the *Backtrace* buffer with (file-error "Opening input file" "Can't decrypt"
> in another window that hides another essential buffer *Error*
> (with explanation of the error raised while decrypting)
> displayed in the same window.  But using 'display-buffer-below-selected'
> both essential buffers will be displayed in separate windows.

So what should we do?  I earlier proposed a 'min-height' entry like in
the code below.  Would that suffice?  If so, would we use the same for
'display-buffer-pop-up-window' and 'display-buffer-at-bottom'?  Should
we check the window below (if we "use" but do not "reuse" it) if it's
high enough?  I think we should provide exact semantics for any such
'min-height' entry so we can easily tell which action functions should
check it.

(defun display-buffer-below-selected (buffer alist)
  "Try displaying BUFFER in a window below the selected window.
If there is a window below the selected one and that window
already displays BUFFER, use that window.  Otherwise, try to
create a new window below the selected one and show BUFFER there.
If that attempt fails as well and there is a non-dedicated window
below the selected one, use that window."
  (let ((min-height (cdr (assq 'min-height alist)))
    (or (and (setq window (window-in-direction 'below))
         (eq buffer (window-buffer window))
         (window--display-buffer buffer window 'reuse alist))
    (and (not (frame-parameter nil 'unsplittable))
         (or (not (numberp min-height))
         (window-sizable-p nil (- min-height)))
         (let ((split-height-threshold 0)
           (setq window (window--try-to-split-window
                             (selected-window) alist)))
          buffer window 'window alist display-buffer-mark-dedicated))
    (and (setq window (window-in-direction 'below))
         (not (window-dedicated-p window))
          buffer window 'reuse alist display-buffer-mark-dedicated)))))


reply via email to

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