Function: with-current-buffer

with-current-buffer is a macro defined in subr.el.gz.

Signature

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

Documentation

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.

Other relevant functions are documented in the buffer group.

Probably introduced at or before Emacs version 20.1.

Shortdoc

;; buffer
(with-current-buffer buffer (buffer-size))
    -> [it depends]

Source Code

;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defmacro 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'."
  (declare (indent 1) (debug t))
  `(save-current-buffer
     (set-buffer ,buffer-or-name)
     ,@body))