Function: org-babel-with-temp-filebuffer

org-babel-with-temp-filebuffer is a macro defined in ob-tangle.el.gz.

Signature

(org-babel-with-temp-filebuffer FILE &rest BODY)

Documentation

Open FILE into a temporary buffer execute BODY there like progn, then kill the FILE buffer returning the result of evaluating BODY.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-tangle.el.gz
(defmacro org-babel-with-temp-filebuffer (file &rest body)
  "Open FILE into a temporary buffer execute BODY there like
`progn', then kill the FILE buffer returning the result of
evaluating BODY."
  (declare (indent 1) (debug t))
  (let ((temp-path (make-symbol "temp-path"))
	(temp-result (make-symbol "temp-result"))
	(temp-file (make-symbol "temp-file"))
	(visited-p (make-symbol "visited-p")))
    `(let* ((,temp-path ,file)
	    (,visited-p (get-file-buffer ,temp-path))
	    ,temp-result ,temp-file)
       (org-babel-find-file-noselect-refresh ,temp-path)
       (setf ,temp-file (get-file-buffer ,temp-path))
       (with-current-buffer ,temp-file
	 (setf ,temp-result (progn ,@body)))
       (unless ,visited-p (kill-buffer ,temp-file))
       ,temp-result)))