1 O'Caml emacs mode, snapshot of $Date: 2002/08/05 02:05:42 $
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.
69 * improved interaction with inferior caml mode
71 * access help from the source
73 * fixes in indentation code
81 * adapt to new label syntax
83 * intelligent indentation of parenthesis
87 * improved ocamltags <ITZ and JG>
89 * added support for multibyte characters in emacs 20
93 * corrected a bug in caml-font.el <Adam P. Jenkins>
95 * corrected abbreviations and added ocamltags script <Ian T Zimmerman>
99 * code for interactive errors added by ITZ
103 * changed the algorithm to skip comments
105 * adapted for the new object syntax
109 * next-error bug fix by John Malecki
111 * camldebug.el modified by Xavier Leroy
115 * new keywords in O'Caml 1.06
117 * compatibility with GNU Emacs 20
119 * changed from caml-imenu-disable to caml-imenu-enable (off by default)
123 * a few indentation bugs corrected. let, val ... are now indented
124 correctly even when you write them at the beginning of a line.
126 * added a Caml menu, and Imenu support. Imenu menu can be disabled
127 by setting the variable caml-imenu-disable to t.
128 Xemacs support for the Menu, but no Imenu.
130 * key bindings closer to lisp-mode.
132 * O'Labl compatibility (":" is part of words) may be switched off by
133 setting caml-olabl-disable to t.
135 * camldebug.el was updated by Xavier Leroy.
139 * many bugs corrected.
141 * (partial) compatibility with Caml-Light added.
142 (setq caml-quote-char "`")
143 (setq inferior-caml-program "camllight")
144 Literals will be correctly understood and highlighted. However,
145 indentation rules are still Objective Caml's: this just happens to
146 work well in most cases, but is only intended for occasional use.
148 * as many people asked for it, application is now indented. This seems
149 to work well: this time differences in indentation between the
150 compiler's source and this mode are really exceptionnal. On the
151 other hand, you may think that some special cases are strange. No
154 * nicer behaviour when sending a phrase/region to the inferior caml
159 * support of Objective Caml and Objective Label.
161 * an indentation very close to mine, which happens to be the same as
162 Xavier's, since the sources of the Objective Caml compiler do not
163 change if you indent them in this mode.
167 Some remarks about the style supported:
168 --------------------------------------
170 Since Objective Caml's syntax is very liberal (more than 100
171 shift-reduce conflicts with yacc), automatic indentation is far from
172 easy. Moreover, you expect the indentation to be not purely syntactic,
173 but also semantic: reflecting the meaning of your program.
175 This mode tries to be intelligent. For instance some operators are
176 indented differently in the middle and at the end of a line (thanks to
177 Ian Zimmerman). Also, we do not indent after if .. then .. else, when
178 else is on the same line, to reflect that this idiom is equivalent to
179 a return instruction in a more imperative language, or after the in of
180 let .. in, since you may see that as an assignment.
182 However, you may want to use a different indentation style. This is
183 made partly possible by a number of variables at the beginning of
184 caml.el. Try to set them. However this only changes the size of
185 indentations, not really the look of your program. This is enough to
186 disable the two idioms above, but to do anything more you will have to
187 edit the code... Enjoy!
189 This mode does not force you to put ;; in your program. This means
190 that we had to use a heuristic to decide where a phrase starts and
191 stops, to speed up the code. A phrase starts when any of the keywords
192 let, type, class, module, functor, exception, val, external, appears
193 at the beginning of a line. Using the first column for such keywords
194 in other cases may confuse the phrase selection function.
196 Comments and bug reports to
198 Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>