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.

1 Answer 1

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.

4
  • 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
    Commented Jul 9, 2012 at 15:22
  • "C-c C-t" works here as well, with this minimal .emacs, without having to define it.
    – jrouquie
    Commented Jul 9, 2012 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
    Commented Jul 11, 2012 at 0: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
    Commented Mar 27, 2013 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.