save-selected-window

save-selected-window is a Lisp macro in `window.el'.

(save-selected-window &rest BODY)

Execute BODY, then select the previously selected window.
The value returned is the value of the last form in BODY.

This macro saves and restores the selected window, as well as the
selected window in each frame. If the previously selected window
is no longer live, then whatever window is selected at the end of
BODY remains selected. If the previously selected window of some
frame is no longer live at the end of BODY, that frame's selected
window is left alone.

This macro saves and restores the current buffer, since otherwise
its normal operation could make a different buffer current. The
order of recently selected windows and the buffer list ordering
are not altered by this macro (unless they are altered in BODY).