more efficient org-babel-with-temp-filebuffer

* lisp/ob-tangle.el (org-babel-with-temp-filebuffer): Don't execute
  macro argument multiple times.
This commit is contained in:
Eric Schulte 2012-08-03 13:33:31 -06:00
parent 62bf9cace0
commit 1952afa6ed

View file

@ -122,13 +122,15 @@ represented in the file."
`progn', then kill the FILE buffer returning the result of
evaluating BODY."
(declare (indent 1))
(let ((temp-result (make-symbol "temp-result"))
(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-result ,temp-file
(,visited-p (get-file-buffer ,file)))
(org-babel-find-file-noselect-refresh ,file)
(setf ,temp-file (get-file-buffer ,file))
`(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))