diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2011-11-20 13:19:01 -0700 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2011-11-21 10:02:39 -0700 |
commit | 3693952e3b36148b9f294a7ccdb361d86a3cdd6f (patch) | |
tree | d0f7ca13589f483963b380a62ce8eb72d137ee06 | |
parent | f312e9a6b39ac7eab3a4e47cdd8c4c6fc261064d (diff) | |
download | org-mode-3693952e3b36148b9f294a7ccdb361d86a3cdd6f.tar.gz |
New option to update intermediate in-buffer results
* lisp/ob-ref.el (org-babel-update-intermediate): New custom variable.
(org-babel-ref-resolve): Optionally update the in-buffer results of
code blocks which are evaluated to resolve references.
-rw-r--r-- | lisp/ob-ref.el | 7 | ||||
-rw-r--r-- | testing/lisp/test-ob.el | 27 |
2 files changed, 33 insertions, 1 deletions
diff --git a/lisp/ob-ref.el b/lisp/ob-ref.el index 0714087..0ce5e86 100644 --- a/lisp/ob-ref.el +++ b/lisp/ob-ref.el @@ -66,6 +66,9 @@ (defvar org-babel-ref-split-regexp "[ \f\t\n\r\v]*\\(.+?\\)[ \f\t\n\r\v]*=[ \f\t\n\r\v]*\\(.+\\)[ \f\t\n\r\v]*") +(defcustom org-babel-update-intermediate nil + "Update the in-buffer results of code blocks executed to resolve references.") + (defun org-babel-ref-parse (assignment) "Parse a variable ASSIGNMENT in a header argument. If the right hand side of the assignment has a literal value @@ -189,7 +192,9 @@ the variable." (table (org-babel-read-table)) (list (org-babel-read-list)) (file (org-babel-read-link)) - (source-block (org-babel-execute-src-block nil nil params)) + (source-block (org-babel-execute-src-block + nil nil (if org-babel-update-intermediate + nil params))) (lob (org-babel-execute-src-block nil lob-info params)) (id (org-babel-ref-headline-body))))) diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el index 47d3b16..de66a97 100644 --- a/testing/lisp/test-ob.el +++ b/testing/lisp/test-ob.el @@ -504,6 +504,33 @@ on two lines " (should (= 10 (org-babel-execute-src-block))))) +(ert-deftest test-ob/org-babel-update-intermediate () + (org-test-with-temp-text "#+name: foo +#+begin_src emacs-lisp + 2 +#+end_src + +#+results: foo +: 4 + +#+begin_src emacs-lisp :var it=foo + (+ it 1) +#+end_src" + (let ((org-babel-update-intermediate nil)) + (goto-char (point-min)) + (org-babel-next-src-block 2) + (should (= 3 (org-babel-execute-src-block))) + (goto-char (point-min)) + (forward-line 6) + (should (looking-at ": 4"))) + (let ((org-babel-update-intermediate t)) + (goto-char (point-min)) + (org-babel-next-src-block 2) + (should (= 3 (org-babel-execute-src-block))) + (goto-char (point-min)) + (forward-line 6) + (should (looking-at ": 2"))))) + (provide 'test-ob) ;;; test-ob ends here |