Babel: Languages
executable source code blocks in org-mode
The Babel Fish is small, yellow, and simultaneously translates from one spoken language to another.
– The Hitchhiker's Guide to the Galaxy, Douglas Adams
Table of Contents
Babel Languages
| Language | Documentation | Identifier | Requirements |
|---|---|---|---|
| Asymptote | ob-doc-asymptote | asymptote | asymptote, asy-mode |
| C | ob-doc-C | C | none |
| Clojure | ob-doc-clojure | clojure | clojure, clojure-mode, slime, swank-clojure |
| css | ob-doc-css | css | none |
| ditaa | ob-doc-ditaa | ditaa | ditaa (bundled with Org-mode) |
| Graphviz | ob-doc-dot | dot | dot |
| Emacs Lisp | ob-doc-emacs-lisp | emacs-lisp | none |
| gnuplot | ob-doc-gnuplot | gnuplot | gnuplot, gnuplot-mode |
| Haskell | ob-doc-haskell | haskell | haskell, haskell-mode, inf-haskell, lhs2tex |
| Javascript | ob-doc-js | js | node.js |
| LaTeX | ob-doc-latex | latex | latex, auctex, reftex |
| Ledger | ob-doc-ledger | ledger | ledger |
| Lisp | ob-lisp | lisp | slime |
| Matlab | ob-doc-octave-matlab | matlab | matlab, matlab.el |
| mscgen | ob-doc-mscgen | mscgen | Mscgen |
| Objective Caml | ob-doc-ocaml | ocaml | ocaml, tuareg-mode |
| Octave | ob-doc-octave-matlab | octave | octave |
| OZ | ob-doc-oz | oz (contrib) | Mozart which includes a major mode |
| Perl | ob-doc-perl | perl | perl, cperl-mode (optional) |
| PlantUML | ob-doc-plantuml | plantuml | |
| Python | ob-doc-python | python | python, python-mode (optional) |
| R | ob-doc-R | R | R, ess-mode |
| Ruby | ob-doc-ruby | ruby | ruby, irb, ruby-mode, inf-ruby mode |
| Sass | ob-doc-sass | sass | sass, sass-mode |
| Scheme | ob-doc-scheme | scheme | none |
| GNU Screen | ob-doc-screen | screen | screen, a terminal |
| shell | ob-doc-sh | sh | a shell |
| SQL | ob-doc-sql | sql | none |
| Sqlite | ob-sqlite | sqlite | none |
Configure active languages
To add support for a particular language to your Babel installation
first make sure that the requirements of the language are met, then
you may customize the org-babel-load-languages variable, update the
variable's value manually by adding1
(lang . t)
to it's definition. A line like the following to explicitly remove support for a language.
(lang . nil)
Here is an example manual configuration of this variable, which
enables support for R, and disables support for emacs-lisp.
;; active Babel languages (org-babel-do-load-languages 'org-babel-load-languages '((R . t) (emacs-lisp . nil) ))
Develop support for new languages
The core Babel functions (viewing, export, tangling, etc…) are language agnostic and will work even for languages that are not explicitly supported. Explicit language-specific support is required only for evaluation of code blocks in a language.
Babel is designed to be easily extended to support new languages. Language support is added by defining language-specific functions using a simple naming convention. The full suite of possible language specific functions need not be implemented all at once, but rather it is possible (and encouraged) to develop language-specific functionality in an incremental fashion – Babel will make use of those functions which are available, and will fail gracefully when functionality has not yet been implemented.
There is a short Emacs Lisp template (ob-template.el) which can be used as a starting point for implementing support for new languages. Developers are encouraged to read the Org-mode contribution instructions in the hopes that the language support can be included into the Org-mode core.
Footnotes:
1 languages in the contrib directory are marked with "(contrib)"
in the "Identifier" section above are not loadable through the
org-babel-do-load-languages variable, but rather must be
explicitly required (e.g. (require 'ob-oz)) after the contrib
directory has been added to you load path.