Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Git mirror of tuareg-mode (OCaml mode for emacs)
Emacs Lisp
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.



This archive contains files to help editing Caml code, to hilight
important parts of the code, to run a Caml toplevel, and to run the
Caml debugger within GNU Emacs/XEmacs editors. It is designed for
Objective Caml but handles Camllight syntax as well.


  README             This file.
  HISTORY            Differences with previous versions.
  tuareg.el          A major mode for editing Tuareg code in Emacs/XEmacs.
  sym-lock.el        An extension to XEmacs Font-Lock for symbol fontifying.
  camldebug.el       To run the Caml debugger under Emacs.
  append-tuareg.el   Configuration file for quick installation
  custom-tuareg.el   Tuareg customization example


  If you have the right to put files in Emacs / XEmacs `site-lisp'
  directory, you only have to copy the `tuareg.el', `camldebug.el'
  and `sym-lock.el' files in it (Sym-Lock works with XEmacs only).

  Otherwise, choose a directory, e.g., `foo'. Copy the `tuareg.el'
  `camldebug.el' and `sym-lock.el' files in it (Sym-Lock works with
  XEmacs only). Then add the following line to your `.emacs', where
  `foo' is replaced by the appropriate directory FULL PATH:

  (setq load-path (cons "foo" load-path))


  If you are no Emacs-Lisp addict, and would like to use Tuareg
  NOW, append (or copy) `append-tuareg.el' file to your `.emacs'
  configuration file. It tells XEmacs to load Tuareg and Sym-Lock

  Consider updating your `.emacs' configuration file by hand if you
  keep on using Tuareg.


  Add the following lines to your .emacs file:

  (setq auto-mode-alist (cons '("\\.ml\\w?" . tuareg-mode) auto-mode-alist))
  (autoload 'tuareg-mode "tuareg" "Major mode for editing Caml code" t)
  (autoload 'camldebug "camldebug" "Run the Caml debugger" t)

  The Tuareg major mode is triggered by visiting a file with extension
  .ml, .mli, .mly, .mll, .mlp... or manually by M-x tuareg-mode. It
  gives you the correct syntax table for the Caml language.

  If you use XEmacs, the Font-Lock minor-mode is used accordingly to
  your customization options.

  Within Emacs, you may want to use Font-Lock in addding the following
  lines to the configuration file:

  (if (and (boundp 'window-system) window-system)
      (require 'font-lock))

  Within XEmacs (more generally, if you have variable-sized fonts and
  `atomic-extents' library supported) you may also want to use
  Sym-Lock Warning: MULE (multilingual) versions of XEmacs do not
  support multiple font encodings in a single buffer, which is
  required by Sym-Lock. Configuring Tuareg with Sym-Lock is done as

  (if (and (boundp 'window-system) window-system)
      (when (string-match "XEmacs" emacs-version)
       	  (if (not (and (boundp 'mule-x-win-initted) mule-x-win-initted))
              (require 'sym-lock))
       	  (require 'font-lock)))


  Tuareg allows you to run batch Caml compilations from Emacs (using
  M-x compile) and browse the errors (C-x `). Typing C-x ` sets the
  point at the beginning of the erroneous program fragment, and the
  mark at the end. Under Emacs, the program fragment is temporarily

  M-x tuareg-run-caml starts a Caml toplevel with input and output in
  an Emacs buffer named `*caml-toplevel*. This gives you the full
  power of Emacs to edit the input to the Caml toplevel. This mode is
  based on comint so you get all the usual comint features, including
  command history. A hook named `tuareg-interactive-mode-hook' may be
  used for customization.

  Typing C-c C-e in a buffer in Caml mode sends the current phrase
  (containing the point) to the Caml toplevel, and evaluates it. If
  you type one of these commands before M-x tuareg-run-caml, the
  toplevel will be started automatically.

  M-x camldebug FILE starts the Caml debugger camldebug on the
  executable FILE, with input and output in an Emacs buffer named
  *camldebug-FILE*. It is similar to April 1996 version, with minor
  changes to support XEmacs, Tuareg and OCaml. Furthermore, package
  `thingatpt' is not required any more.


  The standard Emacs customization tool can be used to configure
  Tuareg options. It is available from the Options menu and Tuareg's
  Customize sub-menu.

  You may also customize the appearance of Caml code by twiddling the
  variables listed at the start of tuareg.el (preferably using
  `tuareg-mode-hook', you should not patch the file directly). You
  should then add to your configuration file something like: (add-hook
  'tuareg-mode-hook '(lambda () ... ; your customization code ))

  `custom-tuareg.el' is a sample customization file for standard
  changes. You can append it to your `.emacs' or use it as a tutorial.


  Cf. online help.


  Ian Zimmerman for the previous mode, compilation interface and
  debugger enhancement.

  Jacques Garrigue enhanced Zimmerman's mode along with an adaptation
  to Objective Caml (and Labl) syntax. Although this work was
  performed independently, his useful test file and comments were of
  great help.

  Michel Quercia for excellent suggestions, patches, and helpful
  emacs-lisp contributions (full, ready-to-work implementations, I
  should say), especially for Tuareg interactive mode, and browser

  Denis Barthou, Pierre Boulet, Jean-Christophe Filliatre and Rémi
  Vanicat for intensive testing, useful suggestions, and help.

  Ralf Treinen for maintaining the Debian GNU/Linux package.

  Every people who sent me bug reports, suggestions, comments and
  patches. Nothing would have improved since version 0.9.2 without
  their help. Special thanks to Eli Barzilay, Josh Berdine, Christian
  Boos, Carsten Clasohm, Yann Coscoy, Prakash Countcham, Alvarado
  Cuihtlauac, Erwan David, Gilles Défourneaux, Philippe Esperet,
  Gilles Falcon, Tim Freeman, Alain Frisch, Christian Lindig, Claude
  Marché, Charles Martin, Dave Mason, Stefan Monnier, Toby Moth,
  Jean-Yves Moyen, Alex Ott, Christopher Quinn, Ohad Rodeh, Rauli
  Ruohonen, Hendrik Tews, Christophe Troestler, Joseph Sudish, Mattias
  Waldau and John Whitley.


  The official Tuareg home page is located at:

  Bug reports, suggestions, donations etc. to:

  Albert Cohen
  Research Scientist - INRIA Rocquencourt

  E-Mail     :
  WWW        :
Something went wrong with that request. Please try again.