ocaml-community / utop

Universal toplevel for OCaml
Other
846 stars 113 forks source link

No way to give input to functions that reads from stdin in utop.el #150

Open peterwang opened 8 years ago

peterwang commented 8 years ago

For example, function _readline

utop[1]> read_line () ;;
(when I typed here, I got error message in the mini-buffer: Text is read-only: "You cannot edit the buffer while ocaml is evaluating a phrase")
(the only thing I can do is: Ctrl-C)
Interrupted.
utop[2]> 

Is there any specific reason why this is not allowed? Any plan to support this?

ghost commented 8 years ago

utop is using stdin/stdout to communicate with emacs using a small protocol. That's why it doesn't work out of the box. It shouldn't be too hard to make it work though

zzhjerry commented 8 years ago

I met the same issue and searched "how to read stdin into utop emacs buffer". But it seems there's no straightforward answer on the web.

I tried using M-1 M-! and echo xxx while expecting xxx can be sent to the buffer. But I sill got the error saying Text is read-only: "You cannot edit the buffer while ocaml evaluating a phrase"

Would you mind give a detailed guide here about how to make it work?