org: results
14.8.2.2 ‘:results’
...................
There are four classes of ‘:results’ header argument. Only one option
per class may be supplied per code block.
• collection header arguments specify how the results should be
collected from the code block
• type header arguments specify what type of result the code block
will return—which has implications for how they will be processed
before insertion into the Org mode buffer
• format header arguments specify what type of result the code block
will return—which has implications for how they will be inserted
into the Org mode buffer
• handling header arguments specify how the results of evaluating the
code block should be handled.
Collection
..........
The following options are mutually exclusive, and specify how the
results should be collected from the code block.
• ‘value’ This is the default. The result is the value of the last
statement in the code block. This header argument places the
evaluation in functional mode. Note that in some languages, e.g.,
Python, use of this result type requires that a ‘return’ statement
be included in the body of the source code block. E.g., ‘:results
value’.
• ‘output’ The result is the collection of everything printed to
STDOUT during the execution of the code block. This header
argument places the evaluation in scripting mode. E.g., ‘:results
output’.
Type
....
The following options are mutually exclusive and specify what type of
results the code block will return. By default, results are inserted as
either a table or scalar depending on their value.
• ‘table’, ‘vector’ The results should be interpreted as an Org mode
table. If a single value is returned, it will be converted into a
table with one row and one column. E.g., ‘:results value table’.
• ‘list’ The results should be interpreted as an Org mode list. If a
single scalar value is returned it will be converted into a list
with only one element.
• ‘scalar’, ‘verbatim’ The results should be interpreted
literally—they will not be converted into a table. The results
will be inserted into the Org mode buffer as quoted text. E.g.,
‘:results value verbatim’.
• ‘file’ The results will be interpreted as the path to a file, and
will be inserted into the Org mode buffer as a file link. E.g.,
‘:results value file’.
Format
......
The following options are mutually exclusive and specify what type of
results the code block will return. By default, results are inserted
according to the type as specified above.
• ‘raw’ The results are interpreted as raw Org mode code and are
inserted directly into the buffer. If the results look like a
table they will be aligned as such by Org mode. E.g., ‘:results
value raw’.
• ‘org’ The results are will be enclosed in a ‘BEGIN_SRC org’ block.
They are not comma-escaped by default but they will be if you hit
‘TAB’ in the block and/or if you export the file. E.g., ‘:results
value org’.
• ‘html’ Results are assumed to be HTML and will be enclosed in a
‘BEGIN_HTML’ block. E.g., ‘:results value html’.
• ‘latex’ Results assumed to be LaTeX and are enclosed in a
‘BEGIN_LaTeX’ block. E.g., ‘:results value latex’.
• ‘code’ Result are assumed to be parsable code and are enclosed in a
code block. E.g., ‘:results value code’.
• ‘pp’ The result is converted to pretty-printed code and is enclosed
in a code block. This option currently supports Emacs Lisp,
Python, and Ruby. E.g., ‘:results value pp’.
• ‘drawer’ The result is wrapped in a RESULTS drawer. This can be
useful for inserting ‘raw’ or ‘org’ syntax results in such a way
that their extent is known and they can be automatically removed or
replaced.
Handling
........
The following results options indicate what happens with the results
once they are collected.
• ‘silent’ The results will be echoed in the minibuffer but will not
be inserted into the Org mode buffer. E.g., ‘:results output
silent’.
• ‘replace’ The default value. Any existing results will be removed,
and the new results will be inserted into the Org mode buffer in
their place. E.g., ‘:results output replace’.
• ‘append’ If there are pre-existing results of the code block then
the new results will be appended to the existing results.
Otherwise the new results will be inserted as with ‘replace’.
• ‘prepend’ If there are pre-existing results of the code block then
the new results will be prepended to the existing results.
Otherwise the new results will be inserted as with ‘replace’.