emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/ebdb a19ff0a 168/350: Simplify pop-up window splitting


From: Eric Abrahamsen
Subject: [elpa] externals/ebdb a19ff0a 168/350: Simplify pop-up window splitting
Date: Mon, 14 Aug 2017 11:46:29 -0400 (EDT)

branch: externals/ebdb
commit a19ff0a0088dec7a79f0c83c45a2b06c7a694314
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    Simplify pop-up window splitting
    
    * ebdb-com.el (ebdb-pop-up-window): Use `display-buffer' with
      `display-buffer-pop-up-window' rather than `split-window'.  This is
      a bit of an experiment -- doing it this way means we're no longer
      able to specify horizontal vs vertical splitting, and instead rely
      on Emacs to DTRT.  The upside is that Emacs will DTRT, and the
      resulting buffers are easier to use (the quit configuration is set
      correctly, mostly).
---
 ebdb-com.el | 45 ++++++++++++++++++---------------------------
 ebdb-mua.el | 14 ++++++--------
 2 files changed, 24 insertions(+), 35 deletions(-)

diff --git a/ebdb-com.el b/ebdb-com.el
index a342f85..a076b56 100644
--- a/ebdb-com.el
+++ b/ebdb-com.el
@@ -964,47 +964,38 @@ 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 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.
+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.
 
 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 (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)))))))
+        (horiz/vert (if (> (window-total-width split-window)
+                           (window-total-height split-window))
+                        'horiz
+                      'vert)))
 
     (cond (buffer-window
           ;; It's already visible, re-use it.
-          (or (null select)
-              (select-window buffer-window)))
+          nil)
          ((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)))
+          (setq buffer-window (get-buffer-window buf t))
+          (display-buffer-record-window 'reuse buffer-window buf))
          (t
           ;; Otherwise split.
-          (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)
+          (setq buffer-window
+                (display-buffer buf
+                                `(display-buffer-pop-up-window
+                                  . ((,(if (eql horiz/vert 'vert)
+                                           'window-height
+                                         'window-width)
+                                      . ,(nth 1 pop))))))))
     (when select
       (select-window buffer-window))))
 
diff --git a/ebdb-mua.el b/ebdb-mua.el
index d132e32..0422ca2 100644
--- a/ebdb-mua.el
+++ b/ebdb-mua.el
@@ -1096,14 +1096,12 @@ Dispatches on the value of major-mode."
   "Return a spec for how to pop up a window on an *EBDB* buffer.
 
 This generic function dispatches on the current value of
-major-mode.  The return value should be a three-element list
-of (window split horiz/vert), in which WINDOW is the window to
-split, SPLIT is either an integer, specifying number of
-rows/columns, or a float specifying what percentage of window
-real estate the pop-up should occupy, and HORIZ-P is 'horiz if
-the window should be split horizontally, 'vert for vertically,
-and nil to split depending on the dimensions of the current
-window.
+major-mode.  The return value should be a two-element list
+of (window split), in which WINDOW is the window to split, and
+SPLIT is either an integer, specifying number of rows/columns, or
+a float specifying what percentage of window real estate the
+pop-up should occupy.  SPLIT can also be nil, in which case the
+window will probably take up half the available space.
 
 Alternately, the return value can be nil, which means continue
 using the current window.")



reply via email to

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