forked from mirrors/org-mode
Merge branch 'maint' into master
This commit is contained in:
commit
d4f48821c1
|
@ -239,9 +239,7 @@ should be asked whether to allow evaluation."
|
|||
(funcall org-confirm-babel-evaluate
|
||||
;; Language, code block body.
|
||||
(nth 0 info)
|
||||
(if (org-babel-noweb-p headers :eval)
|
||||
(org-babel-expand-noweb-references info)
|
||||
(nth 1 info)))
|
||||
(org-babel--expand-body info))
|
||||
org-confirm-babel-evaluate))))
|
||||
(cond
|
||||
(noeval nil)
|
||||
|
@ -636,6 +634,17 @@ a list with the following pattern:
|
|||
(setf (nth 2 info) (org-babel-generate-file-param name (nth 2 info)))
|
||||
info))))
|
||||
|
||||
(defun org-babel--expand-body (info)
|
||||
"Expand noweb references in body and remove any coderefs."
|
||||
(let ((coderef (nth 6 info))
|
||||
(expand
|
||||
(if (org-babel-noweb-p (nth 2 info) :eval)
|
||||
(org-babel-expand-noweb-references info)
|
||||
(nth 1 info))))
|
||||
(if (not coderef) expand
|
||||
(replace-regexp-in-string
|
||||
(org-src-coderef-regexp coderef) "" expand nil nil 1))))
|
||||
|
||||
;;;###autoload
|
||||
(defun org-babel-execute-src-block (&optional arg info params)
|
||||
"Execute the current source code block.
|
||||
|
@ -681,17 +690,7 @@ block."
|
|||
((org-babel-confirm-evaluate info)
|
||||
(let* ((lang (nth 0 info))
|
||||
(result-params (cdr (assq :result-params params)))
|
||||
;; Expand noweb references in BODY and remove any
|
||||
;; coderef.
|
||||
(body
|
||||
(let ((coderef (nth 6 info))
|
||||
(expand
|
||||
(if (org-babel-noweb-p params :eval)
|
||||
(org-babel-expand-noweb-references info)
|
||||
(nth 1 info))))
|
||||
(if (not coderef) expand
|
||||
(replace-regexp-in-string
|
||||
(org-src-coderef-regexp coderef) "" expand nil nil 1))))
|
||||
(body (org-babel--expand-body info))
|
||||
(dir (cdr (assq :dir params)))
|
||||
(mkdirp (cdr (assq :mkdirp params)))
|
||||
(default-directory
|
||||
|
|
|
@ -1955,6 +1955,26 @@ default-directory
|
|||
(let ((org-confirm-babel-evaluate
|
||||
(lambda (_ body)
|
||||
(not (string-match-p ":bar" body)))))
|
||||
(org-babel-check-confirm-evaluate
|
||||
(org-babel-get-src-block-info))))))
|
||||
;; The code block passed to `org-confirm-babel-evaluate' does not
|
||||
;; include coderefs.
|
||||
(should
|
||||
(equal t
|
||||
(org-test-with-temp-text "
|
||||
#+name: foo
|
||||
#+begin_src emacs-lisp
|
||||
:bar
|
||||
#+end_src
|
||||
|
||||
<point>#+begin_src emacs-lisp :noweb yes
|
||||
#(ref:foo)
|
||||
<<foo>>
|
||||
#+end_src"
|
||||
(let ((org-coderef-label-format "#(ref:%s)")
|
||||
(org-confirm-babel-evaluate
|
||||
(lambda (_ body)
|
||||
(string-match-p "ref:foo" body))))
|
||||
(org-babel-check-confirm-evaluate
|
||||
(org-babel-get-src-block-info)))))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue