UP | HOME

Babel: Languages

executable source code blocks in org-mode

Babel Fish

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

Babel has support for the following languages.
LanguageDocumentationIdentifierRequirements
Asymptoteob-doc-asymptoteasymptoteasymptote, asy-mode
Cob-doc-CCnone
Clojureob-doc-clojureclojureclojure, clojure-mode, slime, swank-clojure
cssob-doc-csscssnone
ditaaob-doc-ditaaditaaditaa (bundled with Org-mode)
Graphvizob-doc-dotdotdot
Emacs Lispob-doc-emacs-lispemacs-lispnone
gnuplotob-doc-gnuplotgnuplotgnuplot, gnuplot-mode
Haskellob-doc-haskellhaskellhaskell, haskell-mode, inf-haskell, lhs2tex
Javascriptob-doc-jsjsnode.js
LaTeXob-doc-latexlatexlatex, auctex, reftex
Ledgerob-doc-ledgerledgerledger
Lispob-lisplispslime
Matlabob-doc-octave-matlabmatlabmatlab, matlab.el
mscgenob-doc-mscgenmscgenMscgen
Objective Camlob-doc-ocamlocamlocaml, tuareg-mode
Octaveob-doc-octave-matlaboctaveoctave
OZob-doc-ozoz (contrib)Mozart which includes a major mode
Perlob-doc-perlperlperl, cperl-mode (optional)
PlantUMLob-doc-plantumlplantuml
Pythonob-doc-pythonpythonpython, python-mode (optional)
Rob-doc-RRR, ess-mode
Rubyob-doc-rubyrubyruby, irb, ruby-mode, inf-ruby mode
Sassob-doc-sasssasssass, sass-mode
Schemeob-doc-schemeschemenone
GNU Screenob-doc-screenscreenscreen, a terminal
shellob-doc-shsha shell
SQLob-doc-sqlsqlnone
Sqliteob-sqlitesqlitenone

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.