Initial Commit
[packages] / xemacs-packages / ocaml / README
1         O'Caml emacs mode, snapshot of $Date: 2002/08/05 02:05:42 $
2
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.
6
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.
10
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.
14
15 To use it, just put the .el files in your path, and add the following
16 three lines in your .emacs.
17
18     (setq auto-mode-alist
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)
22
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
25 it.
26
27 To install the mode itself, edit the Makefile and do
28
29     % make install
30
31 To install ocamltags, do
32
33     % make install-ocamltags
34
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
37 emacs.
38
39     (if window-system (require 'caml-hilit))
40     (if window-system (require 'caml-font))
41
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.
45
46 Main key bindings:
47
48 TAB indent current line
49 M-C-q   indent phrase
50 M-C-h   mark phrase
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)
54
55 Once you have started caml by M-x run-caml:
56
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
61
62 For other bindings, see C-h b.
63
64 Changes log:
65 -----------
66
67 Version 3.05:
68 -------------
69 * improved interaction with inferior caml mode
70
71 * access help from the source
72
73 * fixes in indentation code
74
75 Version 3.03:
76 -------------
77 * process ;; properly
78
79 Version 3.00:
80 -------------
81 * adapt to new label syntax
82
83 * intelligent indentation of parenthesis
84
85 Version 2.02:
86 -------------
87 * improved ocamltags <ITZ and JG>
88
89 * added support for multibyte characters in emacs 20
90
91 Version 2.01+:
92 --------------
93 * corrected a bug in caml-font.el <Adam P. Jenkins>
94
95 * corrected abbreviations and added ocamltags script <Ian T Zimmerman>
96
97 Version 2.01:
98 ------------
99 * code for interactive errors added by ITZ
100
101 Version 2.00:
102 ------------
103 * changed the algorithm to skip comments
104
105 * adapted for the new object syntax
106
107 Version 1.07:
108 ------------
109 * next-error bug fix by John Malecki
110
111 * camldebug.el modified by Xavier Leroy
112
113 Version 1.06:
114 ------------
115 * new keywords in O'Caml 1.06
116
117 * compatibility with GNU Emacs 20
118
119 * changed from caml-imenu-disable to caml-imenu-enable (off by default)
120
121 Version 1.05:
122 ------------
123 * a few indentation bugs corrected. let, val ... are now indented
124   correctly even when you write them at the beginning of a line.
125
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.
129
130 * key bindings closer to lisp-mode.
131
132 * O'Labl compatibility (":" is part of words) may be switched off by
133   setting caml-olabl-disable to t.
134
135 * camldebug.el was updated by Xavier Leroy.
136
137 Version 1.03b:
138 -------------
139 * many bugs corrected.
140
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.
147
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
152   miracle.
153
154 * nicer behaviour when sending a phrase/region to the inferior caml
155   process.
156
157 Version 1.03:
158 ------------
159 * support of Objective Caml and Objective Label.
160
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.
164
165 * highlighting.
166
167 Some remarks about the style supported:
168 --------------------------------------
169
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.
174
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.
181
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!
188
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.
195
196 Comments and bug reports to
197
198     Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>