# HG changeset patch # User Richard M. Stallman # Date 1040666232 0 # Node ID 7262fd90146aa8d375a43aaa8876cf198f1fbb99 # Parent 78987e4bee15c2ad5a00392b254b2d0b5cfe0ca5 (save-selected-window): Save and restore selected windows of all frames. diff -r 78987e4bee15 -r 7262fd90146a lisp/window.el --- a/lisp/window.el Mon Dec 23 17:54:31 2002 +0000 +++ b/lisp/window.el Mon Dec 23 17:57:12 2002 +0000 @@ -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)))))