Thursday, January 24, 2008

The Triumphant Return of C-c C-t

The upgrade to Ubuntu gutsy and/or Emacs 22 broke my favorite feature of tuareg/ocaml-mode: C-c C-t for "show type" in OCaml buffers (this requires compiling with -dtypes, which generates type annotation files). I suffered without this for a length of time which is either embarrassing or impressive, depending on whether you consider poking around inside Emacs Lisp files a productive or unproductive use of time...

I finally broke down and fixed it today. The problem is simply that Emacs and OCaml packages aren't cooperating properly. My solution, which may or may not be optimal, is as follows:


  1. Copy the directory /usr/share/emacs/site-lisp/ocaml-mode to a path of your choosing, say ~/.emacs.d/emacs22/ocaml-mode. Let's call this directory DIR
  2. (Optional) In Emacs 22, execute C-u 0 M-x byte-recompile-directory and choose DIR.
  3. Add the following line to your .emacs file:
    (or (< emacs-major-version 22) (push "DIR" load-path))



The test for whether it worked is: load a .ml file and type C-c C-t. In the mini-buffer, you'll either see "type: ..."; "Point is not within a typechecked expression or pattern"; or "No annotation file..." If it says "C-c C-t is undefined", then you have failed.

No comments: