简体   繁体   English

图阿雷格模式和凸轮模式

[英]Tuareg-mode and caml-mode

I'm currently using tuareg-mode but I would like to be able to use the functionality of caml-mode as well. 我目前正在使用tuareg模式,但我希望能够使用caml-mode的功能。 In particular I want to be able to use type annotations interactively, and apparently this occurs with caml-types. 特别是我希望能够以交互方式使用类型注释,并且显然这与caml类型一起发生。 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. 我尝试将http://cristal.inria.fr/~remy/poly/emacs/index.html放在我的.emacs.d中,但我对这两种模式如何或如何协同工作感到困惑。 In fact, I can't get caml-mode to work at all. 事实上,我根本无法使用caml-mode工作。

I have this line in my init.el: 我在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. 我真的以为我开始意识到这些emacs插件是如何工作的,但我开始怀疑。 Maybe someone can explain what else needs to happen? 也许有人可以解释还有什么需要发生?

Edit: I didn't realize I had to require 'caml for this to work. 编辑:我没有意识到我必须require 'caml才能工作。 Still, annotations don't seem to be working although I have caml-types from http://caml.inria.fr/svn/ocaml/branches/gadts/emacs/ . 尽管我有来自http://caml.inria.fr/svn/ocaml/branches/gadts/emacs/的 caml-types,但注释似乎并没有起作用。 I compile with -annot but I'm still told there's no annotations file. 我用-annot编译但是我仍然被告知没有注释文件。

You can have type annotation with the tuareg mode. 您可以使用tuareg模式进行类型注释。 If I have this exact ~/.emacs file: 如果我有这个确切的〜/ .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)

then pressing F10 shows the type of the expression under the point. 然后按F10显示该点下的表达式类型。 As you know, you need to compile your file foo.ml with 如您所知,您需要使用编译文件foo.ml

ocamlc -annot foo.ml

so that there is a file foo.annot in the same directory as foo.ml . 这样在foo.annot所在的目录中就有一个文件foo.ml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM