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) noexport(n)
5 #+TITLE: Header arguments and result types in Org Babel
6 #+AUTHOR: Thorsten Jolitz, Eric Schulte
7 #+EMAIL: tj[at]data-driven[dot]de
9 #+HTML_LINK_UP: index.php
10 #+HTML_LINK_HOME: https://orgmode.org/worg/
11 #+EXPORT_EXCLUDE_TAGS: noexport
13 For a complete header argument reference see the Org-mode manual's
14 page which lists all [[https://orgmode.org/manual/Specific-header-arguments.html][Specific-header-arguments]]. This page holds
15 ancillary notes and tricks which have not made it into the manual.
17 * Generally use =verbatim= when using =drawer=, =raw= or =org=
18 We often want to add =verbatim= (which inhibits interpretation as a
19 value, which can often result in a list or table result), when
20 inserting results directly into the buffer using =drawer=, =raw= or
21 =org= which don't do tabular interpretation.
23 An example w/o =verbatim=.
24 : #+begin_src sh :results drawer
39 The same block /with/ the =verbatim= flag.
40 : #+begin_src sh :results verbatim drawer
55 * Common combinations of header-args and result types
56 Many combinations of header arguments and result types are
57 supported by Org Babel. Individual languages may even define
58 special header args. Like always in combinatorics, the number
59 of possible combinations increases rapidly when there are several
60 factors with several levels each that can be freely combined.
62 The following table shows combinations of header arguments and
63 result types that might be considered reasonable for many
64 programming languages.
66 | evaluation | collection | type |
67 | (:session) | (:results) | (:results) |
68 |------------+------------+-------------------|
69 | external | value | table (vector) |
70 | | | scalar (verbatim) |
77 | | output | table (vector) |
78 | | | scalar (verbatim) |
85 | session | value | table (vector) |
86 | | | scalar (verbatim) |
93 | | output | table (vector) |
94 | | | scalar (verbatim) |
102 More special header arguments and their possible values are
103 summarized in the next table:
105 | header-arg | | values | | |
106 |------------+----------+---------+----------+---------|
107 | :results | silent | replace | append | prepend |
108 | (handling) | | | | |
109 | :exports | code | results | both | none |
110 | :comments | yes | (no?) | | |
111 | :noweb | no | yes | | |
112 | :tangle | yes | no | filename | |
113 | :no-expand | | | | |
116 | :cache | no | yes | | |
118 | :hlines | no | yes | | |
119 | :colnames | nil | no | yes | |
120 | :rownames | no | yes | | |
121 | :shebang | "string" | | | |
122 | :eval | never | query | | |
124 * Setting language and file specific default header argument values
125 This may be useful to e.g., have all Python code blocks in a file use
126 the same session. The following file-local-variable syntax should be
127 used, placing the customization at the end of the Org-mode file.
129 : #+Title: Example of default file and language session
131 : The value in this buffer is...
132 : #+begin_src emacs-lisp
133 : org-babel-default-header-args:Python
137 : | (:session . foo) |
140 : # eval: (setq-local org-babel-default-header-args:Python '((:session . "foo")))