4

In org-babel, is there a way for checking for missing noweb references <<...>> or for throwing an error if a reference is missing?

For example in the following I have mistyped the name of the referenced code block. Tangling via C-c C-v f then produces an elisp file with <<function-body>> replaced by nothing and reports no error.

#+PROPERTY: header-args :noweb yes :tangle no :exports none The first code block calls all others. #+BEGIN_SRC emacs-lisp :tangle yes (defun test-fn (a b c) "A test function" <<function-body>>) #+END_SRC #+NAME: function-bod #+BEGIN_SRC emacs-lisp (+ a b c) #+END_SRC 

Alternatively, is there a reliable way to make sure I don't type such names incorrectly?

1 Answer 1

2

The behavior you want is controlled by the variable org-babel-noweb-error-all-langs, whose default value is nil. Set it to t (e.g. via (setq org-babel-noweb-error-all-langs t) in your init file), and unresolvable noweb references will raise an error.

3
  • Very good. Is this a new feature? It is a pity it is not documented in the info file. Commented Aug 16, 2016 at 14:19
  • I can't speak to the age of the feature; it has probably been there a while. It wasn't hard to discover via source diving, but I agree that it would ideally be documented; perhaps you'll submit a patch. Commented Aug 16, 2016 at 14:28
  • I had tried diving in to the sources, but only really looked in ob-tangle.el. It turns out this is in ob-core. The git sources tell us this was introduced in June 2014, whereas org-babel-noweb-error-langs has been there from the beginning. I'll seriously consider sending a documentation patch. Commented Aug 17, 2016 at 7:42

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.