comparison lisp/subr.el @ 11087:e3c06f791fd8

(one-window-p, walk-windows, minibuffer-window-active-p): Functions moved to window.el.
author Richard M. Stallman <rms@gnu.org>
date Wed, 22 Mar 1995 16:58:14 +0000
parents 0ecc478ed305
children 67231dca5f32
comparison
equal deleted inserted replaced
11086:22693a280a42 11087:e3c06f791fd8
49 ;; (setq body (or (cdr body) body)))) 49 ;; (setq body (or (cdr body) body))))
50 ;; (list (list 'cons (list 'quote 50 ;; (list (list 'cons (list 'quote
51 ;; (cons 'lambda (cons args body))) 51 ;; (cons 'lambda (cons args body)))
52 ;; 'args)))) 52 ;; 'args))))
53 53
54
55 ;;;; Window tree functions.
56
57 (defun one-window-p (&optional nomini all-frames)
58 "Returns non-nil if the selected window is the only window (in its frame).
59 Optional arg NOMINI non-nil means don't count the minibuffer
60 even if it is active.
61
62 The optional arg ALL-FRAMES t means count windows on all frames.
63 If it is `visible', count windows on all visible frames.
64 ALL-FRAMES nil or omitted means count only the selected frame,
65 plus the minibuffer it uses (which may be on another frame).
66 If ALL-FRAMES is neither nil nor t, count only the selected frame."
67 (let ((base-window (selected-window)))
68 (if (and nomini (eq base-window (minibuffer-window)))
69 (setq base-window (next-window base-window)))
70 (eq base-window
71 (next-window base-window (if nomini 'arg) all-frames))))
72
73 (defun walk-windows (proc &optional minibuf all-frames)
74 "Cycle through all visible windows, calling PROC for each one.
75 PROC is called with a window as argument.
76
77 Optional second arg MINIBUF t means count the minibuffer window even
78 if not active. MINIBUF nil or omitted means count the minibuffer iff
79 it is active. MINIBUF neither t nor nil means not to count the
80 minibuffer even if it is active.
81
82 Several frames may share a single minibuffer; if the minibuffer
83 counts, all windows on all frames that share that minibuffer count
84 too. Therefore, when a separate minibuffer frame is active,
85 `walk-windows' includes the windows in the frame from which you
86 entered the minibuffer, as well as the minibuffer window. But if the
87 minibuffer does not count, only windows from WINDOW's frame count.
88
89 Optional third arg ALL-FRAMES t means include windows on all frames.
90 ALL-FRAMES nil or omitted means cycle within the frames as specified
91 above. ALL-FRAMES = `visible' means include windows on all visible frames.
92 ALL-FRAMES = 0 means include windows on all visible and iconified frames.
93 Anything else means restrict to WINDOW's frame."
94 ;; If we start from the minibuffer window, don't fail to come back to it.
95 (if (window-minibuffer-p (selected-window))
96 (setq minibuf t))
97 (let* ((walk-windows-start (selected-window))
98 (walk-windows-current walk-windows-start))
99 (while (progn
100 (setq walk-windows-current
101 (next-window walk-windows-current minibuf all-frames))
102 (funcall proc walk-windows-current)
103 (not (eq walk-windows-current walk-windows-start))))))
104
105 (defun minibuffer-window-active-p (window)
106 "Return t if WINDOW (a minibuffer window) is now active."
107 ;; nil nil means include WINDOW's frame
108 ;; and other frames using WINDOW as minibuffer,
109 ;; and include minibuffer if active.
110 (let ((prev (previous-window window nil nil)))
111 ;; If PREV equals WINDOW, WINDOW must be on a minibuffer-only frame
112 ;; and it's not currently being used. So return nil.
113 (and (not (eq window prev))
114 (let ((should-be-same (next-window prev nil nil)))
115 ;; If next-window doesn't reverse previous-window,
116 ;; WINDOW must be outside the cycle specified by nil nil.
117 (eq should-be-same window)))))
118 54
119 ;;;; Keymap support. 55 ;;;; Keymap support.
120 56
121 (defun undefined () 57 (defun undefined ()
122 (interactive) 58 (interactive)