summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2010-11-17 17:03:22 -0700
committerEric Schulte <schulte.eric@gmail.com>2010-11-17 17:03:44 -0700
commit97f4c3f9a1bffef82593af25b43a87f0768f3f3c (patch)
tree448284059cba3e94140511edd51829459f2bd34b
parent88947588bc8436b5d36d76d6d24cc5d410ad9962 (diff)
downloadorg-mode-97f4c3f9a1bffef82593af25b43a87f0768f3f3c.tar.gz
fixed (hopefully) error in compiled form of org-babel-map-src-blocks
* lisp/ob.el (org-babel-map-src-blocks): Ensure that the file argument is only evaluated once.
-rw-r--r--lisp/ob.el58
1 files changed, 30 insertions, 28 deletions
diff --git a/lisp/ob.el b/lisp/ob.el
index afb3986..30f54b8 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -780,34 +780,36 @@ body ------------- string holding the body of the code block
beg-body --------- point at the beginning of the body
end-body --------- point at the end of the body"
(declare (indent 1))
- `(let ((visited-p (or (null ,file)
- (get-file-buffer (expand-file-name ,file))))
- (point (point)) to-be-removed)
- (save-window-excursion
- (when ,file (find-file ,file))
- (setq to-be-removed (current-buffer))
- (goto-char (point-min))
- (while (re-search-forward org-babel-src-block-regexp nil t)
- (goto-char (match-beginning 0))
- (let ((full-block (match-string 0))
- (beg-block (match-beginning 0))
- (end-block (match-end 0))
- (lang (match-string 2))
- (beg-lang (match-beginning 2))
- (end-lang (match-end 2))
- (switches (match-string 3))
- (beg-switches (match-beginning 3))
- (end-switches (match-end 3))
- (header-args (match-string 4))
- (beg-header-args (match-beginning 4))
- (end-header-args (match-end 4))
- (body (match-string 5))
- (beg-body (match-beginning 5))
- (end-body (match-end 5)))
- ,@body
- (goto-char end-block))))
- (unless visited-p (kill-buffer to-be-removed))
- (goto-char point)))
+ (let ((tempvar (make-symbol "file")))
+ `(let* ((,tempvar ,file)
+ (visited-p (or (null ,tempvar)
+ (get-file-buffer (expand-file-name ,tempvar))))
+ (point (point)) to-be-removed)
+ (save-window-excursion
+ (when ,tempvar (find-file ,tempvar))
+ (setq to-be-removed (current-buffer))
+ (goto-char (point-min))
+ (while (re-search-forward org-babel-src-block-regexp nil t)
+ (goto-char (match-beginning 0))
+ (let ((full-block (match-string 0))
+ (beg-block (match-beginning 0))
+ (end-block (match-end 0))
+ (lang (match-string 2))
+ (beg-lang (match-beginning 2))
+ (end-lang (match-end 2))
+ (switches (match-string 3))
+ (beg-switches (match-beginning 3))
+ (end-switches (match-end 3))
+ (header-args (match-string 4))
+ (beg-header-args (match-beginning 4))
+ (end-header-args (match-end 4))
+ (body (match-string 5))
+ (beg-body (match-beginning 5))
+ (end-body (match-end 5)))
+ ,@body
+ (goto-char end-block))))
+ (unless visited-p (kill-buffer to-be-removed))
+ (goto-char point))))
(defvar org-file-properties)
(defun org-babel-params-from-properties (&optional lang)