From db0e815a4cee691bdd83dc14efecfd87c864b455 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 25 Jan 2011 09:15:06 -0700 Subject: [PATCH 1/2] ob: fixed issue with ":results replace org" * lisp/ob.el (org-babel-result-end): Now recognizes "#+begin_org" blocks for removal. --- lisp/ob.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob.el b/lisp/ob.el index 66563b0e0..24bccd49b 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -1547,7 +1547,7 @@ code ---- the results are extracted in the syntax of the source (t (let ((case-fold-search t) (blocks-re (regexp-opt - (list "latex" "html" "example" "src" "result")))) + (list "latex" "html" "example" "src" "result" "org")))) (if (looking-at (concat "[ \t]*#\\+begin_" blocks-re)) (progn (re-search-forward (concat "[ \t]*#\\+end_" blocks-re) nil t) (forward-char 1)) From 39c982eb494cbbc73717ab5b41be6d1c7e0be183 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Tue, 25 Jan 2011 10:15:47 -0700 Subject: [PATCH 2/2] ob: ob-exec-buf and ob-exec-tree now eval inline code blocks as well * lisp/ob.el (org-babel-map-inline-src-blocks): Macro for executing code in each inline code block. (org-babel-execute-buffer): Executes inline code blocks as well as regular code blocks. --- lisp/ob.el | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lisp/ob.el b/lisp/ob.el index 24bccd49b..b9b852082 100644 --- a/lisp/ob.el +++ b/lisp/ob.el @@ -653,6 +653,28 @@ end-body --------- point at the end of the body" (unless visited-p (kill-buffer to-be-removed)) (goto-char point)))) +;;;###autoload +(defmacro org-babel-map-inline-src-blocks (file &rest body) + "Evaluate BODY forms on each inline source-block in FILE. +If FILE is nil evaluate BODY forms on source blocks in current +buffer." + (declare (indent 1)) + (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-inline-src-block-regexp nil t) + (goto-char (match-beginning 1)) + (save-match-data ,@body) + (goto-char (match-end 0)))) + (unless visited-p (kill-buffer to-be-removed)) + (goto-char point)))) + ;;;###autoload (defun org-babel-execute-buffer (&optional arg) "Execute source code blocks in a buffer. @@ -662,6 +684,8 @@ the current buffer." (org-babel-eval-wipe-error-buffer) (org-save-outline-visibility t (org-babel-map-src-blocks nil + (org-babel-execute-src-block arg)) + (org-babel-map-inline-src-blocks nil (org-babel-execute-src-block arg)))) ;;;###autoload