From ed24214af032fa9592ef435eb01198491bf0a610 Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Thu, 2 Feb 2012 23:39:23 +0100 Subject: [PATCH] hack to force camlp4 to display its welcome message before the prompt in emacs Ignore-this: fe0dee42954ec08b0465d6a57d45dd98 darcs-hash:20120202223923-c41ad-967ee6191c205214ac8d220fddc2d80c4cb9c5bc --- src/emacs/uTop_emacs.ml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/emacs/uTop_emacs.ml b/src/emacs/uTop_emacs.ml index 44a7001..742ba79 100644 --- a/src/emacs/uTop_emacs.ml +++ b/src/emacs/uTop_emacs.ml @@ -185,3 +185,34 @@ and loop prompt buffer length = process prompt buffer length command argument let () = Toploop.read_interactive_input := read_input + +(* +-----------------------------------------------------------------+ + | Hacks | + +-----------------------------------------------------------------+ *) + +(* Force camlp4 to display its welcome message when it is loaded. *) + +let () = + List.iter + (fun directive -> + let orig = + try + match Hashtbl.find Toploop.directive_table directive with + | Toploop.Directive_none func -> + func + | _ -> + ignore + with Not_found -> + ignore + in + Hashtbl.replace Toploop.directive_table directive + (Toploop.Directive_none + (fun () -> + orig (); + (* Parse something so camlp4 will display its welcome + message. *) + try + ignore (!Toploop.parse_toplevel_phrase (Lexing.from_string "")) + with _ -> + ()))) + ["camlp4o"; "camlp4r"]