mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 18:36:26 +00:00
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
|
@ -66,6 +66,9 @@
|
||||||
(defvar org-babel-ref-split-regexp
|
(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]*")
|
"[ \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)
|
(defun org-babel-ref-parse (assignment)
|
||||||
"Parse a variable ASSIGNMENT in a header argument.
|
"Parse a variable ASSIGNMENT in a header argument.
|
||||||
If the right hand side of the assignment has a literal value
|
If the right hand side of the assignment has a literal value
|
||||||
|
@ -189,7 +192,9 @@ the variable."
|
||||||
(table (org-babel-read-table))
|
(table (org-babel-read-table))
|
||||||
(list (org-babel-read-list))
|
(list (org-babel-read-list))
|
||||||
(file (org-babel-read-link))
|
(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
|
(lob (org-babel-execute-src-block
|
||||||
nil lob-info params))
|
nil lob-info params))
|
||||||
(id (org-babel-ref-headline-body)))))
|
(id (org-babel-ref-headline-body)))))
|
||||||
|
|
|
@ -504,6 +504,33 @@ on two lines
|
||||||
"
|
"
|
||||||
(should (= 10 (org-babel-execute-src-block)))))
|
(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)
|
(provide 'test-ob)
|
||||||
|
|
||||||
;;; test-ob ends here
|
;;; test-ob ends here
|
||||||
|
|
Loading…
Reference in a new issue