comparison lisp/window.el @ 41541:9736d12fa64c

(save-selected-window): No error if saved window is dead.
author Richard M. Stallman <rms@gnu.org>
date Mon, 26 Nov 2001 10:09:56 +0000
parents 9ba7895e6ad2
children 922f0ef2951b
comparison
equal deleted inserted replaced
41540:cbb3e2c07f7a 41541:9736d12fa64c
125 (defun minibuffer-window-active-p (window) 125 (defun minibuffer-window-active-p (window)
126 "Return t if WINDOW (a minibuffer window) is now active." 126 "Return t if WINDOW (a minibuffer window) is now active."
127 (eq window (active-minibuffer-window))) 127 (eq window (active-minibuffer-window)))
128 128
129 (defmacro save-selected-window (&rest body) 129 (defmacro save-selected-window (&rest body)
130 "Execute BODY, then select the window that was selected before BODY." 130 "Execute BODY, then select the window that was selected before BODY.
131 However, if that window has become dead, don't get an error,
132 just refrain from switching to it."
131 `(let ((save-selected-window-window (selected-window))) 133 `(let ((save-selected-window-window (selected-window)))
132 (unwind-protect 134 (unwind-protect
133 (progn ,@body) 135 (progn ,@body)
134 (select-window save-selected-window-window)))) 136 (if (window-live-p save-selected-window-window)
137 (select-window save-selected-window-window)))))
135 138
136 (defun count-windows (&optional minibuf) 139 (defun count-windows (&optional minibuf)
137 "Return the number of visible windows. 140 "Return the number of visible windows.
138 This counts the windows in the selected frame and (if the minibuffer is 141 This counts the windows in the selected frame and (if the minibuffer is
139 to be counted) its minibuffer frame (if that's not the same frame). 142 to be counted) its minibuffer frame (if that's not the same frame).