* window.el (split-window-sensibly): Make WINDOW argument
authorTassilo Horn <tassilo@member.fsf.org>
Wed, 18 Jul 2012 10:02:54 +0000 (12:02 +0200)
committerTassilo Horn <tassilo@member.fsf.org>
Wed, 18 Jul 2012 10:02:54 +0000 (12:02 +0200)
optional.

lisp/ChangeLog
lisp/window.el

index b1455a7..d1db5fa 100644 (file)
@@ -1,3 +1,8 @@
+2012-07-18  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * window.el (split-window-sensibly): Make WINDOW argument
+       optional.
+
 2012-07-18  Chong Yidong  <cyd@gnu.org>
 
        * isearch.el (isearch-mode-map): Handle C-x 8 key translations,
index f9adf84..d58fa81 100644 (file)
@@ -4475,8 +4475,9 @@ hold:
                      (* 2 (max window-min-height
                                (if mode-line-format 2 1))))))))))
 
-(defun split-window-sensibly (window)
+(defun split-window-sensibly (&optional window)
   "Split WINDOW in a way suitable for `display-buffer'.
+WINDOW defaults to the currently selected window.
 If `split-height-threshold' specifies an integer, WINDOW is at
 least `split-height-threshold' lines tall and can be split
 vertically, split WINDOW into two windows one above the other and
@@ -4506,23 +4507,24 @@ more likely to occur.
 Have a look at the function `window-splittable-p' if you want to
 know how `split-window-sensibly' determines whether WINDOW can be
 split."
-  (or (and (window-splittable-p window)
-          ;; Split window vertically.
-          (with-selected-window window
-            (split-window-below)))
-      (and (window-splittable-p window t)
-          ;; Split window horizontally.
-          (with-selected-window window
-            (split-window-right)))
-      (and (eq window (frame-root-window (window-frame window)))
-          (not (window-minibuffer-p window))
-          ;; If WINDOW is the only window on its frame and is not the
-          ;; minibuffer window, try to split it vertically disregarding
-          ;; the value of `split-height-threshold'.
-          (let ((split-height-threshold 0))
-            (when (window-splittable-p window)
-              (with-selected-window window
-                (split-window-below)))))))
+  (let ((window (or window (selected-window))))
+    (or (and (window-splittable-p window)
+            ;; Split window vertically.
+            (with-selected-window window
+              (split-window-below)))
+       (and (window-splittable-p window t)
+            ;; Split window horizontally.
+            (with-selected-window window
+              (split-window-right)))
+       (and (eq window (frame-root-window (window-frame window)))
+            (not (window-minibuffer-p window))
+            ;; If WINDOW is the only window on its frame and is not the
+            ;; minibuffer window, try to split it vertically disregarding
+            ;; the value of `split-height-threshold'.
+            (let ((split-height-threshold 0))
+              (when (window-splittable-p window)
+                (with-selected-window window
+                  (split-window-below))))))))
 
 (defun window--try-to-split-window (window)
   "Try to split WINDOW.