branch: externals/ebdb
commit dd675a616cc7e5f6962c683c3fb0b17dd541839d
Author: Eric Abrahamsen <[email protected]>
Commit: Eric Abrahamsen <[email protected]>
Revert changes to pop-up routine.
* ebdb-com.el (ebdb-pop-up-window): I'd changed from `split-window' to
`display-buffer', because the quit configuration was better. But the
splitting behavior was wonky, so I'm changing back. Still have to
solve the quit-restore problem, though.
---
ebdb-com.el | 61 +++++++++++++++++++++++++++++--------------------------------
1 file changed, 29 insertions(+), 32 deletions(-)
diff --git a/ebdb-com.el b/ebdb-com.el
index 20d9515..33eebf9 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -986,50 +986,47 @@ displayed records."
(defun ebdb-pop-up-window (buf &optional select pop)
"Display *EBDB* buffer BUF by popping up a new window.
-POP is typically a two-element list of (window split), where
-WINDOW is the window to be split, and SPLIT says to split it by
-how much. SPLIT can be an integer number of lines/columns, or a
-float between 0 and 1. If SPLIT is nil, split 0.5.
+POP is typically a three-element list of (window split
+horiz/vert), where WINDOW is the window to be split, SPLIT says
+to split it by how much, and HORIZ/VERT says whether to split it
+vertically or horizontally. If HORIZ/VERT is nil, split the
+longest way. If SPLIT is nil, split 0.5.
If the whole POP argument is nil, just re-use the current
buffer."
(let* ((split-window (car-safe pop))
(buffer-window (get-buffer-window buf t))
- (horiz/vert (if (and split-window
- (> (window-total-width split-window)
- (window-total-height split-window)))
- 'horiz
- 'vert))
- ;; This is a hack, necessitated by my ignorance about window
- ;; splitting. We were originally using `split-window'
- ;; directly; I changed that because it seemed better to be
- ;; using a higher-level function, and because
- ;; `display-buffer-pop-up-window' sets the `quit-restore'
- ;; window parameter correctly. But it's also too clever, and
- ;; won't split windows on small screens, and we essentially
- ;; don't ever want *EBDB* to reuse an existing window.
- ;; Probably I should just go back to using `split-window',
- ;; and figure out how to manually set `quit-restore'.
- (split-width-threshold (/ split-width-threshold 2))
- (split-height-threshold (/ split-height-threshold 2)))
+ (horiz/vert (or (caddr pop)
+ (if (> (window-total-width split-window)
+ (window-total-height split-window))
+ 'horiz
+ 'vert)))
+ (size (cond ((null pop)
+ nil)
+ ((integerp (cadr pop)))
+ (t
+ (let ((ratio (- 1 (or (cadr pop) 0.5)))
+ (dimension (max (window-total-width split-window)
+ (window-total-height
split-window))))
+ (round (* dimension ratio)))))))
+
(cond (buffer-window
;; It's already visible, re-use it.
- nil)
- ((null pop)
+ (or (null select)
+ (select-window buffer-window)))
+ ((and (null split-window) (null size))
;; Not splitting, but buffer isn't visible, just take up
;; the whole window.
(set-window-buffer (selected-window) buf)
- (setq buffer-window (get-buffer-window buf t))
- (display-buffer-record-window 'reuse buffer-window buf))
+ (setq buffer-window (get-buffer-window buf t)))
(t
;; Otherwise split.
- (setq buffer-window
- (display-buffer buf
- `(display-buffer-pop-up-window
- . ((,(if (eql horiz/vert 'vert)
- 'window-height
- 'window-width)
- . ,(nth 1 pop))))))))
+ (setq buffer-window (split-window split-window size
+ (if (eql horiz/vert 'vert)
+ 'below
+ 'right)))
+ (set-window-buffer buffer-window buf)))
+ (display-buffer-record-window 'window buffer-window buf)
(when select
(select-window buffer-window))))