aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2017-10-23 09:05:32 +0100
committerJoão Távora2017-11-03 16:13:37 +0000
commit5d34e1b2881caa5743816030c2e9cdcda58e9719 (patch)
tree99f29ab30b1c0b90f33ea397093724914587306e
parent2a973edeacefcabb9fd8024188b7e167f0f9a9b6 (diff)
downloademacs-5d34e1b2881caa5743816030c2e9cdcda58e9719.tar.gz
emacs-5d34e1b2881caa5743816030c2e9cdcda58e9719.zip
Allow split-window-sensibly to split threshold in further edge case
As a fallback, and to avoid creating a frame, split-window-sensibly would previously disregard split-height-threshold if the window to be split is the frame's root window. This change generalizes that: it disregards the threshold if the window to be split is the frame's only _usable_ window (it is either the only one, as before, or all the other windows are dedicated to some buffer and thus cannot be touched). This is required for the fix to bug#28814. * lisp/window.el (split-height-threshold): Adjust doc to match split-window-sensibly. (split-window-sensibly): Also disregard threshold if all other windows are dedicated.
-rw-r--r--lisp/window.el35
1 files changed, 24 insertions, 11 deletions
diff --git a/lisp/window.el b/lisp/window.el
index f87294ceb15..8939e7d589b 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -6465,8 +6465,9 @@ If this is an integer, `split-window-sensibly' may split a window
6465vertically only if it has at least this many lines. If this is 6465vertically only if it has at least this many lines. If this is
6466nil, `split-window-sensibly' is not allowed to split a window 6466nil, `split-window-sensibly' is not allowed to split a window
6467vertically. If, however, a window is the only window on its 6467vertically. If, however, a window is the only window on its
6468frame, `split-window-sensibly' may split it vertically 6468frame, or all the other ones are dedicated,
6469disregarding the value of this variable." 6469`split-window-sensibly' may split it vertically disregarding the
6470value of this variable."
6470 :type '(choice (const nil) (integer :tag "lines")) 6471 :type '(choice (const nil) (integer :tag "lines"))
6471 :version "23.1" 6472 :version "23.1"
6472 :group 'windows) 6473 :group 'windows)
@@ -6573,15 +6574,27 @@ split."
6573 ;; Split window horizontally. 6574 ;; Split window horizontally.
6574 (with-selected-window window 6575 (with-selected-window window
6575 (split-window-right))) 6576 (split-window-right)))
6576 (and (eq window (frame-root-window (window-frame window))) 6577 (and
6577 (not (window-minibuffer-p window)) 6578 ;; If WINDOW is the only usable window on its frame (it is
6578 ;; If WINDOW is the only window on its frame and is not the 6579 ;; the only one or, not being the only one, all the other
6579 ;; minibuffer window, try to split it vertically disregarding 6580 ;; ones are dedicated) and is not the minibuffer window, try
6580 ;; the value of `split-height-threshold'. 6581 ;; to split it vertically disregarding the value of
6581 (let ((split-height-threshold 0)) 6582 ;; `split-height-threshold'.
6582 (when (window-splittable-p window) 6583 (let ((frame (window-frame window)))
6583 (with-selected-window window 6584 (or
6584 (split-window-below)))))))) 6585 (eq window (frame-root-window frame))
6586 (catch 'done
6587 (walk-window-tree (lambda (w)
6588 (unless (or (eq w window)
6589 (window-dedicated-p w))
6590 (throw 'done nil)))
6591 frame)
6592 t)))
6593 (not (window-minibuffer-p window))
6594 (let ((split-height-threshold 0))
6595 (when (window-splittable-p window)
6596 (with-selected-window window
6597 (split-window-below))))))))
6585 6598
6586(defun window--try-to-split-window (window &optional alist) 6599(defun window--try-to-split-window (window &optional alist)
6587 "Try to split WINDOW. 6600 "Try to split WINDOW.