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.
This commit is contained in:
parent
f312e9a6b3
commit
3693952e3b
2 changed files with 33 additions and 1 deletions
|
@ -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)))))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue