From 991ce473781bbd487165287265524df80811900f Mon Sep 17 00:00:00 2001 From: "Richard M. Stallman" Date: Mon, 23 Dec 2002 17:57:12 +0000 Subject: (save-selected-window): Save and restore selected windows of all frames. --- lisp/window.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lisp/window.el') diff --git a/lisp/window.el b/lisp/window.el index 98d5f9963f1..bacd9161ea5 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -31,11 +31,20 @@ (defmacro save-selected-window (&rest body) "Execute BODY, then select the window that was selected before BODY. -However, if that window has become dead, don't get an error, -just refrain from switching to it." - `(let ((save-selected-window-window (selected-window))) +Also restore the selected window of each frame as it was at the start +of this construct. +However, if a window has become dead, don't get an error, +just refrain from reselecting it." + `(let ((save-selected-window-window (selected-window)) + (save-selected-window-alist + (mapcar (lambda (frame) (list frame (frame-selected-window frame))) + (frame-list)))) (unwind-protect (progn ,@body) + (dolist (elt save-selected-window-alist) + (and (frame-live-p (car elt)) + (window-live-p (cadr elt)) + (set-frame-selected-window (car elt) (cadr elt)))) (if (window-live-p save-selected-window-window) (select-window save-selected-window-window))))) -- cgit v1.2.1