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?

Andrew Swann
  • 3,436
  • 2
  • 15
  • 43

1 Answers1

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.

Aaron Miller
  • 552
  • 2
  • 12
  • Very good. Is this a new feature? It is a pity it is not documented in the info file. – Andrew Swann Aug 16 '16 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. – Aaron Miller Aug 16 '16 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. – Andrew Swann Aug 17 '16 at 07:42