jeudi 21 janvier 2010

Playing with .annot files

New commands are available in the OCaml mode of Chamo. They use the .annot files generated by ocamlc. Here is a list of these commands. Default key bindings are shown between parenthesis.

ocaml_display_type_annot (A-t) already existed to display the type of the expression under the cursor. Now ocaml_copy_type_annot (CA-t) does the same but also copies the type in the clipboard so that it can be easily pasted somewhere else, for example in a .mli file. This prevents from having to launch a ocamlc -i command to get the type.

ocaml_display_ident_annot (A-i) displays the "ident" information, that is whether the identifier is local to the file or its fully qualified name if it is defined elsewhere. ocaml_jump_to_local_def (A-j) does the same but if the ident is defined in the file, the cursor is positioned on the identifier definition.

ocaml_display_call_annot (A-c) displays the "call" information, that is whether a function call is "tail" or "stack". ocaml_show_stack_calls (CA-c) highlights (or not) all the calls using the stack. This can be useful to check whether a function is tail-recursive. The screenshot below shows the result on the List module.

At last, ocaml_expand_ext_idents (CA-x) prompts the user to replace each external identifier by its fully qualified identifier (except for idents from Pervasives). I personnally use the open directive only not to prefix record fields and constructors, but always use fully qualified identifiers. This command is useful when working on a code not written by me and full of open's at the beginning of a file.

All these commands are available from revision 745 of the repository and in the nightly snapshot.

Aucun commentaire: