aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2008-03-29 23:03:18 +0000
committerJuri Linkov2008-03-29 23:03:18 +0000
commitb0b0ffa3f8460f9b63c0de606e73e4fd4ab816fc (patch)
treecafa0c05ac32137e6f51082a4689c1f6562c8fd5
parentd47a29c1e17e97a9c195027c3f51b27d03a1207c (diff)
downloademacs-b0b0ffa3f8460f9b63c0de606e73e4fd4ab816fc.tar.gz
emacs-b0b0ffa3f8460f9b63c0de606e73e4fd4ab816fc.zip
(split-window-preferred-horizontally): New function.
-rw-r--r--lisp/window.el37
1 files changed, 37 insertions, 0 deletions
diff --git a/lisp/window.el b/lisp/window.el
index ba9a74a1746..eab0f2b27fc 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -614,6 +614,43 @@ The return value is the new, rightmost window."
614 (setq size (+ (window-width) size))) 614 (setq size (+ (window-width) size)))
615 (split-window-save-restore-data (split-window nil size t) old-w))) 615 (split-window-save-restore-data (split-window nil size t) old-w)))
616 616
617(defun split-window-preferred-horizontally (window)
618 "Split WINDOW horizontally or select an appropriate existing window.
619It is called by `display-buffer' to split windows horizontally
620when the option `split-window-preferred-function' is set to \"horizontally\".
621This function tries to match the implementation of vertical splitting
622in `display-buffer' as close as possible but with the logic of
623horizontal splitting. It returns a new window or an appropriate
624existing window if splitting is not eligible."
625 (interactive)
626 ;; If the largest window is wide enough, eligible for splitting,
627 ;; and the only window, split it horizontally.
628 (if (and window
629 (not (frame-parameter (window-frame window) 'unsplittable))
630 (one-window-p (window-frame window))
631 (>= (window-width window) (* 2 window-min-width)))
632 (split-window window nil t)
633 ;; Otherwise, if the LRU window is wide enough, eligible for
634 ;; splitting and selected or the only window, split it horizontally.
635 (setq window (get-lru-window nil t))
636 (if (and window
637 (not (frame-parameter (window-frame window) 'unsplittable))
638 (or (eq window (selected-window))
639 (one-window-p (window-frame window)))
640 (>= (window-width window) (* 2 window-min-width)))
641 (split-window window nil t)
642 ;; Otherwise, if get-lru-window returns nil, try other approaches.
643 (or
644 (get-lru-window nil nil)
645 ;; Try visible frames first.
646 (get-buffer-window (current-buffer) 'visible)
647 (get-largest-window 'visible)
648 ;; If that didn't work, try iconified frames.
649 (get-buffer-window (current-buffer) 0)
650 (get-largest-window 0)
651 ;; As a last resort, make a new frame.
652 (frame-selected-window (funcall pop-up-frame-function))))))
653
617 654
618(defun set-window-text-height (window height) 655(defun set-window-text-height (window height)
619 "Sets the height in lines of the text display area of WINDOW to HEIGHT. 656 "Sets the height in lines of the text display area of WINDOW to HEIGHT.