图阿雷格模式和凸轮模式

时间:2012-07-09 01:19:24

标签: emacs annotations ocaml tuareg

我目前正在使用tuareg模式,但我希望能够使用caml-mode的功能。特别是我希望能够以交互方式使用类型注释,并且显然这与caml类型一起发生。我尝试将http://cristal.inria.fr/~remy/poly/emacs/index.html放在我的.emacs.d中,但我对这两种模式如何或两者如何协同工作感到困惑。事实上,我根本无法使用caml-mode工作。

我在init.el中有这一行:

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

但是文件没有加载 - 至少没有函数定义或键绑定。我真的以为我开始意识到这些emacs插件是如何工作的,但我开始怀疑。也许有人可以解释还有什么需要发生?

编辑:我没有意识到我必须require 'caml才能使用它。尽管我有来自http://caml.inria.fr/svn/ocaml/branches/gadts/emacs/的caml-types,但注释似乎并没有起作用。我用-annot编译,但我仍然告诉我没有注释文件。

1 个答案:

答案 0 :(得分:5)

您可以使用tuareg模式进行类型注释。 如果我有这个确切的〜/ .emacs文件:

(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)

然后按F10显示该点下的表达式类型。 如您所知,您需要使用

编译文件foo.ml
ocamlc -annot foo.ml

以便在与foo.annot相同的目录中存在文件foo.ml

相关问题