3

I heard we can annotate ocaml prog. by their types. An older thread in the forum suggested using ocaml mode of http://cristal.inria.fr/~remy/poly/emacs/index.html

I have been using Tuareg mode, in which it suggested using "c-c c-t" to retrieve types, cf. this piece of codes in tuareg.el

 (when tuareg-with-caml-mode-p
      ;; Trigger caml-types
      (define-key map [?\C-c ?\C-t] 'caml-types-show-type)
      ;; To prevent misbehavior in case of error during exploration.
      (define-key map [(control mouse-2)] 'caml-types-mouse-ignore)
      (define-key map [(control down-mouse-2)] 'caml-types-explore)

I got "c-c c-t" undefined although everything seems to be well configured.

Here is the .emacs file

(setq auto-mode-alist
      (cons '("\\.ml[iyl]?$" .  caml-mode) auto-mode-alist))

(autoload 'caml-mode "ocaml" 
  "Major mode for editing Caml code." t)

(autoload 'camldebug "camldebug" 
  "Call the camldebugger on FILE" t)

;; adjust paths for emacs source code
(add-to-list 'load-path "~/my-emacs-config/caml-mode")

;; adjust paths for emacs ocaml info sources
(require 'info)
(add-to-list 'Info-directory-list "~/my-emacs-config/caml-mode")

Here is the files in caml-mode (which contains ocaml.el)

bash-3.2$ ls ~/my-emacs-config/caml-mode/
caml-compat.el  caml-emacs.el   caml-font.el    caml-help.el    caml-hilit.el   caml-types.el   caml.el     camldebug.el    inf-caml.el ocaml.el

I did the following

--write an factorial func. in ocaml, called "annot.ml"

let rec f n = 
if n = 1 then 0 else n * f(n-1)

--ocamlc -annot annot.ml

--open annot.ml by emacs and press "c-c c-t" while the cursor is under "n"

I got in the minibuffer of emacs

c-c c-t undefined

Conclusion, I still cannot retrieve types. Why??? Thank you for your ideas.

More info: when I try M-x caml-[tab] I get the following list, which does not contain caml-types-show-types

Possible completions are:
caml-mode              camldebug
camldebug-backtrace        camldebug-break
camldebug-close            camldebug-complete
camldebug-delete           camldebug-display-frame
camldebug-down             camldebug-finish
camldebug-goto             camldebug-kill
camldebug-last             camldebug-mode
camldebug-next             camldebug-open
camldebug-print            camldebug-refresh
camldebug-reverse          camldebug-run
camldebug-step             camldebug-up
zell
  • 9,830
  • 10
  • 62
  • 115

1 Answers1

1

You're autoloading caml-mode from ocaml.el or ocaml.elc. But there is no such file! The official Caml mode is in a file called caml.el, and Tuareg mode is in a file called tuareg.el. This explains why opening your .ml file doesn't put you in Ocaml mode and doesn't load the Caml support. Change your autoload to either this to use the official mode

(autoload 'caml-mode "caml" 
  "Major mode for editing Caml code." t)

or this to use Tuareg mode

(autoload 'caml-mode "tuareg" 
  "Major mode for editing Caml code." t)
Gilles 'SO- stop being evil'
  • 104,111
  • 38
  • 209
  • 254