How to generate and set up annotation for Ocaml in Emacs?
I am writing a compiler in Ocaml with Emacs. I am told that with -annot
a file .annot
could be generated while compiling, which could help Emacs to show the type of my code. But it is odd that no .annot
is generated after running this makefile. Could anyone tell me wha开发者_如何学运维t is wrong with that?
Also, once i have got .annot
, do I need to set up anything (for instance .emacs
?) so that my Emacs read it and show the type of my code?
Thank you very much!
Edit1: after make clean
and make
, I have got the .annot
... But I still do not know how to make use of this .annot
in Emacs.
Edit2: actually it is necessary to follow this link, copy the files in a local folder, then update .emacs
. Then when a .ml
is edited in Emacs, C-c C-t returns its type from .annot
.
Regarding your emacs inquiry --I don't use emacs--, this is from the man-pages for 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.
There are also other tools from the thread I mentioned previously.
As for the Makefile
not creating the .annot
files, I made a mock directory and successfully had .annot
files created. I also don't see anything wrong with your Makefile
. You may want to clean the directory and try again, or switch to another way to build your tool like ocamlbuild
--which would require minimal setup, although, I haven't used it with menhir
.
I will also note that -annot
is new since OCaml 3.11.0, and prior the flag was -dtypes
.
精彩评论