erc-with-selected-window

erc-with-selected-window is an alias for `with-selected-window' in `erc-compat.el'.

(erc-with-selected-window WINDOW &rest BODY)

Execute the forms in BODY with WINDOW as the 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 of each frame. It does not change the order of
recently selected windows. 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. If the selected window is no
longer live, then whatever window is selected at the end of BODY
remains selected.

This macro uses `save-current-buffer' to save and restore the
current buffer, since otherwise its normal operation could
potentially make a different buffer current. It does not alter
the buffer list ordering.