aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-03-22 16:57:58 +0000
committerRichard M. Stallman1995-03-22 16:57:58 +0000
commit82e6d8cb34d547a56945c539ada22be8533b7fb1 (patch)
tree0e3c9c887614af21e7daa2369669cff3c203244e
parentb1aa6cb3446f57ed7f586f829edff25b896bf2aa (diff)
downloademacs-82e6d8cb34d547a56945c539ada22be8533b7fb1.tar.gz
emacs-82e6d8cb34d547a56945c539ada22be8533b7fb1.zip
(one-window-p, walk-windows, minibuffer-window-active-p): Functions moved here.
-rw-r--r--lisp/window.el68
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).
29Optional arg NOMINI non-nil means don't count the minibuffer
30even if it is active.
31
32The optional arg ALL-FRAMES t means count windows on all frames.
33If it is `visible', count windows on all visible frames.
34ALL-FRAMES nil or omitted means count only the selected frame,
35plus the minibuffer it uses (which may be on another frame).
36If 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.
45PROC is called with a window as argument.
46
47Optional second arg MINIBUF t means count the minibuffer window even
48if not active. MINIBUF nil or omitted means count the minibuffer iff
49it is active. MINIBUF neither t nor nil means not to count the
50minibuffer even if it is active.
51
52Several frames may share a single minibuffer; if the minibuffer
53counts, all windows on all frames that share that minibuffer count
54too. Therefore, when a separate minibuffer frame is active,
55`walk-windows' includes the windows in the frame from which you
56entered the minibuffer, as well as the minibuffer window. But if the
57minibuffer does not count, only windows from WINDOW's frame count.
58
59Optional third arg ALL-FRAMES t means include windows on all frames.
60ALL-FRAMES nil or omitted means cycle within the frames as specified
61above. ALL-FRAMES = `visible' means include windows on all visible frames.
62ALL-FRAMES = 0 means include windows on all visible and iconified frames.
63Anything 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.
27Optional arg NO-MINI non-nil means don't count the minibuffer 91Optional 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")