with-current-buffer

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

(with-current-buffer BUFFER-OR-NAME &rest BODY)

Execute the forms in BODY with BUFFER-OR-NAME temporarily current.
BUFFER-OR-NAME must be a buffer or the name of an existing buffer.
The value returned is the value of the last form in BODY. See
also `with-temp-buffer'.