Function: org-babel--expand-body

org-babel--expand-body is a byte-compiled function defined in ob-core.el.gz.

Signature

(org-babel--expand-body INFO)

Documentation

Expand noweb references in src block and remove any coderefs.

The src block is defined by its INFO, as returned by org-babel-get-src-block-info.

This function uses the :eval context for noweb expansion because it is called when code needs to be evaluated, either by org-babel-execute-src-block or org-babel-confirm-evaluate. The :eval context is appropriate even during export or tangling when the code block needs to be evaluated to generate results. It is distinct from the :export and :tangle contexts which are used when generating the source code body for display in exported documents or tangled files.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ob-core.el.gz
(defun org-babel--expand-body (info)
  "Expand noweb references in src block and remove any coderefs.
The src block is defined by its INFO, as returned by
`org-babel-get-src-block-info'.

This function uses the :eval context for noweb expansion because it is
called when code needs to be evaluated, either by
`org-babel-execute-src-block' or `org-babel-confirm-evaluate'.  The :eval
context is appropriate even during export or tangling when the code block
needs to be evaluated to generate results.  It is distinct from the :export
and :tangle contexts which are used when generating the source code body for
display in exported documents or tangled files."
  (let ((coderef (nth 6 info))
	(expand
	 (if (org-babel-noweb-p (nth 2 info) :eval)
	     (org-babel-expand-noweb-references info nil :eval)
	   (nth 1 info))))
    (if (not coderef) expand
      (replace-regexp-in-string
       (org-src-coderef-regexp coderef) "" expand nil nil 1))))