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.

mardi 6 mai 2008

R mode in Chamo

A R mode is now available for Chamo, as a separate snippet. By now, this mode has only one key binding, to call the "r_eval" command. This command sends the contents of the active view to a background R process. The output of this process is displayed in the "outputs" window. Other commands can easily be defined the same way to interact with other programs (see the details).

If some text is selected in the view, then only this text is sent to the R process. Closing the R output tab in the "outputs" window closes the R process. When the "r_eval" command is executed again, a new process is created. If the command is executed and the R process is still running, then it is used and no other process is launched.

mercredi 30 avril 2008

OCamlbuild support in Chamo

The Chamo editor now includes some ocamlbuild support through the internal command "ocaml_build": An ocamlbuild command is proposed to the user who can edit it and run it.

















The output of the command is displayed in a new "outputs" window, and is analyzed. In case of error (or warning considered as error), the editor displays, in the active view, the file where the error was found, and highlights the corresponding characters.










The command used to compile is kept associated to the file, so that it is proposed the next time the internal command "ocaml_build" is launch on the file. These associations are even stored on disk to be kept between two sessions of Chamo launched in the same directory.