with-selected-frame

with-selected-frame is a Lisp macro in `subr.el'.

(with-selected-frame FRAME &rest BODY)

Execute the forms in BODY with FRAME as the selected frame.
The value returned is the value of the last form in BODY.

This macro saves and restores the selected frame, and changes the
order of neither the recently selected windows nor the buffers in
the buffer list.