7

I'm currently using tuareg-mode but I would like to be able to use the functionality of caml-mode as well. In particular I want to be able to use type annotations interactively, and apparently this occurs with caml-types. I tried putting http://cristal.inria.fr/~remy/poly/emacs/index.html in my .emacs.d, but I'm confused about how or if these two modes can work together. In fact, I can't get caml-mode to work at all.

I have this line in my init.el:

(add-to-list 'load-path "~/.emacs.d/modes/caml")

But the files are not loaded - at least, none of the function definitions or keybindings are. I really thought I was starting to grasp how these emacs plugins work, but I'm starting to wonder. Maybe someone can explain what else needs to happen?

Edit: I didn't realize I had to require 'caml for this to work. Still, annotations don't seem to be working although I have caml-types from http://caml.inria.fr/svn/ocaml/branches/gadts/emacs/. I compile with -annot but I'm still told there's no annotations file.

scry
  • 1,237
  • 12
  • 29

1 Answers1

5

You can have type annotation with the tuareg mode. If I have this exact ~/.emacs file:

(add-hook 'tuareg-mode-hook '(lambda ()
  (define-key tuareg-mode-map [f10] 'caml-types-show-type); requires caml-types
  ))
(add-to-list 'auto-mode-alist '("\\.ml\\w?" . tuareg-mode))
(autoload 'caml-types-show-type "caml-types" "Show the type of expression or pattern at point." t)

then pressing F10 shows the type of the expression under the point. As you know, you need to compile your file foo.ml with

ocamlc -annot foo.ml

so that there is a file foo.annot in the same directory as foo.ml.

jrouquie
  • 4,315
  • 4
  • 27
  • 43
  • Thanks, this works. But I tried binding to "C-c C-t" without success. Is there a special format for specifying keys in define-key? – scry Jul 09 '12 at 15:22
  • "C-c C-t" works here as well, with this minimal .emacs, without having to define it. – jrouquie Jul 09 '12 at 15:55
  • Well it looks like everything works as it should as long as `tuareg-with-caml-mode-p` is non-nil - when is that supposed to be enabled? I feel like I shouldn't have to do it myself. eh. – scry Jul 11 '12 at 00:43
  • By my reading of `tuareg.el`, you should not need to tweak `tuareg-with-camp-mode-p` by hand. Rather, `tuareg-with-camp-mode-p` should be enabled automatically if both `caml-types` and `caml-help` can be found in the load path when `tuareg` is loaded. – Ben Liblit Mar 27 '13 at 20:57