1 O'Caml emacs mode, snapshot of $Date: 2008-01-11 17:13:18 +0100 (Fri, 11 Jan 2008) $
3 The files in this archive define a caml-mode for emacs, for editing
4 Objective Caml and Objective Label programs, as well as an
5 inferior-caml-mode, to run a toplevel.
7 Caml-mode supports indentation, compilation and error retrieving,
8 sending phrases to the toplevel. Moreover support for hilit,
9 font-lock and imenu was added.
11 This package is based on the original caml-mode for caml-light by
12 Xavier Leroy, extended with indentation by Ian Zimmerman. For details
13 see README.itz, which is the README from Ian Zimmerman's package.
15 To use it, just put the .el files in your path, and add the following
16 three lines in your .emacs.
19 (cons '("\\.ml[iylp]?$" . caml-mode) auto-mode-alist))
20 (autoload 'caml-mode "caml" "Major mode for editing Caml code." t)
21 (autoload 'run-caml "inf-caml" "Run an inferior Caml process." t)
23 I added camldebug.el from the original distribution, since there will
24 soon be a debugger for Objective Caml, but I do not know enough about
27 To install the mode itself, edit the Makefile and do
31 To install ocamltags, do
33 % make install-ocamltags
35 To use highlighting capabilities, add ONE of the following two lines
36 to your .emacs. The second one works better on recent versions of
39 (if window-system (require 'caml-hilit))
40 (if window-system (require 'caml-font))
42 caml.el and inf-caml.el can be used collectively, but it might be a
43 good idea to copy caml-hilit.el or caml-font.el to you own directory,
44 and edit it to your taste and colors.
48 TAB indent current line
51 C-c C-a switch between interface and implementation
52 C-c C-c compile (usually make)
53 C-x` goto next error (also mouse button 2 in the compilation log)
55 Once you have started caml by M-x run-caml:
57 M-C-x send phrase to inferior caml process
58 C-c C-r send region to inferior caml process
59 C-c C-s show inferior caml process
60 C-c` goto error in expression sent by M-C-x
62 For other bindings, see C-h b.
68 * use caml-font.el from Olivier Andrieu
69 old version is left as caml-font-old.el for compatibility
73 * support for showing type information <Damien Doligez>
77 * improved interaction with inferior caml mode
79 * access help from the source
81 * fixes in indentation code
89 * adapt to new label syntax
91 * intelligent indentation of parenthesis
95 * improved ocamltags <ITZ and JG>
97 * added support for multibyte characters in emacs 20
101 * corrected a bug in caml-font.el <Adam P. Jenkins>
103 * corrected abbreviations and added ocamltags script <Ian T Zimmerman>
107 * code for interactive errors added by ITZ
111 * changed the algorithm to skip comments
113 * adapted for the new object syntax
117 * next-error bug fix by John Malecki
119 * camldebug.el modified by Xavier Leroy
123 * new keywords in O'Caml 1.06
125 * compatibility with GNU Emacs 20
127 * changed from caml-imenu-disable to caml-imenu-enable (off by default)
131 * a few indentation bugs corrected. let, val ... are now indented
132 correctly even when you write them at the beginning of a line.
134 * added a Caml menu, and Imenu support. Imenu menu can be disabled
135 by setting the variable caml-imenu-disable to t.
136 Xemacs support for the Menu, but no Imenu.
138 * key bindings closer to lisp-mode.
140 * O'Labl compatibility (":" is part of words) may be switched off by
141 setting caml-olabl-disable to t.
143 * camldebug.el was updated by Xavier Leroy.
147 * many bugs corrected.
149 * (partial) compatibility with Caml-Light added.
150 (setq caml-quote-char "`")
151 (setq inferior-caml-program "camllight")
152 Literals will be correctly understood and highlighted. However,
153 indentation rules are still Objective Caml's: this just happens to
154 work well in most cases, but is only intended for occasional use.
156 * as many people asked for it, application is now indented. This seems
157 to work well: this time differences in indentation between the
158 compiler's source and this mode are really exceptionnal. On the
159 other hand, you may think that some special cases are strange. No
162 * nicer behaviour when sending a phrase/region to the inferior caml
167 * support of Objective Caml and Objective Label.
169 * an indentation very close to mine, which happens to be the same as
170 Xavier's, since the sources of the Objective Caml compiler do not
171 change if you indent them in this mode.
175 Some remarks about the style supported:
176 --------------------------------------
178 Since Objective Caml's syntax is very liberal (more than 100
179 shift-reduce conflicts with yacc), automatic indentation is far from
180 easy. Moreover, you expect the indentation to be not purely syntactic,
181 but also semantic: reflecting the meaning of your program.
183 This mode tries to be intelligent. For instance some operators are
184 indented differently in the middle and at the end of a line (thanks to
185 Ian Zimmerman). Also, we do not indent after if .. then .. else, when
186 else is on the same line, to reflect that this idiom is equivalent to
187 a return instruction in a more imperative language, or after the in of
188 let .. in, since you may see that as an assignment.
190 However, you may want to use a different indentation style. This is
191 made partly possible by a number of variables at the beginning of
192 caml.el. Try to set them. However this only changes the size of
193 indentations, not really the look of your program. This is enough to
194 disable the two idioms above, but to do anything more you will have to
195 edit the code... Enjoy!
197 This mode does not force you to put ;; in your program. This means
198 that we had to use a heuristic to decide where a phrase starts and
199 stops, to speed up the code. A phrase starts when any of the keywords
200 let, type, class, module, functor, exception, val, external, appears
201 at the beginning of a line. Using the first column for such keywords
202 in other cases may confuse the phrase selection function.
204 Comments and bug reports to
206 Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>