1 #+OPTIONS: H:3 num:nil toc:2 \n:nil @:t ::t |:t ^:{} -:t f:t *:t TeX:t LaTeX:t skip:nil d:(HIDE) tags:not-in-toc
2 #+STARTUP: align fold nodlcheck hidestars oddeven lognotestate hideblocks
3 #+SEQ_TODO: TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
4 #+TAGS: Write(w) Update(u) Fix(f) Check(c)
6 #+AUTHOR: Eric Schulte, Dan Davison
7 #+EMAIL: schulte.eric at gmail dot com, davison at stats dot ox dot ac dot uk
11 # #+INFOJS_OPT: view:content
15 <p>executable source code blocks in org-mode</p>
19 <img src="images/tower-of-babel.png" alt="images/tower-of-babel.png"
20 title="And the Lord said, Behold, the people is one, and they have all one language; and this they begin to do; and now nothing will be restrained from them, which they have imagined to do. Genesis 11:1-9"/>
23 <a href="http://www.flickr.com/photos/23379658@N05/" title=""><b>Martijn Streefkerk</b></a>
36 :CUSTOM_ID: introduction
38 Org-babel is an extension to the very excellent [[http://orgmode.org/][Org-mode]]; an [[http://www.gnu.org/software/emacs/][Emacs]]
39 major mode for doing almost anything with plain text. If you are
40 not familiar with Org-mode please take a moment to read [[http://orgmode.org/][the Org-mode
41 homepage]] before continuing.
43 Org-babel provides the following modifications to [[http://orgmode.org/manual/Literal-examples.html][the existing
44 support]] for blocks of source code examples in the org-mode core.
46 1. Interactive source code execution
47 2. Arguments to source code blocks
48 3. Exportation of source code blocks to files (literate programming)
52 :CUSTOM_ID: getting-started
55 1) Grab the latest code from the git repo at [[http://github.com/eschulte/org-babel/tree/master][github/org-babel]]
57 git clone git://github.com/eschulte/org-babel.git
60 2) Add the following lines to your .emacs, replacing the path as
61 appropriate. A good place to check that things are up and running
62 would the examples in [[* Basic org-babel functionality][Basic org-babel functionality]].
63 #+begin_src emacs-lisp
64 (add-to-list 'load-path "/path/to/org-babel/lisp")
65 (require 'org-babel-init)
68 3) Finally, activate the subset of supported Org-babel languages
69 which you want to be able to execute on your system. As an
70 example, the following activates python, ruby and R. For a full
71 list of languages and notes on their dependencies see the
72 [[#reference-and-documentation][Reference / Documentation]] section below.
73 #+begin_src emacs-lisp
74 (require 'org-babel-python)
75 (require 'org-babel-ruby)
76 (require 'org-babel-R)
78 ;; Once you've activated languages, load the library of babel to
79 ;; make pre-built helper functions available in the languages you will be using.
80 (org-babel-load-library-of-babel)
83 * Basic org-babel functionality
85 :CUSTOM_ID: basic-functionality
87 *** Source code blocks
89 :CUSTOM_ID: source-code-blocks
92 Org-babel is all about *source code blocks* in org mode. These are
93 blocks of code (in whatever language), surrounded by special
94 starting and ending lines. For example, the following is a source
95 block containing [[http://www.ruby-lang.org/][ruby]] code:
98 : "This file was last evaluated on #{Date.today}"
101 If you are unfamiliar with the notion of source code blocks in
102 org-mode, please have a look at the [[http://orgmode.org/manual/Literal-examples.html][relevant manual section]] before
105 Note that above is what the source block looks like in the org-mode
106 file. We had to take [[http://orgmode.org/manual/Literal-examples.html#Literal-examples][special steps]] to make it look that way in the
107 HTML output. Normally, when exported to HTML, source blocks are
108 fontified according to their language, and the begin_src...end_src
109 mark-up is omitted, like this:
112 "This file was last evaluated on #{Date.today}"
115 From now on, if you are viewing the HTML version, you will see the
116 HTML output only. However, much of this document consists of
117 interactive examples, and therefore in order to get a feeling for the
118 mechanics of Org-babel it might make most sense to grab the plain text
120 #+HTML: <a href="org-babel-worg.org">org-babel-worg.org</a>
121 and work through it in Emacs. Alternatively the htmlized
122 version of the plain text of this file at
123 #+HTML: <a href="org-babel-worg.org.html">org-babel-worg.html</a>
124 allows the plain text version to be viewed (non-interactively) in a web browser.
125 *** Source code execution
127 :CUSTOM_ID: source-code-execution
129 For interpreted languages such as shell, python, R, etc, org-babel
130 allows source blocks to be executed: the code is passed to the
131 interpreter and you have control over what is done with the results of
132 excecution. E.g. place point anywhere in the following blocks and use
133 =C-c C-c= to run the code[fn:1]. In the first two cases the code comes
134 first, followed by the results of evlauting the block.
138 "This file was last evaluated on #{Date.today}"
142 : This file was last evaluated on 2009-08-09
144 **** [[http://www.r-project.org/][R]]
145 #+begin_src R :results value
146 matrix(rnorm(6), nrow=2)
150 | 0.496600061063252 | "-1.44355317891110" | 0.106411785870013 |
151 | "-1.81619611674921" | "-1.25542979009380" | 0.00969467528507845 |
153 **** [[http://ditaa.sourceforge.net/][ditaa]]
154 #+begin_src ditaa :file images/blue.png :cmdline -r
165 [[file:images/blue.png]]
167 *** Additional source block syntax
168 Org-babel adds some new syntactical elements to source blocks in
169 org-mode, illustrated here:
171 : #+srcname: source-block-name(arg1=value1, arg2=value2)
172 : #+begin_src language :var1 var1-value :var2 var2-value ...
178 Note the following two new features
179 **** =srcname= with optional arguments
180 The optional =srcname= line allows a name to be given to the
181 source block, together with any arguments to the source block
182 (see [[#arguments-to-source-code-blocks][below]])
183 **** Header arguments
184 An arbitrary series of :variable value pairs can be specified
185 after the language, controlling various aspects of org-babel
186 operation. The available header arguments are documented [[#header-arguments][below.]]
187 *** What happens to the results?
191 Org-babel provides two fundamentally different modes for capturing
192 the results of code evaluation, specified by the =:results= header
194 **** =:results value= (functional mode)
195 This means that the 'result' of code evaluation is defined to be
196 the *value* of the last statement in the block. Thus with this
197 setting, one can view the code block as a function with a return
198 value. And not only can you view it that way, but you can
199 actually use the return value of one source block as input for
200 another (see later). This setting is the default.
202 As an example, consider the following block of python code and its
205 #+begin_src python :results value
207 print("Hello, today's date is %s" % time.ctime())
208 print('Two plus two is')
215 Notice that in functional mode, the output consists of the value of
216 the last statement, and nothing else.
218 **** =:results output= (scripting mode)
219 With this setting, org-babel captures all the text output of the
220 code block and places it in the org buffer. One can think of this
221 as a 'scripting' mode: the code block contains a series of
222 commands, and you get the output of all the commands. Unlike in
223 the 'functional' mode, the code block has no return value. (This
224 mode will be familiar to Sweave users).
226 Now consider the result of evaluating the same source block as
227 before, but under scripting mode.
230 #+begin_src python :results output
232 print("Hello, today's date is %s" % time.ctime())
233 print('Two plus two is')
238 : Hello, today's date is Fri Sep 4 19:49:06 2009
241 Again, we got what we asked for: all the text output (stdout) from
242 python. Since we didn't print the last value (2 + 2), we didn't get it
245 *** Arguments to source code blocks
247 :CUSTOM_ID: arguments-to-source-code-blocks
249 In addition to evaluation of code blocks, org-babel allows them to
250 be parameterised (i.e. have arguments). Thus source code blocks
251 now have the status of *functions*. Arguments to code blocks can
252 be used in both functional and scripting mode.
254 **** Simple example of using a source block as a function
256 First let's look at a very simple example. The following source
257 block defines an org-babel function that will square its input.
264 In the org-mode file that looks like this:
265 : #+srcname: square(x)
271 Now we use the source block:
277 #+resname: square(x=6)
280 **** A more complex example: using an org-table as input
282 In this example we're going to define a function to compute a
283 Fibonacci sequence, and we're going to make it take its input
284 from a table in the org-mode buffer.
286 Here are the inputs for fibonacci-seq:
288 #+tblname: fibonacci-inputs
289 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
290 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
292 in the Org-mode buffer this looks like
293 : #+tblname: fibonacci-inputs
294 : | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
295 : | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
297 [[http://www.gnu.org/software/emacs/manual/elisp.html][Emacs Lisp]] source code
298 #+srcname: fibonacci-seq(fib-inputs=fibonacci-inputs)
299 #+begin_src emacs-lisp
301 (if (or (= n 0) (= n 1))
303 (+ (fibonacci (- n 1)) (fibonacci (- n 2)))))
305 (mapcar (lambda (row)
306 (mapcar #'fibonacci row)) fib-inputs)
309 in the Org-mode buffer this looks like
310 : #+srcname: fibonacci-seq(fib-inputs=fibonacci-inputs)
311 : #+begin_src emacs-lisp
312 : (defun fibonacci (n)
313 : (if (or (= n 0) (= n 1))
315 : (+ (fibonacci (- n 1)) (fibonacci (- n 2)))))
317 : (mapcar (lambda (row)
318 : (mapcar #'fibonacci row)) fib-inputs)
321 Results of Emacs Lisp code evaluation
323 | 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 | 34 | 55 |
324 | 1 | 3 | 8 | 21 | 55 | 144 | 377 | 987 | 2584 | 6765 |
326 * A meta-programming language for org-mode
328 :CUSTOM_ID: meta-programming-language
331 Since information can pass freely between source-code blocks and
332 org-mode tables you can mix and match languages using each language
333 for those tasks to which it is suited. This makes Org-mode files with
334 Org-babel into a kind of meta-functional programming language in which
335 functions from many languages can work together.
337 As an example, lets take some system diagnostics in the shell, and
338 then graph them with R.
341 #+srcname: directories
342 #+begin_src bash :results replace
343 cd ~ && du -sc * |grep -v total
345 2. Results of the shell source code (on my system, grab this org-mode
346 files and try running it on your own)
347 #+resname: directories
349 | 12156104 | "Documents" |
350 | 3482440 | "Downloads" |
351 | 2901720 | "Library" |
353 | 16548024 | "Music" |
355 | 7649472 | "Pictures" |
363 3. R source code (which calls the previous shell source code)
364 #+srcname: directory-pie
365 #+begin_src R :var dirs = directories :session R-pie-example
366 pie(dirs[,1], labels = dirs[,2])
368 4. Results of R code [[file:images/dirs.png]]
370 * Spreadsheet plugins for org-mode in any language
372 :CUSTOM_ID: spreadsheet
375 *NOTE*: Maybe in-addition-to/in-stead-of this example we should do a
376 more traditional "spreadsheet" example with R [Eric]
378 Not only can Org-babel pass entire tables of data to source code
379 blocks (see [[arguments-to-source-code-blocks]]), Org-babel can also be
380 used to call source code blocks from *within* tables using the
381 Org-mode's [[http://orgmode.org/manual/The-spreadsheet.html#The-spreadsheet][existing spreadsheet functionality]].
383 In fact the functional test suite for Org-babel is implemented as a
384 large Org-mode table. To run the entire test suite you simple
385 evaluate the table =C-u C-c C-c=, and all of the tests are run
386 updating the table with pass/fail statistics.
388 Here's a sample of our test suite.
390 #+TBLNAME: org-babel-tests
391 | functionality | block | arg | expected | results | pass |
392 |------------------+--------------+-----+-------------+-------------+------|
393 | basic evaluation | | | | | pass |
394 |------------------+--------------+-----+-------------+-------------+------|
395 | emacs lisp | basic-elisp | 2 | 4 | 4 | pass |
396 | shell | basic-shell | | 6 | 6 | pass |
397 | ruby | basic-ruby | | org-babel | org-babel | pass |
398 | python | basic-python | | hello world | hello world | pass |
399 | R | basic-R | | 13 | 13 | pass |
400 #+TBLFM: $5='(if (= (length $3) 1) (progn (message (format "running %S" '(sbe $2 (n $3)))) (sbe $2 (n $3))) (sbe $2))::$6='(if (string= $4 $5) "pass" (format "expected %S but was %S" $4 $5))
401 #+TBLFM: $5=""::$6=""
403 *** code blocks for tests
405 #+srcname: basic-elisp
406 #+begin_src emacs-lisp :var n=7
410 #+srcname: basic-shell
411 #+begin_src sh :results silent
415 #+srcname: date-simple
416 #+begin_src sh :results silent
420 #+srcname: basic-ruby
421 #+begin_src ruby :results silent
425 #+srcname: basic-python
426 #+begin_src python :results silent
431 #+begin_src R :results silent
438 :CUSTOM_ID: library-of-babel
440 What about those source code blocks which are so useful you want to
441 have them available in every org-mode buffer?
443 The [[file:library-of-babel.org][Library of Babel]] is an extensible collection of ready-made and
444 easily-shortcut-callable source-code blocks for handling common
445 tasks. Org-babel comes pre-populated with the source-code blocks
446 located in the [[file:library-of-babel.org][library-of-babel.org]] file. It is possible to add
447 source-code blocks from any org-mode file to the library by calling
449 #+srcname: add-file-to-lob
450 #+begin_src emacs-lisp
451 (org-babel-lob-ingest "path/to/file.org")
454 * Reproducible Research
456 :CUSTOM_ID: reproducable-research
459 An article about computational science in a scientific publication is
460 not the scholarship itself, it is merely advertising of the
461 scholarship. The actual scholarship is the complete software
462 development environment and the complete set of instructions which
463 generated the figures.
468 [[http://reproducibleresearch.net/index.php/Main_Page][Reproducible Research]] (RR) is the practice of distributing along with
469 an article of research all data, code, and tools required to reproduce
470 the results discussed in the paper. As such the paper becomes not
471 only a document describing the research but a complete laboratory
472 reproducing the research.
474 Org-mode already has exceptional support for [[http://orgmode.org/manual/Exporting.html#Exporting][exporting to html and
475 LaTeX]]. Org-babel makes Org-mode a tool for RR by *activating* the
476 data and source code embedded into Org-mode documents making the
477 entire document executable. This makes it not only possible, but
478 natural to distribute research in a format that encourages readers to
479 recreate your results, and perform their own analysis.
481 Existing RR tools like [[http://en.wikipedia.org/wiki/Sweave][Sweave]] provide for the embedding of [[http://www.r-project.org/][R]] code into
482 LaTeX documents. While this is very useful, such documents often
483 still require a large degree of "glue code" in the form of external
484 shell scripts, python scripts, and Makefiles. To our knowledge
485 Org-babel is the only RR tool which allows multiple languages and data
486 to coexist and cooperate inside of a single document.
488 * Literate programming
490 :CUSTOM_ID: literate-programming
494 Let us change our traditional attitude to the construction of
495 programs: Instead of imagining that our main task is to instruct a
496 /computer/ what to do, let us concentrate rather on explaining to
497 /human beings/ what we want a computer to do.
499 The practitioner of literate programming can be regarded as an
500 essayist, whose main concern is with exposition and excellence of
501 style. Such an author, with thesaurus in hand, chooses the names of
502 variables carefully and explains what each variable means. He or she
503 strives for a program that is comprehensible because its concepts have
504 been introduced in an order that is best for human understanding,
505 using a mixture of formal and informal methods that reinforce each
511 Org-babel supports [[http://en.wikipedia.org/wiki/Literate_programming][Literate Programming]] (LP) by allowing the act of
512 programming to take place inside of Org-mode documents. The Org-mode
513 file can then be exported (*woven* in LP speak) to html or LaTeX for
514 consumption by a human, and the embedded source code can be extracted
515 (*tangled* in LP speak) into structured source code files for
516 consumption by a computer.
518 To support these operations Org-babel relies on Org-mode's [[http://orgmode.org/manual/Exporting.html#Exporting][existing
519 exporting functionality]] for *weaving* of documentation, and on the
520 =org-babel-tangle= function which makes use of [[http://www.cs.tufts.edu/~nr/noweb/][Noweb]] [[reference-expansion][reference syntax]]
521 for *tangling* of code files.
523 The [[literate-programming-example][following example]] demonstrates the process of *tangling* in
526 *** Simple Literate Programming Example (Noweb syntax)
528 :CUSTOM_ID: literate-programming-example
531 Tangling functionality is controlled by the =tangle= family of
532 [[header-arguments]]. These arguments can be used to turn tangling on or
533 off (the default) on the source code block, or the outline heading
536 The following demonstrates the combination of three source code blocks
537 into a single source code file using =org-babel-tangle=.
539 The following two blocks will not be tangled by default since they
540 have no =tangle= header arguments.
542 #+srcname: hello-world-prefix
543 #+begin_src sh :exports none
544 echo "/-----------------------------------------------------------\\"
547 : #+srcname: hello-world-prefix
548 : #+begin_src sh :exports none
549 : echo "/-----------------------------------------------------------\\"
552 #+srcname: hello-world-postfix
553 #+begin_src sh :exports none
554 echo "\-----------------------------------------------------------/"
557 : #+srcname: hello-world-postfix
558 : #+begin_src sh :exports none
559 : echo "\-----------------------------------------------------------/"
563 The third block does have a =tangle= header argument indicating the
564 name of the file to which it should be written. It also has [[http://www.cs.tufts.edu/~nr/noweb/][Noweb]]
565 style references to the two previous source code blocks which will be
566 expanded during tangling to include them in the output file as well.
568 #+srcname: hello-world
569 #+begin_src sh :tangle hello :exports none
570 # <<hello-world-prefix>>
571 echo "| hello world |"
572 # <<hello-world-postfix>>
575 : #+srcname: hello-world
576 : #+begin_src sh :tangle hello :exports none
577 : # <<hello-world-prefix>>
578 : echo "| hello world |"
579 : # <<hello-world-postfix>>
582 Calling =org-babel-tangle= will result in the following being written
583 to the =hello.sh= file.
585 #+srcname: hello-world-output
588 # generated by org-babel-tangle
590 # [[file:~/src/org-babel/org-babel-worg.org::#literate-programming-example][block-16]]
591 # <<hello-world-prefix>>
592 echo "/-----------------------------------------------------------\\"
594 echo "| hello world |"
595 # <<hello-world-postfix>>
596 echo "\-----------------------------------------------------------/"
600 *** Emacs Initialization with Org-babel
601 Org-babel has special support for embedding your emacs initialization
602 into Org-mode files. The =org-babel-load-file= function can be used
603 to load the emacs lisp embedded in a literate Org-mode file in the
604 same way that you might load a regular elisp file.
606 This allows you to have all the niceness of Org-mode (folding, tags,
607 notes, html export, etc...) available in your emacs initialization.
609 To try this out either see the simple [[literate-emacs-init][Literate Emacs Initialization]]
610 example directly below, or check out the Org-babel Literate
611 Programming version of Phil Hagelberg's excellent [[http://github.com/technomancy/emacs-starter-kit/tree/master][emacs-starter-kit]]
612 available at [[http://github.com/eschulte/emacs-starter-kit/tree/master][Org-babel-emacs-starter-kit]].
614 ***** Literate Emacs Initialization
616 :CUSTOM_ID: literate-emacs-init
619 For a simple example of usage follow these 4 steps.
621 1) create a directory named =.emacs.d= in the base of your home
626 2) checkout the latest versions of Org-mode and Org-babel into the src
627 subdirectory of this new directory
632 git clone git://repo.or.cz/org-mode.git
633 git clone git://github.com/eschulte/org-babel.git
635 3) place the following in a file called =init.el= in your emacs
636 initialization directory (=~/.emacs.d=).
637 #+srcname: emacs-init
638 #+begin_src emacs-lisp
639 ;;; init.el --- Where all the magic begins
641 ;; This file loads both
642 ;; - Org-mode : http://orgmode.org/ and
643 ;; - Org-babel: http://eschulte.github.com/org-babel/
645 ;; It then loads the rest of our Emacs initialization from Emacs lisp
646 ;; embedded in literate Org-mode files.
648 ;; Load up Org Mode and Org Babel for elisp embedded in Org Mode files
649 (setq dotfiles-dir (file-name-directory (or (buffer-file-name) load-file-name)))
650 (add-to-list 'load-path (expand-file-name
651 "lisp" (expand-file-name
652 "org" (expand-file-name
653 "src" dotfiles-dir))))
654 (add-to-list 'load-path (expand-file-name
655 "lisp" (expand-file-name
656 "org-babel" (expand-file-name
657 "src" dotfiles-dir))))
658 (require 'org-babel-init)
660 ;; load up all literate org-mode files in this directory
661 (mapc #'org-babel-load-file (directory-files dotfiles-dir t "\\.org$"))
663 ;;; init.el ends here
665 4) Implement all of your emacs customizations inside of elisp
666 source-code blocks located in Org-mode files in this directory.
667 They will be loaded by emacs on startup.
669 * Reference / Documentation
671 :CUSTOM_ID: reference-and-documentation
674 The following can be added to your .emacs and used to activate
675 languages. It includes a brief list of the requirements for each
676 language. *Note*: this also serves as the list of languages
677 currently supported by Org-babel.
678 #+begin_src emacs-lisp
679 ;; Uncomment each of the following require lines if you want org-babel
680 ;; to support that language. Each language has a comment explaining
681 ;; it's dependencies. See the related files in lisp/langs for more
682 ;; detailed explanations of requirements.
683 ;; (require 'org-babel-R) ;; R and ess-mode
684 ;; (require 'org-babel-asymptote) ;; asymptote
685 ;; (require 'org-babel-css) ;; none
686 ;; (require 'org-babel-ditaa) ;; ditaa
687 ;; (require 'org-babel-dot) ;; dot
688 ;; (require 'org-babel-gnuplot) ;; gnuplot, and gnuplot-mode
689 ;; (require 'org-babel-haskell) ;; haskell, haskell-mode, inf-haskell
690 ;; (require 'org-babel-ocaml) ;; ocaml, and tuareg-mode
691 ;; (require 'org-babel-python) ;; python, and python-mode
692 ;; (require 'org-babel-ruby) ;; ruby, irb, ruby-mode, and inf-ruby
693 ;; (require 'org-babel-sass) ;; sass, sass-mode
694 ;; (require 'org-babel-sql) ;; none
697 *** Source Code block syntax
699 The basic syntax of source-code blocks is as follows:
702 : #+begin_src language header-arguments
706 - name :: This name is associated with the source-code block. This is
707 similar to the =#+TBLNAME= lines which can be used to name tables
708 in org-mode files. By referencing the srcname of a source-code
709 block it is possible to evaluate the block for other places,
710 files, or from inside tables.
711 - language :: The language of the code in the source-code block, valid
712 values must be members of `org-babel-interpreters'.
713 - header-arguments :: Header arguments control many facets of the
714 input to, evaluation of, and output of source-code blocks. See
715 the [[* Header Arguments][Header Arguments]] section for a complete review of available
717 - body :: The actual source code which will be evaluated. This can be
718 edited with `org-edit-special'.
722 :CUSTOM_ID: header-arguments
725 - results :: results arguments specify what should be done with the
726 output of source-code blocks
727 - The following options are mutually exclusive, and specify how the
728 results should be collected from the source-code block
731 - The following options are mutually exclusive and specify what type
732 of results the code block will return
733 - vector :: specifies that the results should be interpreted as a
734 multidimensional vector (even if the vector is
735 trivial), and will be inserted into the org-mode file
737 - scalar :: specifies that the results should be interpreted as a
738 scalar value, and will be inserted into the org-mode
740 - file :: specifies that the results should be interpreted as the
741 path to a file, and will be inserted into the org-mode
743 - The following options specify how the results should be inserted
744 into the org-mode file
745 - replace :: the current results replace any previously inserted
746 results from the code block
747 - silent :: rather than being inserted into the org-mode file the
748 results are echoed into the message bar
749 - exports :: exports arguments specify what should be included in html
750 or latex exports of the org-mode file
751 - code :: the body of code is included into the exported file
752 - results :: the results of evaluating the code is included in the
754 - both :: both the code and results are included in the exported
756 - none :: nothing is included in the exported file
757 - tangle :: tangle arguments specify whether or not the source-code
758 block should be included in tangled extraction of
760 - yes :: the source-code block is exported to a source-code file
761 named after the basename (name w/o extension) of the
763 - no :: (default) the source-code block is not exported to a
765 - other :: any other string passed to the =tangle= header argument
766 is interpreted as a file basename to which the block will
769 *** Noweb reference syntax
770 The [[http://www.cs.tufts.edu/~nr/noweb/][Noweb]] Literate Programming system allows named blocks of code to
771 be referenced by using a =<<code-block-name>>= syntax. When a
772 document is tangled these references are replaced with the named code.
773 An example is provided in the [[literate-programming-example]] in this
778 [fn:1] Calling =C-c C-o= on a source-code block will open the
779 block's results in a separate buffer.