1

I want to use the noweb style references in Emacs org for literate programming.

Consider the following working code.

#+NAME:Header
#+BEGIN_SRC c++
#include <iostream>
#+END_SRC


Blah blah


#+BEGIN_SRC c++ :tangle test.cpp :noweb yes
<<Header>>
int main (void)
{
   std::cout << "Hello World" << std::endl;
}
#+END_SRC

I don't want to have to specify :noweb yes every time to expand noweb references since I will always be expanding them by default. How do I change my .emacs file to tell org mode this?

3

There's an example for doing just what you are asking in the Org Manual:

https://orgmode.org/manual/System_002dwide-header-arguments.html#System_002dwide-header-arguments

Here it is for convenience:

This example sets :noweb header arguments to yes, which makes Org expand :noweb references by default.

 (setq org-babel-default-header-args
      (cons '(:noweb . "yes")
            (assq-delete-all :noweb org-babel-default-header-args)))
1

you can either set a global property on the top of the org file:

#+PROPERTY: header-args :noweb yes

or you can set a "tree node" property at any node level that is a parent of your src block:

* Parent Node
 :PROPERTIES:
 :header-args: :noweb yes
 :END:

Big warning: if you will want to add more of such properties either add them on the same line:

#+PROPERTY: header-args :noweb yes :result output
* Parent Node
 :PROPERTIES:
 :header-args: :noweb yes :result output
 :END:

or use concatenation to accumulate your values (otherwise your property value will equal to the last entry:

#+PROPERTY: header-args :noweb yes 
#+PROPERTY: header-args+ :result output
* Parent Node
 :PROPERTIES:
 :header-args: :noweb yes 
 :header-args+: :result output
 :END:

Notice the use of + sign in order to concatenate and not overwrite

0

Try setq org-babel-default-header-args.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.