Function: with-temp-buffer
with-temp-buffer is a macro defined in subr.el.gz.
Signature
(with-temp-buffer &rest BODY)
Documentation
Create a temporary buffer, and evaluate BODY there like progn.
The buffer does not run the hooks kill-buffer-hook,
kill-buffer-query-functions, and buffer-list-update-hook.
See also with-temp-file and with-output-to-string.
Probably introduced at or before Emacs version 20.1.
Source Code
;; Defined in /usr/src/emacs/lisp/subr.el.gz
(defmacro with-temp-buffer (&rest body)
"Create a temporary buffer, and evaluate BODY there like `progn'.
The buffer does not run the hooks `kill-buffer-hook',
`kill-buffer-query-functions', and `buffer-list-update-hook'.
See also `with-temp-file' and `with-output-to-string'."
(declare (indent 0) (debug t))
(let ((temp-buffer (make-symbol "temp-buffer")))
`(let ((,temp-buffer (generate-new-buffer " *temp*" t)))
;; `kill-buffer' can change current-buffer in some odd cases.
(with-current-buffer ,temp-buffer
(unwind-protect
(progn ,@body)
(and (buffer-name ,temp-buffer)
(kill-buffer ,temp-buffer)))))))