inputemacsocamltuaregocaml-toplevel

Inputing data in OCaml toplevel runnin under Emacs


When interactively running the OCaml toplevel on Emacs (via the Tuareg mode), evaluation of expression which do input from the standard input channel does not finish.

For instance, when I enter the following expression in the *ocaml-toplevel* buffer and hit enter

let x = read_int ();;

and type some integer and hit ENTER to finish, evaluation is not finished as it was expected.

The following screenshot demonstrates the situation.

enter image description here

What is the proper way of doing input from the standard input channel in the OCaml toplevel buffer in Emacs?


Solution

  • just type as usal an use M-x comint-send-input directly, so tuareg won't check for the terminating ;;

    edit: of course, you can define a keyboard shortcut for it, if you need it regularly; e.g

     (add-hook 'tuareg-interactive-mode-hook
      '(lambda ()
          (local-set-key (kbd "C-n") 'comint-send-input)))