From: Richard M. Stallman Date: Mon, 23 Dec 2002 17:57:12 +0000 (+0000) Subject: (save-selected-window): Save and restore selected windows of all frames. X-Git-Tag: ttn-vms-21-2-B4~11928 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=991ce473781bbd487165287265524df80811900f;p=emacs.git (save-selected-window): Save and restore selected windows of all frames. --- 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)))))