diff options
| author | Juri Linkov | 2008-03-29 23:03:18 +0000 |
|---|---|---|
| committer | Juri Linkov | 2008-03-29 23:03:18 +0000 |
| commit | b0b0ffa3f8460f9b63c0de606e73e4fd4ab816fc (patch) | |
| tree | cafa0c05ac32137e6f51082a4689c1f6562c8fd5 | |
| parent | d47a29c1e17e97a9c195027c3f51b27d03a1207c (diff) | |
| download | emacs-b0b0ffa3f8460f9b63c0de606e73e4fd4ab816fc.tar.gz emacs-b0b0ffa3f8460f9b63c0de606e73e4fd4ab816fc.zip | |
(split-window-preferred-horizontally): New function.
| -rw-r--r-- | lisp/window.el | 37 |
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. | ||
| 619 | It is called by `display-buffer' to split windows horizontally | ||
| 620 | when the option `split-window-preferred-function' is set to \"horizontally\". | ||
| 621 | This function tries to match the implementation of vertical splitting | ||
| 622 | in `display-buffer' as close as possible but with the logic of | ||
| 623 | horizontal splitting. It returns a new window or an appropriate | ||
| 624 | existing 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. |