Next: , Previous: , Up: Working With Source Code   [Contents][Index]

14.1 Structure of code blocks

Live code blocks can be specified with a ‘src’ block or inline.168 The structure of a ‘src’ block is

#+NAME: <name>
#+BEGIN_SRC <language> <switches> <header arguments>

The #+NAME: line is optional, and can be used to name the code block. Live code blocks require that a language be specified on the #+BEGIN_SRC line. Switches and header arguments are optional.

Live code blocks can also be specified inline using



src_<language>[<header arguments>]{<body>}
<#+NAME: name>

This line associates a name with the code block. This is similar to the #+NAME: Name lines that can be used to name tables in Org mode files. Referencing the name of a code block makes it possible to evaluate the block from other places in the file, from other files, or from Org mode table formulas (see The spreadsheet). Names are assumed to be unique and the behavior of Org mode when two or more blocks share the same name is undefined.


The language of the code in the block (see Languages).


Optional switches control code block export (see the discussion of switches in Literal examples)

<header arguments>

Optional header arguments control many aspects of evaluation, export and tangling of code blocks (see Header arguments). Header arguments can also be set on a per-buffer or per-subtree basis using properties.

source code, header arguments

Source code in the specified language.



Note that ‘src’ blocks may be inserted using Org mode’s Easy Templates system

Next: , Previous: , Up: Working With Source Code   [Contents][Index]