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/Brueghel-little-tower-of-babel.png"
20 alt="images/Brueghel-little-tower-of-babel.png"
21 title="And the Lord said, Behold, the people is one, and they
22 have all one language; and this they begin to do; and now
23 nothing will be restrained from them, which they have
24 imagined to do. Genesis 11:1-9"/>
26 The Tower of Babel by Pieter Bruegel the Elder
39 :CUSTOM_ID: introduction
41 Org-babel is an extension to the very excellent [[http://orgmode.org/][Org-mode]], providing
42 the ability to execute source code in many different languages within
43 org-mode documents. Org-mode is an [[http://www.gnu.org/software/emacs/][Emacs]] major mode for doing almost
44 anything with plain text. If you are not familiar with Org-mode
45 please take a moment to read [[http://orgmode.org/][the Org-mode homepage]] before continuing.
47 Org-babel provides the following modifications to [[http://orgmode.org/manual/Literal-examples.html][the existing
48 support]] for blocks of source code examples in the org-mode core.
50 1. Interactive source code execution
51 2. Arguments to source code blocks
52 3. Exportation of source code blocks to files (literate programming)
56 :CUSTOM_ID: getting-started
59 1) Grab the latest code from the git repo at [[http://github.com/eschulte/org-babel/tree/master][github/org-babel]]
61 git clone git://github.com/eschulte/org-babel.git
64 2) Add the following lines to your .emacs, replacing the path as
65 appropriate. A good place to check that things are up and running
66 would the examples in [[* Basic org-babel functionality][Basic org-babel functionality]].
67 #+begin_src emacs-lisp
68 (add-to-list 'load-path "/path/to/org-babel/lisp")
69 (require 'org-babel-init)
72 3) Finally, activate the subset of supported Org-babel languages
73 which you want to be able to execute on your system. As an
74 example, the following activates python, ruby and R. For a full
75 list of languages, with notes on their dependencies see the
76 [[#reference-and-documentation][Reference / Documentation]] section below.
77 #+begin_src emacs-lisp
78 (require 'org-babel-python)
79 (require 'org-babel-ruby)
80 (require 'org-babel-R)
82 ;; Once you've activated languages, load the library of babel to
83 ;; make pre-built helper functions available in the languages you will be using.
84 (org-babel-load-library-of-babel)
87 * Basic org-babel functionality
89 :CUSTOM_ID: basic-functionality
91 *** Source code blocks
93 :CUSTOM_ID: source-code-blocks
96 Org-babel is all about *source code blocks* in org mode. These are
97 blocks of code (in whatever language), that can occur anywhere in
98 an org-mode file. For example, the following is a source block
99 containing [[http://www.ruby-lang.org/][ruby]] code:
102 : "This file was last evaluated on #{Date.today}"
105 If you are unfamiliar with the notion of a source code block in
106 org-mode, please have a look at the [[http://orgmode.org/manual/Literal-examples.html][relevant manual section]] before
109 Note that above is what the source block looks like in the org-mode
110 file. We had to take [[http://orgmode.org/manual/Literal-examples.html#Literal-examples][special steps]] to make it look that way in the
111 HTML output. Normally, when exported to HTML, source blocks are
112 fontified according to their language, and the begin_src...end_src
113 mark-up is omitted, like this:
116 "This file was last evaluated on #{Date.today}"
119 From now on, if you are viewing the HTML version, you will see the
120 HTML output only. However, much of this document consists of
121 interactive examples, and therefore in order to get a feeling for the
122 mechanics of Org-babel it might make most sense to grab the plain text
124 #+HTML: <a href="org-babel-worg.org">org-babel-worg.org</a>
125 and work through it in Emacs. Alternatively the htmlized
126 version of the plain text of this file at
127 #+HTML: <a href="org-babel-worg.org.html">org-babel-worg.html</a>
128 allows the plain text version to be viewed (non-interactively) in a web browser.
129 *** Source code execution
131 :CUSTOM_ID: source-code-execution
133 For interpreted languages such as shell, python, R, etc, org-babel
134 allows source blocks to be executed: the code is passed to the
135 interpreter and you have control over what is done with the results of
136 execution. Here are three examples of code blocks in three different
137 languages, followed by their output. If you are viewing the plain text
138 version of this document in emacs, place point anywhere inside the
139 blocks and use =C-c C-c= to run the code[fn:1] (and feel free to alter
144 "This file was last evaluated on #{Date.today}"
148 : This file was last evaluated on 2009-08-09
150 **** [[http://www.r-project.org/][R]]
151 #+begin_src R :results value
152 matrix(rnorm(6), nrow=2)
156 | -0.138279734486552 | -2.2476234005706 | -0.0839549402407832 |
157 | 0.0730510956002737 | 0.0634015508602321 | 0.174013159381603 |
159 **** [[http://ditaa.sourceforge.net/][ditaa]]
160 #+begin_src ditaa :file images/blue.png :cmdline -r
171 [[file:images/blue.png]]
173 *** Source code block syntax
175 The basic syntax of source-code blocks in Org-babel is as follows:
177 : #+srcname: name(arguments)
178 : #+begin_src language header-arguments
182 - name :: This name is associated with the source-code block. This is
183 similar to the =#+tblname= lines which can be used to name tables
184 in org-mode files. By referencing the srcname of a source-code
185 block it is possible to evaluate the block from other places,
186 files, or from inside tables.
187 - arguments :: Code blocks can have arguments (see [[#arguments-to-source-code-blocks][below]]) which are
188 provided using a familiar function-call syntax similar
189 to (e.g.) python or R.
190 - language :: The language of the code in the source-code block. Valid
191 values must be members of `org-babel-interpreters'.
192 - header-arguments :: Header arguments control many facets of the
193 evaluation and output of source-code blocks. See the [[* Header Arguments][Header
194 Arguments]] section for a complete review of available header
196 - body :: The actual source code which will be evaluated. An
197 important key-binding to become familiar with is =C-c
198 '=. This calls `org-edit-special' which brings up an edit
199 buffer containing the code using the emacs major mode
200 appropriate to the language.
202 *** What happens to the results?
206 Org-babel provides two fundamentally different modes for capturing
207 the results of code evaluation, specified by the =:results= header
209 **** =:results value= (functional mode)
210 This means that the 'result' of code evaluation is defined to be
211 the *value* of the last statement in the block. Thus with this
212 setting, one can view the code block as a function with a return
213 value. And not only can you view it that way, but you can
214 actually use the return value of one source block as input for
215 another (see [[meta-programming-language]]). This setting is the
218 As an example, consider the following block of python code and its
221 #+begin_src python :results value
223 print("Hello, today's date is %s" % time.ctime())
224 print('Two plus two is')
231 Notice that in functional mode, the output consists of the value of
232 the last statement, and nothing else.
234 **** =:results output= (scripting mode)
235 With this setting, org-babel captures all the text output of the
236 code block and places it in the org buffer. One can think of this
237 as a 'scripting' mode: the code block contains a series of
238 commands, and you get the output of all the commands. Unlike in
239 the 'functional' mode, the code block has no return value. (This
240 mode will be more familiar to Sweave users).
242 Now consider the result of evaluating the same source block as
243 before, but under scripting mode.
246 #+begin_src python :results output
248 print("Hello, today's date is %s" % time.ctime())
249 print('Two plus two is')
254 : Hello, today's date is Fri Sep 4 19:49:06 2009
257 Again, we got what we asked for: all the text output (stdout) from
258 python. Since we didn't print the last value (2 + 2), we didn't get it
261 *** Arguments to source code blocks
263 :CUSTOM_ID: arguments-to-source-code-blocks
265 In addition to evaluation of code blocks, org-babel allows them to
266 be parameterised (i.e. have arguments). Thus source code blocks
267 now have the status of *functions*. Arguments to code blocks can
268 be used in both functional and scripting mode.
270 **** Simple example of using a source block as a function
272 First let's look at a very simple example. The following source
273 block defines an org-babel function that will square its input.
280 In the org-mode file that looks like this:
281 : #+srcname: square(x)
287 Now we use the source block:
290 (/for information on the/ =lob= /syntax see [[library-of-babel]]/)
294 #+resname: square(x=6)
297 **** A more complex example: using an org-table as input
299 In this example we're going to define a function to compute a
300 Fibonacci sequence, and we're going to make it take its input
301 from a table in the org-mode buffer.
303 Here are the inputs for fibonacci-seq:
305 #+tblname: fibonacci-inputs
306 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
307 | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
309 in the Org-mode buffer this looks like
310 : #+tblname: fibonacci-inputs
311 : | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
312 : | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
314 [[http://www.gnu.org/software/emacs/manual/elisp.html][Emacs Lisp]] source code
315 #+srcname: fibonacci-seq(fib-inputs=fibonacci-inputs)
316 #+begin_src emacs-lisp
318 (if (or (= n 0) (= n 1))
320 (+ (fibonacci (- n 1)) (fibonacci (- n 2)))))
322 (mapcar (lambda (row)
323 (mapcar #'fibonacci row)) fib-inputs)
326 in the Org-mode buffer this looks like
327 : #+srcname: fibonacci-seq(fib-inputs=fibonacci-inputs)
328 : #+begin_src emacs-lisp
329 : (defun fibonacci (n)
330 : (if (or (= n 0) (= n 1))
332 : (+ (fibonacci (- n 1)) (fibonacci (- n 2)))))
334 : (mapcar (lambda (row)
335 : (mapcar #'fibonacci row)) fib-inputs)
338 Results of Emacs Lisp code evaluation
340 | 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 | 34 | 55 |
341 | 1 | 3 | 8 | 21 | 55 | 144 | 377 | 987 | 2584 | 6765 |
343 * A meta-programming language for org-mode
345 :CUSTOM_ID: meta-programming-language
348 Since information can pass freely between source-code blocks and
349 org-mode tables you can mix and match languages using each language
350 for those tasks to which it is suited. This makes Org-mode files with
351 Org-babel into a kind of meta-functional programming language in which
352 functions from many languages can work together.
354 As an example, lets take some system diagnostics in the shell, and
355 then graph them with R.
358 #+srcname: directories
359 #+begin_src bash :results replace
360 cd ~ && du -sc * |grep -v total
362 2. Results of the shell source code (on my system, grab this org-mode
363 files and try running it on your own)
364 #+resname: directories
366 | 12156104 | "Documents" |
367 | 3482440 | "Downloads" |
368 | 2901720 | "Library" |
370 | 16548024 | "Music" |
372 | 7649472 | "Pictures" |
380 3. R source code (which calls the previous shell source code)
381 #+srcname: directory-pie
382 #+begin_src R :var dirs = directories :session R-pie-example
383 pie(dirs[,1], labels = dirs[,2])
385 4. Results of R code [[file:images/dirs.png]]
387 * Spreadsheet plugins for org-mode in any language
389 :CUSTOM_ID: spreadsheet
392 *NOTE*: Maybe in-addition-to/in-stead-of this example we should do a
393 more traditional "spreadsheet" example with R [Eric]
395 Not only can Org-babel pass entire tables of data to source code
396 blocks (see [[arguments-to-source-code-blocks]]), Org-babel can also be
397 used to call source code blocks from *within* tables using the
398 Org-mode's [[http://orgmode.org/manual/The-spreadsheet.html#The-spreadsheet][existing spreadsheet functionality]].
400 In fact the functional test suite for Org-babel is implemented as a
401 large Org-mode table. To run the entire test suite you simple
402 evaluate the table =C-u C-c C-c=, and all of the tests are run
403 updating the table with pass/fail statistics.
405 Here's a sample of our test suite.
407 #+TBLNAME: org-babel-tests
408 | functionality | block | arg | expected | results | pass |
409 |------------------+--------------+-----+-------------+-------------+------|
410 | basic evaluation | | | | | pass |
411 |------------------+--------------+-----+-------------+-------------+------|
412 | emacs lisp | basic-elisp | 2 | 4 | 4 | pass |
413 | shell | basic-shell | | 6 | 6 | pass |
414 | ruby | basic-ruby | | org-babel | org-babel | pass |
415 | python | basic-python | | hello world | hello world | pass |
416 | R | basic-R | | 13 | 13 | pass |
417 #+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))
418 #+TBLFM: $5=""::$6=""
420 *** code blocks for tests
422 #+srcname: basic-elisp
423 #+begin_src emacs-lisp :var n=7
427 #+srcname: basic-shell
428 #+begin_src sh :results silent
432 #+srcname: date-simple
433 #+begin_src sh :results silent
437 #+srcname: basic-ruby
438 #+begin_src ruby :results silent
442 #+srcname: basic-python
443 #+begin_src python :results silent
448 #+begin_src R :results silent
455 :CUSTOM_ID: library-of-babel
457 What about those source code blocks which are so useful you want to
458 have them available in every org-mode buffer?
460 The [[file:library-of-babel.org][Library of Babel]] is an extensible collection of ready-made and
461 easily-shortcut-callable source-code blocks for handling common
462 tasks. Org-babel comes pre-populated with the source-code blocks
463 located in the [[file:library-of-babel.org][library-of-babel.org]] file. It is possible to add
464 source-code blocks from any org-mode file to the library by calling
466 #+srcname: add-file-to-lob
467 #+begin_src emacs-lisp
468 (org-babel-lob-ingest "path/to/file.org")
471 Once a function has been loaded into the Library of Babel it can be
472 called using the following short =lob= notation.
475 Note that it is also possible to pass table values or the output of
476 a source-code block to lob functions, and it is possible to
477 reference lob functions in source block arguments.
479 * Reproducible Research
481 :CUSTOM_ID: reproducable-research
484 An article about computational science in a scientific publication is
485 not the scholarship itself, it is merely advertising of the
486 scholarship. The actual scholarship is the complete software
487 development environment and the complete set of instructions which
488 generated the figures.
493 [[http://reproducibleresearch.net/index.php/Main_Page][Reproducible Research]] (RR) is the practice of distributing along with
494 an article of research all data, code, and tools required to reproduce
495 the results discussed in the paper. As such the paper becomes not
496 only a document describing the research but a complete laboratory in
497 which the research can be reproduced and extended.
499 Org-mode already has exceptional support for [[http://orgmode.org/manual/Exporting.html#Exporting][exporting to html and
500 LaTeX]]. Org-babel makes Org-mode a tool for RR by *activating* the
501 data and source code embedded into Org-mode documents making the
502 entire document executable. This makes it not only possible, but
503 natural to distribute research in a format that encourages readers to
504 recreate your results, and perform their own analysis.
506 One notable existing RR tool is [[http://en.wikipedia.org/wiki/Sweave][Sweave]] which provides for the
507 embedding of [[http://www.r-project.org/][R]] code into LaTeX documents. While Sweave is a mature
508 and very useful tool, we believe that Org-babel has several
510 - It supports multiple languages (we're not aware of other RR tools that do this)
511 - The [[http://orgmode.org/manual/Exporting.html#Exporting][export process]] is flexible and powerful, including HTML as a target in addition to LaTeX
512 - The document can make native use of all the features of Org-mode,
513 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]]
515 * Literate programming
517 :CUSTOM_ID: literate-programming
521 Let us change our traditional attitude to the construction of
522 programs: Instead of imagining that our main task is to instruct a
523 /computer/ what to do, let us concentrate rather on explaining to
524 /human beings/ what we want a computer to do.
526 The practitioner of literate programming can be regarded as an
527 essayist, whose main concern is with exposition and excellence of
528 style. Such an author, with thesaurus in hand, chooses the names of
529 variables carefully and explains what each variable means. He or she
530 strives for a program that is comprehensible because its concepts have
531 been introduced in an order that is best for human understanding,
532 using a mixture of formal and informal methods that reinforce each
538 Org-babel supports [[http://en.wikipedia.org/wiki/Literate_programming][Literate Programming]] (LP) by allowing the act of
539 programming to take place inside of Org-mode documents. The Org-mode
540 file can then be exported (*woven* in LP speak) to html or LaTeX for
541 consumption by a human, and the embedded source code can be extracted
542 (*tangled* in LP speak) into structured source code files for
543 consumption by a computer.
545 To support these operations Org-babel relies on Org-mode's [[http://orgmode.org/manual/Exporting.html#Exporting][existing
546 exporting functionality]] for *weaving* of documentation, and on the
547 =org-babel-tangle= function which makes use of [[http://www.cs.tufts.edu/~nr/noweb/][Noweb]] [[reference-expansion][reference syntax]]
548 for *tangling* of code files.
550 The [[literate-programming-example][following example]] demonstrates the process of *tangling* in
553 *** Simple Literate Programming Example (Noweb syntax)
555 :CUSTOM_ID: literate-programming-example
558 Tangling functionality is controlled by the =tangle= family of
559 [[header-arguments]]. These arguments can be used to turn tangling on or
560 off (the default) on the source code block, or the outline heading
563 The following demonstrates the combination of three source code blocks
564 into a single source code file using =org-babel-tangle=.
566 The following two blocks will not be tangled by default since they
567 have no =tangle= header arguments.
569 #+srcname: hello-world-prefix
570 #+begin_src sh :exports none
571 echo "/-----------------------------------------------------------\\"
574 : #+srcname: hello-world-prefix
575 : #+begin_src sh :exports none
576 : echo "/-----------------------------------------------------------\\"
579 #+srcname: hello-world-postfix
580 #+begin_src sh :exports none
581 echo "\-----------------------------------------------------------/"
584 : #+srcname: hello-world-postfix
585 : #+begin_src sh :exports none
586 : echo "\-----------------------------------------------------------/"
590 The third block does have a =tangle= header argument indicating the
591 name of the file to which it should be written. It also has [[http://www.cs.tufts.edu/~nr/noweb/][Noweb]]
592 style references to the two previous source code blocks which will be
593 expanded during tangling to include them in the output file as well.
595 #+srcname: hello-world
596 #+begin_src sh :tangle hello :exports none
597 # <<hello-world-prefix>>
598 echo "| hello world |"
599 # <<hello-world-postfix>>
602 : #+srcname: hello-world
603 : #+begin_src sh :tangle hello :exports none
604 : # <<hello-world-prefix>>
605 : echo "| hello world |"
606 : # <<hello-world-postfix>>
609 Calling =org-babel-tangle= will result in the following being written
610 to the =hello.sh= file.
612 #+srcname: hello-world-output
615 # generated by org-babel-tangle
617 # [[file:~/src/org-babel/org-babel-worg.org::#literate-programming-example][block-16]]
618 # <<hello-world-prefix>>
619 echo "/-----------------------------------------------------------\\"
621 echo "| hello world |"
622 # <<hello-world-postfix>>
623 echo "\-----------------------------------------------------------/"
627 *** Emacs Initialization with Org-babel
628 Org-babel has special support for embedding your emacs initialization
629 into Org-mode files. The =org-babel-load-file= function can be used
630 to load the emacs lisp embedded in a literate Org-mode file in the
631 same way that you might load a regular elisp file.
633 This allows you to have all the niceness of Org-mode (folding, tags,
634 notes, html export, etc...) available in your emacs initialization.
636 To try this out either see the simple [[literate-emacs-init][Literate Emacs Initialization]]
637 example directly below, or check out the Org-babel Literate
638 Programming version of Phil Hagelberg's excellent [[http://github.com/technomancy/emacs-starter-kit/tree/master][emacs-starter-kit]]
639 available at [[http://github.com/eschulte/emacs-starter-kit/tree/master][Org-babel-emacs-starter-kit]].
641 ***** Literate Emacs Initialization
643 :CUSTOM_ID: literate-emacs-init
646 For a simple example of usage follow these 4 steps.
648 1) create a directory named =.emacs.d= in the base of your home
653 2) checkout the latest versions of Org-mode and Org-babel into the src
654 subdirectory of this new directory
659 git clone git://repo.or.cz/org-mode.git
660 git clone git://github.com/eschulte/org-babel.git
662 3) place the following in a file called =init.el= in your emacs
663 initialization directory (=~/.emacs.d=).
664 #+srcname: emacs-init
665 #+begin_src emacs-lisp
666 ;;; init.el --- Where all the magic begins
668 ;; This file loads both
669 ;; - Org-mode : http://orgmode.org/ and
670 ;; - Org-babel: http://eschulte.github.com/org-babel/
672 ;; It then loads the rest of our Emacs initialization from Emacs lisp
673 ;; embedded in literate Org-mode files.
675 ;; Load up Org Mode and Org Babel for elisp embedded in Org Mode files
676 (setq dotfiles-dir (file-name-directory (or (buffer-file-name) load-file-name)))
677 (add-to-list 'load-path (expand-file-name
678 "lisp" (expand-file-name
679 "org" (expand-file-name
680 "src" dotfiles-dir))))
681 (add-to-list 'load-path (expand-file-name
682 "lisp" (expand-file-name
683 "org-babel" (expand-file-name
684 "src" dotfiles-dir))))
685 (require 'org-babel-init)
687 ;; load up all literate org-mode files in this directory
688 (mapc #'org-babel-load-file (directory-files dotfiles-dir t "\\.org$"))
690 ;;; init.el ends here
692 4) Implement all of your emacs customizations inside of elisp
693 source-code blocks located in Org-mode files in this directory.
694 They will be loaded by emacs on startup.
696 * Reference / Documentation
698 :CUSTOM_ID: reference-and-documentation
701 The following can be added to your .emacs and used to activate
702 languages. It includes a brief list of the requirements for each
703 language. *Note*: this also serves as the list of languages
704 currently supported by Org-babel.
705 #+begin_src emacs-lisp
706 ;; Uncomment each of the following require lines if you want org-babel
707 ;; to support that language. Each language has a comment explaining
708 ;; it's dependencies. See the related files in lisp/langs for more
709 ;; detailed explanations of requirements.
710 ;; (require 'org-babel-R) ;; R and ess-mode
711 ;; (require 'org-babel-asymptote) ;; asymptote
712 ;; (require 'org-babel-css) ;; none
713 ;; (require 'org-babel-ditaa) ;; ditaa
714 ;; (require 'org-babel-dot) ;; dot
715 ;; (require 'org-babel-gnuplot) ;; gnuplot, and gnuplot-mode
716 ;; (require 'org-babel-haskell) ;; haskell, haskell-mode, inf-haskell
717 ;; (require 'org-babel-ocaml) ;; ocaml, and tuareg-mode
718 ;; (require 'org-babel-python) ;; python, and python-mode
719 ;; (require 'org-babel-ruby) ;; ruby, irb, ruby-mode, and inf-ruby
720 ;; (require 'org-babel-sass) ;; sass, sass-mode
721 ;; (require 'org-babel-sql) ;; none
726 :CUSTOM_ID: header-arguments
729 - results :: results arguments specify what should be done with the
730 output of source-code blocks
731 - The following options are mutually exclusive, and specify how the
732 results should be collected from the source-code block
735 - The following options are mutually exclusive and specify what type
736 of results the code block will return
737 - vector :: specifies that the results should be interpreted as a
738 multidimensional vector (even if the vector is
739 trivial), and will be inserted into the org-mode file
741 - scalar :: specifies that the results should be interpreted as a
742 scalar value, and will be inserted into the org-mode
744 - file :: specifies that the results should be interpreted as the
745 path to a file, and will be inserted into the org-mode
747 - The following options specify how the results should be inserted
748 into the org-mode file
749 - replace :: the current results replace any previously inserted
750 results from the code block
751 - silent :: rather than being inserted into the org-mode file the
752 results are echoed into the message bar
753 - exports :: exports arguments specify what should be included in html
754 or latex exports of the org-mode file
755 - code :: the body of code is included into the exported file
756 - results :: the results of evaluating the code is included in the
758 - both :: both the code and results are included in the exported
760 - none :: nothing is included in the exported file
761 - tangle :: tangle arguments specify whether or not the source-code
762 block should be included in tangled extraction of
764 - yes :: the source-code block is exported to a source-code file
765 named after the basename (name w/o extension) of the
767 - no :: (default) the source-code block is not exported to a
769 - other :: any other string passed to the =tangle= header argument
770 is interpreted as a file basename to which the block will
773 *** Noweb reference syntax
774 The [[http://www.cs.tufts.edu/~nr/noweb/][Noweb]] Literate Programming system allows named blocks of code to
775 be referenced by using a =<<code-block-name>>= syntax. When a
776 document is tangled these references are replaced with the named code.
777 An example is provided in the [[literate-programming-example]] in this
782 [fn:1] Calling =C-c C-o= on a source-code block will open the
783 block's results in a separate buffer.