I just discovered that one can say UTop.set_create_implicits true
to have utop bind results to variables _1
, _2
etc. This works well when running utop in a terminal but seems not to when running it from Emacs (ie. with the -emacs command line option) : results still get a -
in front of them and no _%i
variable seem to exist.
How come ?
I think the reason is that the uTop implementation for Emacs is missing the code to bind implicits, which seems to be a bug?:
See the code to rewrite toplevel expressions in the normal uTop loop:
and the corresponding code in the module implementing Emacs support:
| Some ("end", _) ->
Buffer.contents buf
| Some (command, argument) ->
Printf.ksprintf (send "stderr") "'data' or 'end' command expected, got %S!" command;
exit 1
in
loop true
let process_checked_phrase phrase =
(* Rewrite toplevel expressions. *)
let phrase = rewrite phrase in
try
Env.reset_cache_toplevel ();
ignore (execute_phrase true Format.std_formatter phrase);
true
with exn ->
(* The only possible errors are directive errors. *)
let msg = UTop.get_message Errors.report_error exn in
(* Skip the dumb location. *)
let msg =
try
Maybe there’s a reason for this discrepancy? Not sure.
1 Like
Thank you. I saw the first snippet by searching for implicits
, but I did not realise that the emacs mode would use a different function.
So an issue to Utop it is.
1 Like