diff options
| author | Richard M. Stallman | 1995-03-22 16:57:58 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-03-22 16:57:58 +0000 |
| commit | 82e6d8cb34d547a56945c539ada22be8533b7fb1 (patch) | |
| tree | 0e3c9c887614af21e7daa2369669cff3c203244e | |
| parent | b1aa6cb3446f57ed7f586f829edff25b896bf2aa (diff) | |
| download | emacs-82e6d8cb34d547a56945c539ada22be8533b7fb1.tar.gz emacs-82e6d8cb34d547a56945c539ada22be8533b7fb1.zip | |
(one-window-p, walk-windows, minibuffer-window-active-p): Functions moved here.
| -rw-r--r-- | lisp/window.el | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/lisp/window.el b/lisp/window.el index a0fcb130ff9..d760b28830d 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -22,6 +22,70 @@ | |||
| 22 | 22 | ||
| 23 | ;;; Code: | 23 | ;;; Code: |
| 24 | 24 | ||
| 25 | ;;;; Window tree functions. | ||
| 26 | |||
| 27 | (defun one-window-p (&optional nomini all-frames) | ||
| 28 | "Returns non-nil if the selected window is the only window (in its frame). | ||
| 29 | Optional arg NOMINI non-nil means don't count the minibuffer | ||
| 30 | even if it is active. | ||
| 31 | |||
| 32 | The optional arg ALL-FRAMES t means count windows on all frames. | ||
| 33 | If it is `visible', count windows on all visible frames. | ||
| 34 | ALL-FRAMES nil or omitted means count only the selected frame, | ||
| 35 | plus the minibuffer it uses (which may be on another frame). | ||
| 36 | If ALL-FRAMES is neither nil nor t, count only the selected frame." | ||
| 37 | (let ((base-window (selected-window))) | ||
| 38 | (if (and nomini (eq base-window (minibuffer-window))) | ||
| 39 | (setq base-window (next-window base-window))) | ||
| 40 | (eq base-window | ||
| 41 | (next-window base-window (if nomini 'arg) all-frames)))) | ||
| 42 | |||
| 43 | (defun walk-windows (proc &optional minibuf all-frames) | ||
| 44 | "Cycle through all visible windows, calling PROC for each one. | ||
| 45 | PROC is called with a window as argument. | ||
| 46 | |||
| 47 | Optional second arg MINIBUF t means count the minibuffer window even | ||
| 48 | if not active. MINIBUF nil or omitted means count the minibuffer iff | ||
| 49 | it is active. MINIBUF neither t nor nil means not to count the | ||
| 50 | minibuffer even if it is active. | ||
| 51 | |||
| 52 | Several frames may share a single minibuffer; if the minibuffer | ||
| 53 | counts, all windows on all frames that share that minibuffer count | ||
| 54 | too. Therefore, when a separate minibuffer frame is active, | ||
| 55 | `walk-windows' includes the windows in the frame from which you | ||
| 56 | entered the minibuffer, as well as the minibuffer window. But if the | ||
| 57 | minibuffer does not count, only windows from WINDOW's frame count. | ||
| 58 | |||
| 59 | Optional third arg ALL-FRAMES t means include windows on all frames. | ||
| 60 | ALL-FRAMES nil or omitted means cycle within the frames as specified | ||
| 61 | above. ALL-FRAMES = `visible' means include windows on all visible frames. | ||
| 62 | ALL-FRAMES = 0 means include windows on all visible and iconified frames. | ||
| 63 | Anything else means restrict to WINDOW's frame." | ||
| 64 | ;; If we start from the minibuffer window, don't fail to come back to it. | ||
| 65 | (if (window-minibuffer-p (selected-window)) | ||
| 66 | (setq minibuf t)) | ||
| 67 | (let* ((walk-windows-start (selected-window)) | ||
| 68 | (walk-windows-current walk-windows-start)) | ||
| 69 | (while (progn | ||
| 70 | (setq walk-windows-current | ||
| 71 | (next-window walk-windows-current minibuf all-frames)) | ||
| 72 | (funcall proc walk-windows-current) | ||
| 73 | (not (eq walk-windows-current walk-windows-start)))))) | ||
| 74 | |||
| 75 | (defun minibuffer-window-active-p (window) | ||
| 76 | "Return t if WINDOW (a minibuffer window) is now active." | ||
| 77 | ;; nil nil means include WINDOW's frame | ||
| 78 | ;; and other frames using WINDOW as minibuffer, | ||
| 79 | ;; and include minibuffer if active. | ||
| 80 | (let ((prev (previous-window window nil nil))) | ||
| 81 | ;; If PREV equals WINDOW, WINDOW must be on a minibuffer-only frame | ||
| 82 | ;; and it's not currently being used. So return nil. | ||
| 83 | (and (not (eq window prev)) | ||
| 84 | (let ((should-be-same (next-window prev nil nil))) | ||
| 85 | ;; If next-window doesn't reverse previous-window, | ||
| 86 | ;; WINDOW must be outside the cycle specified by nil nil. | ||
| 87 | (eq should-be-same window))))) | ||
| 88 | |||
| 25 | (defun count-windows (&optional minibuf) | 89 | (defun count-windows (&optional minibuf) |
| 26 | "Returns the number of visible windows. | 90 | "Returns the number of visible windows. |
| 27 | Optional arg NO-MINI non-nil means don't count the minibuffer | 91 | Optional arg NO-MINI non-nil means don't count the minibuffer |
| @@ -73,7 +137,7 @@ even if it is active." | |||
| 73 | (enlarge-window (- newsize | 137 | (enlarge-window (- newsize |
| 74 | (window-height)))))) | 138 | (window-height)))))) |
| 75 | 'nomini))) | 139 | 'nomini))) |
| 76 | 140 | ||
| 77 | ;;; I think this should be the default; I think people will prefer it--rms. | 141 | ;;; I think this should be the default; I think people will prefer it--rms. |
| 78 | (defvar split-window-keep-point t | 142 | (defvar split-window-keep-point t |
| 79 | "*If non-nil, split windows keeps the original point in both children. | 143 | "*If non-nil, split windows keeps the original point in both children. |
| @@ -133,7 +197,7 @@ No arg means split equally." | |||
| 133 | (and size (< size 0) | 197 | (and size (< size 0) |
| 134 | (setq size (+ (window-width) size))) | 198 | (setq size (+ (window-width) size))) |
| 135 | (split-window nil size t))) | 199 | (split-window nil size t))) |
| 136 | 200 | ||
| 137 | (defun enlarge-window-horizontally (arg) | 201 | (defun enlarge-window-horizontally (arg) |
| 138 | "Make current window ARG columns wider." | 202 | "Make current window ARG columns wider." |
| 139 | (interactive "p") | 203 | (interactive "p") |