Initial Commit
[packages] / xemacs-packages / ocaml / README.itz
1 DESCRIPTION:
2
3 This directory contains files to help editing Caml code, running a
4 Caml toplevel, and running the Caml debugger under the Gnu Emacs editor.
5
6 AUTHORS:
7
8 Ian T Zimmerman <itz@rahul.net> added indentation to caml mode, beefed
9 up camldebug to work much like gud/gdb.
10
11 Xavier Leroy (Xavier.Leroy@inria.fr), Jerome Vouillon (Jerome.Vouillon@ens.fr).
12 camldebug.el is derived from FSF code.
13
14 CONTENTS:
15
16     caml.el         A major mode for editing Caml code in Gnu Emacs
17     inf-caml.el     To run a Caml toplevel under Emacs, with input and
18                     output in an Emacs buffer.
19     camldebug.el    To run the Caml debugger under Emacs.
20
21
22 NOTE FOR EMACS 18 USERS:
23
24 This package will no longer work with Emacs 18.x. Sorry. You really
25 should consider upgrading to Emacs 19.
26
27 USAGE:
28
29 Add the following lines to your .emacs file:
30
31 (setq auto-mode-alist (cons '("\\.ml[iylp]?" . caml-mode) auto-mode-alist))
32 (autoload 'caml-mode "caml" "Major mode for editing Caml code." t)
33 (autoload 'run-caml "inf-caml" "Run an inferior Caml process." t)
34 (autoload 'camldebug "camldebug" "Run the Caml debugger." t)
35
36 The Caml major mode is triggered by visiting a file with extension .ml,
37 .mli, .mly. .mll or .mlp, or manually by M-x caml-mode. It gives you the
38 correct syntax table for the Caml language. For a brief description of
39 the indentation capabilities, see below under NEWS.
40
41 The Caml mode also allows you to run batch Caml compilations from
42 Emacs (using M-x compile) and browse the errors (C-x `). Typing C-x `
43 sets the point at the beginning of the erroneous program fragment, and
44 the mark at the end. Under Emacs 19, the program fragment is
45 temporarily highlighted.
46
47 M-x run-caml starts a Caml toplevel with input and output in an Emacs
48 buffer named *inferior-caml*. This gives you the full power of Emacs
49 to edit the input to the Caml toplevel. This mode is based on comint
50 so you get all the usual comint features, including command history.
51
52 After M-x run-caml, typing C-c C-e or M-C-x in a buffer in Caml mode
53 sends the current phrase (containing the point) to the Caml toplevel,
54 and evaluates it.
55
56 M-x camldebug FILE starts the Caml debugger camldebug on the executable
57 FILE, with input and output in an Emacs buffer named *camldebug-FILE*.
58 For a brief description of the commands available in this buffer, see
59 NEWS below.
60
61 NEWS:
62
63 Ok, so this is the really important part of this file :-) I took the
64 original package from the contrib subdirectory of the caml-light
65 distribution, and hacked on it. First, I added real syntax dependent
66 indentation to caml mode. Like Xavier has said, it was hard (and I
67 knew it would be), but I refused to believe it was impossible, partly
68 because I knew of a Standard ML mode with indentation (written by
69 Matthew Morley).
70
71 Indentation works pretty much like in other programming modes. C-j at
72 the end of a line starts a new line properly indented. M-C-\ indents
73 the current region (this may take a while :-)). I incorporated a
74 slightly different TAB function, one that I use in other modes: if TAB
75 is pressed while the point is not in line indentation, the line is
76 indented to the column where point is (instead of just inserting a TAB
77 character - you can always to that with C-q C-i). This way, you can
78 indent a line any time, regardless of where the point lies, by hitting
79 TAB twice in succession. If you don't like this behaviour (but you
80 should), it's quite easy to add to your startup code like this:
81
82 (defun caml-old-style-indent ()
83         (if (caml-in-indentation)
84                 (caml-indent-command)
85                 (insert "\t")))
86
87 (add-hook 'caml-mode-hook
88         (function (lambda ()
89                 (define-key 'caml-mode-map "\t"
90                         caml-old-style-indent))))
91
92 You can customize the appearance of your caml code by twiddling the
93 variables listed at the start of caml.el. Good luck. :-)
94
95 Other news in caml mode are the various caml-insert-*-form commands. I
96 believe they are self-explanatory - just do a C-h m in a caml buffer
97 to see what you've got.
98
99 The ohter major news is that I changed camldebug mode considerably. I
100 took many clues from the gud "Grand Unified Debugger" mode distributed
101 with modern versions of Emacs. The main benefit here is that you can
102 do debugger commands _from your caml source buffer_. Commands with the
103 C-c prefix in the debugger buffer have counterparts which do the same
104 thing (well, a similar thing) in the source buffer, with the C-x C-a
105 prefix.
106
107 I made the existing debugger commands smarter in that they now attempt
108 to guess the correct parameter to the underlying camldebug command. A
109 numeric argument will always override that guess. For example, the
110 guess for C-c C-b (camldebug-break) is to set a breakpoint at the
111 current event (which was the only behaviour provided with the old
112 camldebug.el). But C-u 1 C-c C-b will now send "break 1" to the
113 camldebug process, setting a break at code address 1.
114
115 This also allowed me to add many more commands for which the
116 underlying camldebug commands require a parameter. The best way to
117 learn about them is to do C-h m in the camldebug buffer, and then C-h
118 f for the commands you'll see listed.
119
120 Finally, I added command completion. To use it, you'll have to apply
121 the provided patch to the debugger itself
122 (contrib/debugger/command_line_interpreter.ml), and recompile it
123 (you'll get one warning from the compiler; it is safe to ignore
124 it). Then hitting TAB in the following situation, for example:
125
126 (cdb) pri_
127
128 will complete the "pri" to "print".
129
130 CAVEATS:
131
132 I don't use X and haven't tested this stuff under the X mode of
133 emacs. It is entirely possible (though not very probable) that I
134 introduced some undesirable interaction between X (fontification,
135 highlighting,...) and caml mode. I will welcome reports of such
136 problems (see REPORTING below), but I won't be able to do much about
137 them unless you also provide a patch.
138
139 I don't know if the informational messages produced by camldebug are
140 internationalized. If they are, the debugger mode won't work unless
141 you set the language to English. The mode uses the messages to
142 synchronize with camldebug, and looks for fixed Emacs regular
143 expressions that match them. This may be fixed (if necessary) in a
144 future release.
145
146 BUGS:
147
148 In the debugger buffer, it's possible to overflow your mental stack by
149 asking for help on help on help on help on help on help on help on
150 help...
151
152 THANKS:
153
154 Xavier Leroy <Xavier.Leroy@inria.fr> for Caml-light. Used together with the
155 Emacs interface, it is about the most pleasant programming environment
156 I've known on any platform.
157
158 Eric Raymond <esr@thyrsus.com> for gud, which camldebug mode apes.
159
160 Barry Warsaw <bwarsaw@cen.com> for elp, without which I wouldn't have
161 been able to get the indentation code to perform acceptably.
162
163 Gareth Rees <Gareth.Rees@cl.cam.ac.uk> for suggestions how to speed up
164 Emacs regular expression search, even if I didn't use them in the end.
165
166 Bill Dubuque <wgd@martigny.ai.mit.edu> for alerting me to the
167 necessity of guarding against C-g inside Emacs code which modifies
168 syntax tables.
169
170 REPORTING:
171
172 Bug reports (preferably with patches), suggestions, donations etc. to:
173
174 Ian T Zimmerman           +-------------------------------------------+
175 Box 13445                 I    With so many executioners available,   I
176 Berkeley CA 94712 USA     I suicide is a really foolish thing to do.  I
177 mailto:itz@rahul.net      +-------------------------------------------+