2011-12-29 14:10:39 -08:00
|
|
|
OCaml emacs mode, snapshot of $Date$
|
1997-07-17 02:46:54 -07:00
|
|
|
|
1997-02-24 05:17:50 -08:00
|
|
|
The files in this archive define a caml-mode for emacs, for editing
|
2011-07-27 07:17:02 -07:00
|
|
|
OCaml and Objective Label programs, as well as an
|
1997-02-24 05:17:50 -08:00
|
|
|
inferior-caml-mode, to run a toplevel.
|
|
|
|
|
1998-10-14 00:36:51 -07:00
|
|
|
Caml-mode supports indentation, compilation and error retrieving,
|
|
|
|
sending phrases to the toplevel. Moreover support for hilit,
|
|
|
|
font-lock and imenu was added.
|
1997-02-24 05:17:50 -08:00
|
|
|
|
|
|
|
This package is based on the original caml-mode for caml-light by
|
|
|
|
Xavier Leroy, extended with indentation by Ian Zimmerman. For details
|
|
|
|
see README.itz, which is the README from Ian Zimmerman's package.
|
|
|
|
|
2011-09-13 05:25:52 -07:00
|
|
|
To use it, just put the .el files in your emacs load path, and add the
|
2011-12-29 14:10:39 -08:00
|
|
|
following lines in your .emacs.
|
1997-02-24 05:17:50 -08:00
|
|
|
|
2011-09-13 05:25:52 -07:00
|
|
|
(add-to-list 'auto-mode-alist '("\\.ml[iylp]?$" . caml-mode))
|
2011-12-29 14:10:39 -08:00
|
|
|
(autoload 'caml-mode "caml" "Major mode for editing OCaml code." t)
|
|
|
|
(autoload 'run-caml "inf-caml" "Run an inferior OCaml process." t)
|
2011-09-13 05:25:52 -07:00
|
|
|
(autoload 'camldebug "camldebug" "Run ocamldebug on program." t)
|
2011-12-29 14:10:39 -08:00
|
|
|
(add-to-list 'interpreter-mode-alist '("ocamlrun" . caml-mode))
|
|
|
|
(add-to-list 'interpreter-mode-alist '("ocaml" . caml-mode))
|
1997-02-24 05:17:50 -08:00
|
|
|
|
2011-09-13 05:25:52 -07:00
|
|
|
or put the .el files in, eg. "/usr/share/emacs/site-lisp/caml-mode/"
|
|
|
|
and add the following line in addtion to the four lines above:
|
|
|
|
|
|
|
|
(add-to-list 'load-path "/usr/share/emacs/site-lisp/caml-mode")
|
1997-02-24 05:17:50 -08:00
|
|
|
|
1999-01-31 17:55:27 -08:00
|
|
|
To install the mode itself, edit the Makefile and do
|
|
|
|
|
2000-04-05 11:30:22 -07:00
|
|
|
% make install
|
1999-01-31 17:55:27 -08:00
|
|
|
|
1999-10-18 02:40:46 -07:00
|
|
|
To install ocamltags, do
|
1999-01-31 17:55:27 -08:00
|
|
|
|
2000-04-05 11:30:22 -07:00
|
|
|
% make install-ocamltags
|
1999-01-31 17:55:27 -08:00
|
|
|
|
2002-08-04 19:05:42 -07:00
|
|
|
To use highlighting capabilities, add ONE of the following two lines
|
|
|
|
to your .emacs. The second one works better on recent versions of
|
|
|
|
emacs.
|
1997-02-24 05:17:50 -08:00
|
|
|
|
2000-04-05 11:30:22 -07:00
|
|
|
(if window-system (require 'caml-hilit))
|
|
|
|
(if window-system (require 'caml-font))
|
1997-02-24 05:17:50 -08:00
|
|
|
|
|
|
|
caml.el and inf-caml.el can be used collectively, but it might be a
|
|
|
|
good idea to copy caml-hilit.el or caml-font.el to you own directory,
|
|
|
|
and edit it to your taste and colors.
|
|
|
|
|
|
|
|
Main key bindings:
|
|
|
|
|
2000-04-05 11:30:22 -07:00
|
|
|
TAB indent current line
|
|
|
|
M-C-q indent phrase
|
|
|
|
M-C-h mark phrase
|
|
|
|
C-c C-a switch between interface and implementation
|
|
|
|
C-c C-c compile (usually make)
|
|
|
|
C-x` goto next error (also mouse button 2 in the compilation log)
|
1997-02-24 05:17:50 -08:00
|
|
|
|
|
|
|
Once you have started caml by M-x run-caml:
|
|
|
|
|
2000-04-05 11:30:22 -07:00
|
|
|
M-C-x send phrase to inferior caml process
|
|
|
|
C-c C-r send region to inferior caml process
|
1997-07-17 02:46:54 -07:00
|
|
|
C-c C-s show inferior caml process
|
2000-04-05 11:30:22 -07:00
|
|
|
C-c` goto error in expression sent by M-C-x
|
1997-02-24 05:17:50 -08:00
|
|
|
|
|
|
|
For other bindings, see C-h b.
|
|
|
|
|
1997-07-17 02:46:54 -07:00
|
|
|
Changes log:
|
|
|
|
-----------
|
2008-01-11 08:13:18 -08:00
|
|
|
Version 3.10.1:
|
|
|
|
---------------
|
|
|
|
* use caml-font.el from Olivier Andrieu
|
|
|
|
old version is left as caml-font-old.el for compatibility
|
|
|
|
|
|
|
|
Version 3.07:
|
|
|
|
-------------
|
|
|
|
* support for showing type information <Damien Doligez>
|
1999-03-30 19:00:35 -08:00
|
|
|
|
2002-08-04 19:05:42 -07:00
|
|
|
Version 3.05:
|
|
|
|
-------------
|
|
|
|
* improved interaction with inferior caml mode
|
|
|
|
|
|
|
|
* access help from the source
|
|
|
|
|
|
|
|
* fixes in indentation code
|
|
|
|
|
2001-10-31 23:41:18 -08:00
|
|
|
Version 3.03:
|
|
|
|
-------------
|
|
|
|
* process ;; properly
|
|
|
|
|
2000-04-23 20:17:40 -07:00
|
|
|
Version 3.00:
|
|
|
|
-------------
|
|
|
|
* adapt to new label syntax
|
|
|
|
|
1999-03-30 19:00:35 -08:00
|
|
|
* intelligent indentation of parenthesis
|
|
|
|
|
|
|
|
Version 2.02:
|
|
|
|
-------------
|
1999-01-31 17:55:27 -08:00
|
|
|
* improved ocamltags <ITZ and JG>
|
|
|
|
|
|
|
|
* added support for multibyte characters in emacs 20
|
|
|
|
|
1998-12-16 01:32:04 -08:00
|
|
|
Version 2.01+:
|
|
|
|
--------------
|
|
|
|
* corrected a bug in caml-font.el <Adam P. Jenkins>
|
|
|
|
|
|
|
|
* corrected abbreviations and added ocamltags script <Ian T Zimmerman>
|
|
|
|
|
1998-10-14 00:36:51 -07:00
|
|
|
Version 2.01:
|
|
|
|
------------
|
|
|
|
* code for interactive errors added by ITZ
|
|
|
|
|
|
|
|
Version 2.00:
|
|
|
|
------------
|
|
|
|
* changed the algorithm to skip comments
|
|
|
|
|
|
|
|
* adapted for the new object syntax
|
|
|
|
|
|
|
|
Version 1.07:
|
|
|
|
------------
|
|
|
|
* next-error bug fix by John Malecki
|
|
|
|
|
|
|
|
* camldebug.el modified by Xavier Leroy
|
|
|
|
|
|
|
|
Version 1.06:
|
|
|
|
------------
|
2012-02-10 08:15:24 -08:00
|
|
|
* new keywords in Objective Caml 1.06
|
1998-10-14 00:36:51 -07:00
|
|
|
|
|
|
|
* compatibility with GNU Emacs 20
|
|
|
|
|
|
|
|
* changed from caml-imenu-disable to caml-imenu-enable (off by default)
|
|
|
|
|
1997-07-17 02:46:54 -07:00
|
|
|
Version 1.05:
|
|
|
|
------------
|
|
|
|
* a few indentation bugs corrected. let, val ... are now indented
|
|
|
|
correctly even when you write them at the beginning of a line.
|
1997-02-24 05:17:50 -08:00
|
|
|
|
1997-07-17 02:46:54 -07:00
|
|
|
* added a Caml menu, and Imenu support. Imenu menu can be disabled
|
2000-04-05 11:30:22 -07:00
|
|
|
by setting the variable caml-imenu-disable to t.
|
1997-07-17 08:29:13 -07:00
|
|
|
Xemacs support for the Menu, but no Imenu.
|
1997-02-24 05:17:50 -08:00
|
|
|
|
1997-07-17 02:46:54 -07:00
|
|
|
* key bindings closer to lisp-mode.
|
1997-02-24 05:17:50 -08:00
|
|
|
|
1997-07-17 02:46:54 -07:00
|
|
|
* O'Labl compatibility (":" is part of words) may be switched off by
|
|
|
|
setting caml-olabl-disable to t.
|
1997-02-24 05:17:50 -08:00
|
|
|
|
1997-07-17 02:46:54 -07:00
|
|
|
* camldebug.el was updated by Xavier Leroy.
|
1997-02-24 05:17:50 -08:00
|
|
|
|
1997-07-17 02:46:54 -07:00
|
|
|
Version 1.03b:
|
|
|
|
-------------
|
1997-02-24 05:17:50 -08:00
|
|
|
* many bugs corrected.
|
|
|
|
|
|
|
|
* (partial) compatibility with Caml-Light added.
|
2000-04-05 11:30:22 -07:00
|
|
|
(setq caml-quote-char "`")
|
|
|
|
(setq inferior-caml-program "camllight")
|
1997-02-24 05:17:50 -08:00
|
|
|
Literals will be correctly understood and highlighted. However,
|
2012-02-10 08:15:24 -08:00
|
|
|
indentation rules are still OCaml's: this just happens to
|
1997-02-24 05:17:50 -08:00
|
|
|
work well in most cases, but is only intended for occasional use.
|
|
|
|
|
|
|
|
* as many people asked for it, application is now indented. This seems
|
|
|
|
to work well: this time differences in indentation between the
|
|
|
|
compiler's source and this mode are really exceptionnal. On the
|
|
|
|
other hand, you may think that some special cases are strange. No
|
|
|
|
miracle.
|
|
|
|
|
|
|
|
* nicer behaviour when sending a phrase/region to the inferior caml
|
|
|
|
process.
|
|
|
|
|
1997-07-17 02:46:54 -07:00
|
|
|
Version 1.03:
|
|
|
|
------------
|
2012-02-10 08:15:24 -08:00
|
|
|
* support of OCaml and Objective Label.
|
1997-07-17 02:46:54 -07:00
|
|
|
|
|
|
|
* an indentation very close to mine, which happens to be the same as
|
2012-02-10 08:15:24 -08:00
|
|
|
Xavier's, since the sources of the OCaml compiler do not
|
1997-07-17 02:46:54 -07:00
|
|
|
change if you indent them in this mode.
|
|
|
|
|
|
|
|
* highlighting.
|
|
|
|
|
1997-02-24 05:17:50 -08:00
|
|
|
Some remarks about the style supported:
|
1997-07-17 02:46:54 -07:00
|
|
|
--------------------------------------
|
1997-02-24 05:17:50 -08:00
|
|
|
|
2012-02-10 08:15:24 -08:00
|
|
|
Since OCaml's syntax is very liberal (more than 100
|
1997-02-24 05:17:50 -08:00
|
|
|
shift-reduce conflicts with yacc), automatic indentation is far from
|
2000-04-05 11:30:22 -07:00
|
|
|
easy. Moreover, you expect the indentation to be not purely syntactic,
|
1997-02-24 05:17:50 -08:00
|
|
|
but also semantic: reflecting the meaning of your program.
|
|
|
|
|
|
|
|
This mode tries to be intelligent. For instance some operators are
|
2000-04-05 11:30:22 -07:00
|
|
|
indented differently in the middle and at the end of a line (thanks to
|
1997-02-24 05:17:50 -08:00
|
|
|
Ian Zimmerman). Also, we do not indent after if .. then .. else, when
|
|
|
|
else is on the same line, to reflect that this idiom is equivalent to
|
2000-04-05 11:30:22 -07:00
|
|
|
a return instruction in a more imperative language, or after the in of
|
1997-02-24 05:17:50 -08:00
|
|
|
let .. in, since you may see that as an assignment.
|
|
|
|
|
|
|
|
However, you may want to use a different indentation style. This is
|
|
|
|
made partly possible by a number of variables at the beginning of
|
|
|
|
caml.el. Try to set them. However this only changes the size of
|
|
|
|
indentations, not really the look of your program. This is enough to
|
|
|
|
disable the two idioms above, but to do anything more you will have to
|
|
|
|
edit the code... Enjoy!
|
|
|
|
|
|
|
|
This mode does not force you to put ;; in your program. This means
|
1997-07-17 02:46:54 -07:00
|
|
|
that we had to use a heuristic to decide where a phrase starts and
|
|
|
|
stops, to speed up the code. A phrase starts when any of the keywords
|
|
|
|
let, type, class, module, functor, exception, val, external, appears
|
|
|
|
at the beginning of a line. Using the first column for such keywords
|
|
|
|
in other cases may confuse the phrase selection function.
|
1997-02-24 05:17:50 -08:00
|
|
|
|
|
|
|
Comments and bug reports to
|
|
|
|
|
2008-01-11 08:13:18 -08:00
|
|
|
Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
|