From: Tassilo Horn Date: Wed, 18 Jul 2012 10:02:54 +0000 (+0200) Subject: * window.el (split-window-sensibly): Make WINDOW argument X-Git-Tag: emacs-24.2.90~1152 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2dc2a609c584168036fae5196033ffca2a619a9e;p=emacs.git * window.el (split-window-sensibly): Make WINDOW argument optional. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b1455a7816a..d1db5fa3a6b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-07-18 Tassilo Horn + + * window.el (split-window-sensibly): Make WINDOW argument + optional. + 2012-07-18 Chong Yidong * isearch.el (isearch-mode-map): Handle C-x 8 key translations, diff --git a/lisp/window.el b/lisp/window.el index f9adf84fc58..d58fa81a8de 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -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.