erc-with-buffer

erc-with-buffer is a Lisp macro in `erc.el'.

(erc-with-buffer (TARGET [PROCESS]) BODY...)

Execute BODY in the buffer associated with SPEC.

SPEC should have the form

(TARGET [PROCESS])

If TARGET is a buffer, use it. Otherwise, use the buffer
matching TARGET in the process specified by PROCESS.

If PROCESS is nil, use the current `erc-server-process'.
See `erc-get-buffer' for details.

See also `with-current-buffer'.