Re: Setting custom prompt in utop with UTop.prompt

"John Magolske [email protected] [ocaml_beginners]" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <[email protected]>
Hi Chingfan,

* Chingfan Tsao [email protected] [ocaml_beginners] [150404 09:17]:
> Since LTerm_text belongs to the lambda-term package, it seems that
> your utop couldn't find LTerm_text, a little strange, since if you
> installed utop via opam, lambda-term should be installed automatically
> as dependency, can you show your whole ocamlinit content? Changing
> UTop.prompt definitly works in my ocamlinit file.

Thanks for the clue. I forgot to mention I'd installed utop to
/usr/local/bin/utop from source (to tweak the prompt by editing
src/lib/uTop.cppo.ml and recompiling). In that case, I found
UTop.prompt worked after inputing:

    #require "react"

Of course prompt customization with UTop.prompt in ocamlinit is a much
better way to go. So now, with utop installed via opam, there's no
need for an explicit #require "react", and my ~/.ocamlinit looks like:

    (* Added by OPAM. *)
    let () =
      try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
      with Not_found -> ()
    ;;

    (* hide the utop completion bar *)
    UTop.set_show_box false ;;

    (* custom utop prompt *)
    #require "lambda-term" ;;
    UTop.prompt :=
      fst (React.S.create LTerm_text.(
          eval [
            B_fg (LTerm_style.cyan);
            S "  ────────────────────────────────────────\n" ;
            B_fg (LTerm_style.lyellow); S "# "])) ;;

...and that works fine.
 
Regards,

John

-- 
John Magolske
http://B79.net/contact
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.