Emacs

The Emacs homepage has all the information on emacs.

Getting emacs

Windows
Precompiled binaries are found here. Here is a FAQ on Windows and emacs.
Macintosh OS X
OS X comes with emacs, but that version supports terminal use only and so you want a better version. A prebuilt binary of full emacs is found here.
Linux
Linux comes with emacs installed already.

Learning Emacs

If you are not familiar with emacs, control-H t is an interactive tutorial to get you going. control-H i gets you into the emacs info system; middle-click on Emacs to read the documentation about the editor. This documentation is also available on a webpage. A good emacs tutorial webpage here.

Using emacs with OCaml

You will need the caml-mode addition to emacs to effectively edit ML programs.

There are two things you need to set up in order to get caml mode working

  1. You need to install the emacs caml mode files in a place where your version of emacs can find them;
  2. You need to add a few lines to your .emacs preferences file to tell emacs to start up caml mode on ml files.

Installing Emacs caml mode

There are several ways you can get this mode installed.
  1. If you are using any CS department UNIX machine, it should already be installed.
  2. Many installs of ocaml on *NIX machines will ask you if you want to install the emacs mode somewhere during the ocaml install -- just say yes and you are all set.
  3. If you downloaded the ocaml source distribution, cd to subdirectory emacs and make install.
  4. If the three options above are not working, then we suggest you manually install your own copy of the caml mode. You may also want to install your own copy becuase then you can use the Tuareg version which is slightly better.
    1. Download the files from here
    2. Follow the install instructions in the README file.
    3. Note for Windows users: Emacs is often not aware of your "home" directory for looking for the files you just installed above; if it is not finding the mode just use the complete path where you put the files, e.g."C:Meoohmy/Camlstuff/foo" instead of just "foo". Also some Windows emacs installs may use a file named _emacs instead of the .emacs referred to in the README. Lastly Windows may have trouble finding the _emacs file since it is looking in the wrong place (it is supposed to be in your home directory). If it is not finding your .emacs file, start up emacs and type ESC x eval RETURN (getenv "HOME") RETURN (use the ESC and RETURN keys) - this will show the value of HOME at the bottom. Put the required configuration lines in a file in that folder, and name it _emacs.

Using Caml Mode

In emacs, every file that ends in .ml will automatically load caml-mode; there will be a (caml) in the status line at the bottom indicating you are in caml mode. Also, you can execute the extended command caml-mode (type meta-x caml-mode; meta-x is either holding down the meta-key and pressing x, or ESC followed by x)) to start caml-mode in a buffer. To start a shell window running ocaml, use the extended command run-caml (or do C-c C-s which will start a caml shell if it is not already running).

The caml-mode distribution includes no documentation but is easy to use; control-h m from within emacs gets you the caml mode command list. The main useful commands (C-c means control-C, etc) are

C-c C-e		evaluate the phrase the cursor is sitting in the middle of
C-c C-r		evaluate the whole selected region
C-c C-s		show the shell window; will automatically run-caml if not running
C-c `		go to exact error location in the source