]> git.eshelyaron.com Git - emacs.git/commitdiff
Rewrite window splitting part of display-buffer so that windows are split evenly.
authorMartin Rudalics <rudalics@gmx.at>
Tue, 16 Nov 2010 15:52:06 +0000 (16:52 +0100)
committerMartin Rudalics <rudalics@gmx.at>
Tue, 16 Nov 2010 15:52:06 +0000 (16:52 +0100)
* window.el (display-buffer-split-window-1)
(display-buffer-split-window): Rewrite so that windows are
always split evenly.

* windows.texi (Displaying Buffers): Mention that if a window is
the only window on its frame it can be split regardless of the
min-height specifier.

doc/lispref/ChangeLog
doc/lispref/windows.texi
lisp/ChangeLog
lisp/window.el

index 8a5a0e15cfdacacfd170115e9b49832a217101ac..a98f73df852ccb9c963e708bcd943c77fa0bfb3a 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-16  Martin Rudalics  <rudalics@gmx.at>
+
+       * windows.texi (Displaying Buffers): Mention that if a window is
+       the only window on its frame it can be split regardless of the
+       min-height specifier.
+
 2010-11-13  Eli Zaretskii  <eliz@gnu.org>
 
        * display.texi (Usual Display): Characters with no fonts are not
index 2b905cc9b170a898e0b0d4ee76af0bdfe269f7cf..0f1cb085cdad68cc6e982d5f706d2abab5222382 100644 (file)
@@ -1897,9 +1897,14 @@ The symbols @code{min-height} and @code{min-width}.  In this case, the
 new window to display the buffer.  An integer number specifies the
 minimum number of lines or columns of the new window.  A floating point
 number gives the minimum fraction of the window's size with respect to
-the frame's root window.  A new window will be made if and only if it
-can be made at least as large as specified by the number.  Reusing a
-window or making a new frame are not affected by these specifiers.
+the frame's root window.
+
+A new window will be made if and only if it can be made at least as
+large as specified by the number.  As a special case, if a window is the
+only window on its frame, it can be split vertically regardless of the
+value specified by the @code{min-height} specifier.  Reusing a window or
+making a new frame are not affected by these specifiers.
+
 
 @item
 The symbol @code{split-unsplittable-frame} with a non-@code{nil}
index f0f60448feb8342433c5368b55f3a24d163097de..e1275419f2bed72723e2dc55a4b30b57e90a33e6 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-16  Martin Rudalics  <rudalics@gmx.at>
+
+       * window.el (display-buffer-split-window-1)
+       (display-buffer-split-window): Rewrite so that windows are
+       always split evenly.
+
 2010-11-15  Martin Rudalics  <rudalics@gmx.at>
 
        * minibuffer.el (minibuffer-completion-help): Don't mark window
index 920ba8fd7c6129441bddaf4889839eaf5dc8b87f..9b1f8b202d2cdd091e99fa47daf18563cbb14f5c 100644 (file)
@@ -4789,22 +4789,35 @@ description."
         (old-size
          ;; We either resize WINDOW or its parent.
          (window-total-size (if resize parent window) horflag))
-        (new-size
-         ;; Don't make the new window smaller than MIN-SIZE.
-         (max min-size
-              (if resize
-                  (min (- old-size (window-min-size parent horflag))
-                       (/ old-size
-                          (1+ (window-iso-combinations parent horflag))))
-                (/ old-size 2)))))
-    ;; Check the sizes.
-    (when (if resize
-             (window-sizable-p parent (- new-size) horflag)
-           (window-sizable-p window (- new-size) horflag))
-      ;; We don't call `split-window-vertically' any more here. If for
-      ;; some reason it seems appropriate we can always do so (provided
-      ;; we give it an optional SIDE argument).
-      (split-window window (- new-size) side))))
+        new-size)
+    ;; We don't call split-window-vertically/-horizontally any more
+    ;; here. If for some reason it's needed we can always do so
+    ;; (provided we give it an optional SIDE argument).
+    (cond
+     (resize
+      ;; When we resize a combination, the new window must be at least
+      ;; MIN-SIZE large after the split.
+      (setq new-size
+           (max min-size
+                (min (- old-size (window-min-size parent horflag))
+                     (/ old-size
+                        (1+ (window-iso-combinations parent horflag))))))
+      (when (window-sizable-p parent (- new-size) horflag)
+       (split-window window (- new-size) side)))
+     ((window-live-p window)
+      (setq new-size (/ old-size 2))
+      ;; When WINDOW is live the old _and_ the new window must be at
+      ;; least MIN-SIZE large after the split.
+      (when (and (>= new-size min-size)
+                (window-sizable-p window (- new-size) horflag))
+       ;; Do an even split to make Stepan happy.
+       (split-window window nil side)))
+     (t
+      ;; When WINDOW is internal the new window must be at least
+      ;; MIN-SIZE large after the split.
+      (setq new-size (max min-size (/ old-size 2)))
+      (when (window-sizable-p window (- new-size) horflag)
+       (split-window window (- new-size) side))))))
 
 (defun display-buffer-split-window (window &optional side specifiers)
   "Split WINDOW in a way suitable for `display-buffer'.
@@ -4816,35 +4829,37 @@ list of buffer display specifiers, see the documentation of
 Return the new window, nil if it could not be created."
   (let ((min-height (cdr (assq 'min-height specifiers)))
        (min-width (cdr (assq 'min-width specifiers)))
-       (root-height (window-total-height
-                     (frame-root-window (window-frame window))))
-       (root-width (window-total-width
-                     (frame-root-window (window-frame window))))
        size)
     ;; Normalize min-height and min-width, we might need both.
     (setq min-height
+         ;; If min-height is specified, it can be as small as
+         ;; `window-safe-min-height'.
          (cond
           ((and (integerp min-height)
-                ;; If min-height is specified, it can be as small
-                ;; `window-safe-min-height'.
                 (>= min-height window-safe-min-height))
            min-height)
           ((and (floatp min-height)
                 (<= min-height 1)
-                (let ((height (round (* min-height root-height))))
+                (let* ((root-height (window-total-height
+                                     (frame-root-window
+                                      (window-frame window))))
+                       (height (round (* min-height root-height))))
                   (when (>= height window-safe-min-height)
                     height))))
           (t window-min-height)))
     (setq min-width
+         ;; If min-width is specified, it can be as small as
+         ;; `window-safe-min-width'.
          (cond
           ((and (integerp min-width)
-                ;; If min-width is specified, it can be as small
-                ;; `window-safe-min-width'.
                 (>= min-width window-safe-min-width))
            min-width)
           ((and (floatp min-width)
                 (<= min-width 1)
-                (let ((width (round (* min-width root-width))))
+                (let* ((root-width (window-total-width
+                                    (frame-root-window
+                                     (window-frame window))))
+                       (width (round (* min-width root-width))))
                   (when (>= width window-safe-min-width)
                     width))))
           (t window-min-width)))
@@ -4857,12 +4872,12 @@ Return the new window, nil if it could not be created."
        (and (memq side '(nil left right))
             (display-buffer-split-window-1
              window (or side 'right) min-width))
-       ;; If WINDOW is the root window of its frame, try once more
-       ;; splitting vertically, disregarding the min-height specifier
-       ;; this time.  This was the old behavior and there's probably no
-       ;; convincing reason to change it.
+       ;; If WINDOW is live and the root window of its frame, try once
+       ;; more splitting vertically, disregarding the min-height
+       ;; specifier this time and using `window-min-height' instead.
        (and (memq side '(nil above below))
-            (< window-min-height min-height)
+            (<= window-min-height min-height)
+            (window-live-p window)
             (eq window (frame-root-window window))
             (display-buffer-split-window-1
              window (or side 'below) window-min-height)))))