【问题标题】:Tuareg-mode and caml-mode图阿雷格模式和caml模式
【发布时间】:2012-07-09 01:19:24
【问题描述】:

我目前正在使用 tuareg-mode,但我也希望能够使用 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 类型,但注释似乎不起作用。我用-annot 编译,但我仍然被告知没有注释文件。

【问题讨论】:

    标签: emacs annotations ocaml tuareg


    【解决方案1】:

    您可以使用 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.ml的同一目录下就有一个文件foo.annot

    【讨论】:

    • 谢谢,这行得通。但我尝试绑定到“C-c C-t”但没有成功。在define-key中指定键是否有特殊格式?
    • "C-c C-t" 在这里也可以使用,使用这个最小的 .emacs,无需定义它。
    • 好吧,只要tuareg-with-caml-mode-p 不为零,看起来一切正常 - 什么时候应该启用?我觉得我不应该自己做。嗯。
    • 根据我对tuareg.el 的阅读,您不需要手动调整tuareg-with-camp-mode-p。相反,如果caml-typescaml-help 在加载tuareg 时可以在加载路径中找到,则应自动启用tuareg-with-camp-mode-p
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-03
    • 1970-01-01
    • 1970-01-01
    • 2023-02-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多