emacs - 如何在 Emacs 中为 Ocaml 生成和设置注释?

标签 emacs makefile annotations compilation ocaml

我正在使用 Emacs 在 Ocaml 中编写编译器。有人告诉我 -annot一个文件.annot可以在编译时生成,这可以帮助 Emacs 显示我的代码类型。但奇怪的是没有.annot运行此 makefile 后生成.谁能告诉我这有什么问题?

此外,一旦我得到 .annot ,我是否需要设置任何东西(例如 .emacs ?)以便我的 Emacs 读取它并显示我的代码类型?

非常感谢你!

编辑 1:在 make clean 之后和 make , 我有 .annot ...但是我仍然不知道如何使用这个.annot在 Emacs 中。

Edit2:实际上有必要遵循 link ,复制本地文件夹中的文件,然后更新.emacs .那么当一个.ml在 Emacs 中编辑,C-c C-t 从 .annot 返回其类型.

最佳答案

关于您的 emacs 查询——我不使用 emacs——,这是来自 man-pages对于 ocamlc ,

-annot Dump detailed information about the compilation (types, bindings, tail-calls, etc). The information for file src.ml is put into file src.annot. In case of a type error, dump all the information inferred by the type-checker before the error. The src.annot file can be used with the emacs commands given in emacs/caml-types.el to display types and other annotations interactively.



the thread I mentioned previously 还有其他工具.

至于Makefile不创建 .annot文件,我制作了一个模拟目录并成功拥有.annot创建的文件。我也看不出你的 Makefile 有什么问题.您可能需要清理目录并重试,或切换到另一种方式来构建您的工具,如 ocamlbuild --这需要最少的设置,虽然,我没有将它与 menhir 一起使用.

我还会注意到 -annot is new since OCaml 3.11.0 , 之前的标志是 -dtypes .

关于emacs - 如何在 Emacs 中为 Ocaml 生成和设置注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6424751/

相关文章:

java - 如何定义流Result注解?

linux - 一次查看多个日志的最佳方式?

emacs - ranp 是否提供任何 API 来查询缓冲区文件名中的信息

c - Makefile 不删除中间文件

makefile - autogen.sh 不(重新)生成 po/Makefile.in.in

makefile - makefile 调用其他 makefile 的最佳实践

java - PointCut 将使用某些参数注释的方法与注释相匹配

java - SpEL 函数更改字符串

emacs - 在光标点生成一个随机的 5 个字母 + 数字字符串。 (全部小写)

emacs - 让 emacs 增量搜索将光标置于匹配的开头