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, with 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), that can occur anywhere in
94 an org-mode file. For example, the following is a source block
95 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 a source code block 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. Here are three examples of code blocks in three different
133 languages, followed by their output. If you are viewing the plain text
134 version of this document in emacs, place point anywhere inside the
135 blocks and use =C-c C-c= to run the code[fn:1] (and feel free to alter
140 "This file was last evaluated on #{Date.today}"
144 : This file was last evaluated on 2009-08-09
146 **** [[http://www.r-project.org/][R]]
147 #+begin_src R :results value
148 matrix(rnorm(6), nrow=2)
152 | -0.138279734486552 | -2.2476234005706 | -0.0839549402407832 |
153 | 0.0730510956002737 | 0.0634015508602321 | 0.174013159381603 |
155 **** [[http://ditaa.sourceforge.net/][ditaa]]
156 #+begin_src ditaa :file images/blue.png :cmdline -r
167 [[file:images/blue.png]]
169 *** Source code block syntax
171 The basic syntax of source-code blocks in Org-babel is as follows:
173 : #+srcname: name(arguments)
174 : #+begin_src language header-arguments
178 - name :: This name is associated with the source-code block. This is
179 similar to the =#+tblname= lines which can be used to name tables
180 in org-mode files. By referencing the srcname of a source-code
181 block it is possible to evaluate the block from other places,
182 files, or from inside tables.
183 - arguments :: Code blocks can have arguments (see [[#arguments-to-source-code-blocks][below]]) which are
184 provided using a familiar function-call syntax similar
185 to (e.g.) python or R.
186 - language :: The language of the code in the source-code block. Valid
187 values must be members of `org-babel-interpreters'.
188 - header-arguments :: Header arguments control many facets of the
189 evaluation and output of source-code blocks. See the [[* Header Arguments][Header
190 Arguments]] section for a complete review of available header
192 - body :: The actual source code which will be evaluated. An
193 important key-binding to become familiar with is =C-c
194 '=. This calls `org-edit-special' which brings up an edit
195 buffer containing the code using the emacs major mode
196 appropriate to the language.
198 *** What happens to the results?
202 Org-babel provides two fundamentally different modes for capturing
203 the results of code evaluation, specified by the =:results= header
205 **** =:results value= (functional mode)
206 This means that the 'result' of code evaluation is defined to be
207 the *value* of the last statement in the block. Thus with this
208 setting, one can view the code block as a function with a return
209 value. And not only can you view it that way, but you can
210 actually use the return value of one source block as input for
211 another (see later). This setting is the default.
213 As an example, consider the following block of python code and its
216 #+begin_src python :results value
218 print("Hello, today's date is %s" % time.ctime())
219 print('Two plus two is')
226 Notice that in functional mode, the output consists of the value of
227 the last statement, and nothing else.
229 **** =:results output= (scripting mode)
230 With this setting, org-babel captures all the text output of the
231 code block and places it in the org buffer. One can think of this
232 as a 'scripting' mode: the code block contains a series of
233 commands, and you get the output of all the commands. Unlike in
234 the 'functional' mode, the code block has no return value. (This
235 mode will be more familiar to Sweave users).
237 Now consider the result of evaluating the same source block as
238 before, but under scripting mode.
241 #+begin_src python :results output
243 print("Hello, today's date is %s" % time.ctime())
244 print('Two plus two is')
249 : Hello, today's date is Fri Sep 4 19:49:06 2009
252 Again, we got what we asked for: all the text output (stdout) from
253 python. Since we didn't print the last value (2 + 2), we didn't get it
256 *** Arguments to source code blocks
258 :CUSTOM_ID: arguments-to-source-code-blocks
260 In addition to evaluation of code blocks, org-babel allows them to
261 be parameterised (i.e. have arguments). Thus source code blocks
262 now have the status of *functions*. Arguments to code blocks can
263 be used in both functional and scripting mode.
265 **** Simple example of using a source block as a function
267 First let's look at a very simple example. The following source
268 block defines an org-babel function that will square its input.
275 In the org-mode file that looks like this:
276 : #+srcname: square(x)
282 Now we use the source block:
288 #+resname: square(x=6)
291 **** A more complex example: using an org-table as input
293 In this example we're going to define a function to compute a
294 Fibonacci sequence, and we're going to make it take its input
295 from a table in the org-mode buffer.
297 Here are the inputs for fibonacci-seq:
299 #+tblname: fibonacci-inputs
300 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
301 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
303 in the Org-mode buffer this looks like
304 : #+tblname: fibonacci-inputs
305 : | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
306 : | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
308 [[http://www.gnu.org/software/emacs/manual/elisp.html][Emacs Lisp]] source code
309 #+srcname: fibonacci-seq(fib-inputs=fibonacci-inputs)
310 #+begin_src emacs-lisp
312 (if (or (= n 0) (= n 1))
314 (+ (fibonacci (- n 1)) (fibonacci (- n 2)))))
316 (mapcar (lambda (row)
317 (mapcar #'fibonacci row)) fib-inputs)
320 in the Org-mode buffer this looks like
321 : #+srcname: fibonacci-seq(fib-inputs=fibonacci-inputs)
322 : #+begin_src emacs-lisp
323 : (defun fibonacci (n)
324 : (if (or (= n 0) (= n 1))
326 : (+ (fibonacci (- n 1)) (fibonacci (- n 2)))))
328 : (mapcar (lambda (row)
329 : (mapcar #'fibonacci row)) fib-inputs)
332 Results of Emacs Lisp code evaluation
334 | 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 | 34 | 55 |
335 | 1 | 3 | 8 | 21 | 55 | 144 | 377 | 987 | 2584 | 6765 |
337 * A meta-programming language for org-mode
339 :CUSTOM_ID: meta-programming-language
342 Since information can pass freely between source-code blocks and
343 org-mode tables you can mix and match languages using each language
344 for those tasks to which it is suited. This makes Org-mode files with
345 Org-babel into a kind of meta-functional programming language in which
346 functions from many languages can work together.
348 As an example, lets take some system diagnostics in the shell, and
349 then graph them with R.
352 #+srcname: directories
353 #+begin_src bash :results replace
354 cd ~ && du -sc * |grep -v total
356 2. Results of the shell source code (on my system, grab this org-mode
357 files and try running it on your own)
358 #+resname: directories
360 | 12156104 | "Documents" |
361 | 3482440 | "Downloads" |
362 | 2901720 | "Library" |
364 | 16548024 | "Music" |
366 | 7649472 | "Pictures" |
374 3. R source code (which calls the previous shell source code)
375 #+srcname: directory-pie
376 #+begin_src R :var dirs = directories :session R-pie-example
377 pie(dirs[,1], labels = dirs[,2])
379 4. Results of R code [[file:images/dirs.png]]
381 * Spreadsheet plugins for org-mode in any language
383 :CUSTOM_ID: spreadsheet
386 *NOTE*: Maybe in-addition-to/in-stead-of this example we should do a
387 more traditional "spreadsheet" example with R [Eric]
389 Not only can Org-babel pass entire tables of data to source code
390 blocks (see [[arguments-to-source-code-blocks]]), Org-babel can also be
391 used to call source code blocks from *within* tables using the
392 Org-mode's [[http://orgmode.org/manual/The-spreadsheet.html#The-spreadsheet][existing spreadsheet functionality]].
394 In fact the functional test suite for Org-babel is implemented as a
395 large Org-mode table. To run the entire test suite you simple
396 evaluate the table =C-u C-c C-c=, and all of the tests are run
397 updating the table with pass/fail statistics.
399 Here's a sample of our test suite.
401 #+TBLNAME: org-babel-tests
402 | functionality | block | arg | expected | results | pass |
403 |------------------+--------------+-----+-------------+-------------+------|
404 | basic evaluation | | | | | pass |
405 |------------------+--------------+-----+-------------+-------------+------|
406 | emacs lisp | basic-elisp | 2 | 4 | 4 | pass |
407 | shell | basic-shell | | 6 | 6 | pass |
408 | ruby | basic-ruby | | org-babel | org-babel | pass |
409 | python | basic-python | | hello world | hello world | pass |
410 | R | basic-R | | 13 | 13 | pass |
411 #+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))
412 #+TBLFM: $5=""::$6=""
414 *** code blocks for tests
416 #+srcname: basic-elisp
417 #+begin_src emacs-lisp :var n=7
421 #+srcname: basic-shell
422 #+begin_src sh :results silent
426 #+srcname: date-simple
427 #+begin_src sh :results silent
431 #+srcname: basic-ruby
432 #+begin_src ruby :results silent
436 #+srcname: basic-python
437 #+begin_src python :results silent
442 #+begin_src R :results silent
449 :CUSTOM_ID: library-of-babel
451 What about those source code blocks which are so useful you want to
452 have them available in every org-mode buffer?
454 The [[file:library-of-babel.org][Library of Babel]] is an extensible collection of ready-made and
455 easily-shortcut-callable source-code blocks for handling common
456 tasks. Org-babel comes pre-populated with the source-code blocks
457 located in the [[file:library-of-babel.org][library-of-babel.org]] file. It is possible to add
458 source-code blocks from any org-mode file to the library by calling
460 #+srcname: add-file-to-lob
461 #+begin_src emacs-lisp
462 (org-babel-lob-ingest "path/to/file.org")
465 * Reproducible Research
467 :CUSTOM_ID: reproducable-research
470 An article about computational science in a scientific publication is
471 not the scholarship itself, it is merely advertising of the
472 scholarship. The actual scholarship is the complete software
473 development environment and the complete set of instructions which
474 generated the figures.
479 [[http://reproducibleresearch.net/index.php/Main_Page][Reproducible Research]] (RR) is the practice of distributing along with
480 an article of research all data, code, and tools required to reproduce
481 the results discussed in the paper. As such the paper becomes not
482 only a document describing the research but a complete laboratory in
483 which the research can be reproduced and extended.
485 Org-mode already has exceptional support for [[http://orgmode.org/manual/Exporting.html#Exporting][exporting to html and
486 LaTeX]]. Org-babel makes Org-mode a tool for RR by *activating* the
487 data and source code embedded into Org-mode documents making the
488 entire document executable. This makes it not only possible, but
489 natural to distribute research in a format that encourages readers to
490 recreate your results, and perform their own analysis.
492 One notable existing RR tool is [[http://en.wikipedia.org/wiki/Sweave][Sweave]] which provides for the
493 embedding of [[http://www.r-project.org/][R]] code into LaTeX documents. While Sweave is a mature
494 and very useful tool, we believe that Org-babel has several
496 - It supports multiple languages (we're not aware of other RR tools that do this)
497 - The [[http://orgmode.org/manual/Exporting.html#Exporting][export process]] is flexible and powerful, including HTML as a target in addition to LaTeX
498 - The document can make native use of all the features of Org-mode,
499 such as those for [[http://orgmode.org/manual/Agenda-Views.html#Agenda-Views][project planning]] and [[http://orgmode.org/manual/TODO-Items.html#TODO-Items][task management]]
501 * Literate programming
503 :CUSTOM_ID: literate-programming
507 Let us change our traditional attitude to the construction of
508 programs: Instead of imagining that our main task is to instruct a
509 /computer/ what to do, let us concentrate rather on explaining to
510 /human beings/ what we want a computer to do.
512 The practitioner of literate programming can be regarded as an
513 essayist, whose main concern is with exposition and excellence of
514 style. Such an author, with thesaurus in hand, chooses the names of
515 variables carefully and explains what each variable means. He or she
516 strives for a program that is comprehensible because its concepts have
517 been introduced in an order that is best for human understanding,
518 using a mixture of formal and informal methods that reinforce each
524 Org-babel supports [[http://en.wikipedia.org/wiki/Literate_programming][Literate Programming]] (LP) by allowing the act of
525 programming to take place inside of Org-mode documents. The Org-mode
526 file can then be exported (*woven* in LP speak) to html or LaTeX for
527 consumption by a human, and the embedded source code can be extracted
528 (*tangled* in LP speak) into structured source code files for
529 consumption by a computer.
531 To support these operations Org-babel relies on Org-mode's [[http://orgmode.org/manual/Exporting.html#Exporting][existing
532 exporting functionality]] for *weaving* of documentation, and on the
533 =org-babel-tangle= function which makes use of [[http://www.cs.tufts.edu/~nr/noweb/][Noweb]] [[reference-expansion][reference syntax]]
534 for *tangling* of code files.
536 The [[literate-programming-example][following example]] demonstrates the process of *tangling* in
539 *** Simple Literate Programming Example (Noweb syntax)
541 :CUSTOM_ID: literate-programming-example
544 Tangling functionality is controlled by the =tangle= family of
545 [[header-arguments]]. These arguments can be used to turn tangling on or
546 off (the default) on the source code block, or the outline heading
549 The following demonstrates the combination of three source code blocks
550 into a single source code file using =org-babel-tangle=.
552 The following two blocks will not be tangled by default since they
553 have no =tangle= header arguments.
555 #+srcname: hello-world-prefix
556 #+begin_src sh :exports none
557 echo "/-----------------------------------------------------------\\"
560 : #+srcname: hello-world-prefix
561 : #+begin_src sh :exports none
562 : echo "/-----------------------------------------------------------\\"
565 #+srcname: hello-world-postfix
566 #+begin_src sh :exports none
567 echo "\-----------------------------------------------------------/"
570 : #+srcname: hello-world-postfix
571 : #+begin_src sh :exports none
572 : echo "\-----------------------------------------------------------/"
576 The third block does have a =tangle= header argument indicating the
577 name of the file to which it should be written. It also has [[http://www.cs.tufts.edu/~nr/noweb/][Noweb]]
578 style references to the two previous source code blocks which will be
579 expanded during tangling to include them in the output file as well.
581 #+srcname: hello-world
582 #+begin_src sh :tangle hello :exports none
583 # <<hello-world-prefix>>
584 echo "| hello world |"
585 # <<hello-world-postfix>>
588 : #+srcname: hello-world
589 : #+begin_src sh :tangle hello :exports none
590 : # <<hello-world-prefix>>
591 : echo "| hello world |"
592 : # <<hello-world-postfix>>
595 Calling =org-babel-tangle= will result in the following being written
596 to the =hello.sh= file.
598 #+srcname: hello-world-output
601 # generated by org-babel-tangle
603 # [[file:~/src/org-babel/org-babel-worg.org::#literate-programming-example][block-16]]
604 # <<hello-world-prefix>>
605 echo "/-----------------------------------------------------------\\"
607 echo "| hello world |"
608 # <<hello-world-postfix>>
609 echo "\-----------------------------------------------------------/"
613 *** Emacs Initialization with Org-babel
614 Org-babel has special support for embedding your emacs initialization
615 into Org-mode files. The =org-babel-load-file= function can be used
616 to load the emacs lisp embedded in a literate Org-mode file in the
617 same way that you might load a regular elisp file.
619 This allows you to have all the niceness of Org-mode (folding, tags,
620 notes, html export, etc...) available in your emacs initialization.
622 To try this out either see the simple [[literate-emacs-init][Literate Emacs Initialization]]
623 example directly below, or check out the Org-babel Literate
624 Programming version of Phil Hagelberg's excellent [[http://github.com/technomancy/emacs-starter-kit/tree/master][emacs-starter-kit]]
625 available at [[http://github.com/eschulte/emacs-starter-kit/tree/master][Org-babel-emacs-starter-kit]].
627 ***** Literate Emacs Initialization
629 :CUSTOM_ID: literate-emacs-init
632 For a simple example of usage follow these 4 steps.
634 1) create a directory named =.emacs.d= in the base of your home
639 2) checkout the latest versions of Org-mode and Org-babel into the src
640 subdirectory of this new directory
645 git clone git://repo.or.cz/org-mode.git
646 git clone git://github.com/eschulte/org-babel.git
648 3) place the following in a file called =init.el= in your emacs
649 initialization directory (=~/.emacs.d=).
650 #+srcname: emacs-init
651 #+begin_src emacs-lisp
652 ;;; init.el --- Where all the magic begins
654 ;; This file loads both
655 ;; - Org-mode : http://orgmode.org/ and
656 ;; - Org-babel: http://eschulte.github.com/org-babel/
658 ;; It then loads the rest of our Emacs initialization from Emacs lisp
659 ;; embedded in literate Org-mode files.
661 ;; Load up Org Mode and Org Babel for elisp embedded in Org Mode files
662 (setq dotfiles-dir (file-name-directory (or (buffer-file-name) load-file-name)))
663 (add-to-list 'load-path (expand-file-name
664 "lisp" (expand-file-name
665 "org" (expand-file-name
666 "src" dotfiles-dir))))
667 (add-to-list 'load-path (expand-file-name
668 "lisp" (expand-file-name
669 "org-babel" (expand-file-name
670 "src" dotfiles-dir))))
671 (require 'org-babel-init)
673 ;; load up all literate org-mode files in this directory
674 (mapc #'org-babel-load-file (directory-files dotfiles-dir t "\\.org$"))
676 ;;; init.el ends here
678 4) Implement all of your emacs customizations inside of elisp
679 source-code blocks located in Org-mode files in this directory.
680 They will be loaded by emacs on startup.
682 * Reference / Documentation
684 :CUSTOM_ID: reference-and-documentation
687 The following can be added to your .emacs and used to activate
688 languages. It includes a brief list of the requirements for each
689 language. *Note*: this also serves as the list of languages
690 currently supported by Org-babel.
691 #+begin_src emacs-lisp
692 ;; Uncomment each of the following require lines if you want org-babel
693 ;; to support that language. Each language has a comment explaining
694 ;; it's dependencies. See the related files in lisp/langs for more
695 ;; detailed explanations of requirements.
696 ;; (require 'org-babel-R) ;; R and ess-mode
697 ;; (require 'org-babel-asymptote) ;; asymptote
698 ;; (require 'org-babel-css) ;; none
699 ;; (require 'org-babel-ditaa) ;; ditaa
700 ;; (require 'org-babel-dot) ;; dot
701 ;; (require 'org-babel-gnuplot) ;; gnuplot, and gnuplot-mode
702 ;; (require 'org-babel-haskell) ;; haskell, haskell-mode, inf-haskell
703 ;; (require 'org-babel-ocaml) ;; ocaml, and tuareg-mode
704 ;; (require 'org-babel-python) ;; python, and python-mode
705 ;; (require 'org-babel-ruby) ;; ruby, irb, ruby-mode, and inf-ruby
706 ;; (require 'org-babel-sass) ;; sass, sass-mode
707 ;; (require 'org-babel-sql) ;; none
712 :CUSTOM_ID: header-arguments
715 - results :: results arguments specify what should be done with the
716 output of source-code blocks
717 - The following options are mutually exclusive, and specify how the
718 results should be collected from the source-code block
721 - The following options are mutually exclusive and specify what type
722 of results the code block will return
723 - vector :: specifies that the results should be interpreted as a
724 multidimensional vector (even if the vector is
725 trivial), and will be inserted into the org-mode file
727 - scalar :: specifies that the results should be interpreted as a
728 scalar value, and will be inserted into the org-mode
730 - file :: specifies that the results should be interpreted as the
731 path to a file, and will be inserted into the org-mode
733 - The following options specify how the results should be inserted
734 into the org-mode file
735 - replace :: the current results replace any previously inserted
736 results from the code block
737 - silent :: rather than being inserted into the org-mode file the
738 results are echoed into the message bar
739 - exports :: exports arguments specify what should be included in html
740 or latex exports of the org-mode file
741 - code :: the body of code is included into the exported file
742 - results :: the results of evaluating the code is included in the
744 - both :: both the code and results are included in the exported
746 - none :: nothing is included in the exported file
747 - tangle :: tangle arguments specify whether or not the source-code
748 block should be included in tangled extraction of
750 - yes :: the source-code block is exported to a source-code file
751 named after the basename (name w/o extension) of the
753 - no :: (default) the source-code block is not exported to a
755 - other :: any other string passed to the =tangle= header argument
756 is interpreted as a file basename to which the block will
759 *** Noweb reference syntax
760 The [[http://www.cs.tufts.edu/~nr/noweb/][Noweb]] Literate Programming system allows named blocks of code to
761 be referenced by using a =<<code-block-name>>= syntax. When a
762 document is tangled these references are replaced with the named code.
763 An example is provided in the [[literate-programming-example]] in this
768 [fn:1] Calling =C-c C-o= on a source-code block will open the
769 block's results in a separate buffer.