src/Pure/PIDE/command.ML
changeset 56265 785569927666
parent 56034 1c59b555ac4a
child 56291 e79f76a48449
equal deleted inserted replaced
56260:3d79c132e657 56265:785569927666
   269 local
   269 local
   270 
   270 
   271 val print_functions =
   271 val print_functions =
   272   Synchronized.var "Command.print_functions" ([]: (string * print_function) list);
   272   Synchronized.var "Command.print_functions" ([]: (string * print_function) list);
   273 
   273 
   274 fun print_error tr e =
   274 fun print_error tr opt_context e =
   275   (Toplevel.setmp_thread_position tr o Toplevel.controlled_execution) e ()
   275   (Toplevel.setmp_thread_position tr o Toplevel.controlled_execution opt_context) e ()
   276     handle exn =>
   276     handle exn =>
   277       if Exn.is_interrupt exn then reraise exn
   277       if Exn.is_interrupt exn then reraise exn
   278       else List.app (Future.error_msg (Toplevel.pos_of tr)) (ML_Compiler.exn_messages_ids exn);
   278       else List.app (Future.error_msg (Toplevel.pos_of tr)) (ML_Compiler.exn_messages_ids exn);
   279 
   279 
   280 fun print_eq (Print {exec_id, ...}, Print {exec_id = exec_id', ...}) = exec_id = exec_id';
   280 fun print_eq (Print {exec_id, ...}, Print {exec_id = exec_id', ...}) = exec_id = exec_id';
   296         val exec_id = Document_ID.make ();
   296         val exec_id = Document_ID.make ();
   297         fun process () =
   297         fun process () =
   298           let
   298           let
   299             val {failed, command, state = st', ...} = eval_result eval;
   299             val {failed, command, state = st', ...} = eval_result eval;
   300             val tr = Toplevel.exec_id exec_id command;
   300             val tr = Toplevel.exec_id exec_id command;
       
   301             val opt_context = try Toplevel.generic_theory_of st';
   301           in
   302           in
   302             if failed andalso strict then ()
   303             if failed andalso strict then ()
   303             else print_error tr (fn () => print_fn tr st')
   304             else print_error tr opt_context (fn () => print_fn tr st')
   304           end;
   305           end;
   305       in
   306       in
   306         Print {
   307         Print {
   307           name = name, args = args, delay = delay, pri = pri, persistent = persistent,
   308           name = name, args = args, delay = delay, pri = pri, persistent = persistent,
   308           exec_id = exec_id, print_process = memo exec_id process}
   309           exec_id = exec_id, print_process = memo exec_id process}
   314 
   315 
   315     fun new_print name args get_pr =
   316     fun new_print name args get_pr =
   316       let
   317       let
   317         val params = {command_name = command_name, args = args};
   318         val params = {command_name = command_name, args = args};
   318       in
   319       in
   319         (case Exn.capture (Toplevel.controlled_execution get_pr) params of
   320         (case Exn.capture (Toplevel.controlled_execution NONE get_pr) params of
   320           Exn.Res NONE => NONE
   321           Exn.Res NONE => NONE
   321         | Exn.Res (SOME pr) => SOME (make_print name args pr)
   322         | Exn.Res (SOME pr) => SOME (make_print name args pr)
   322         | Exn.Exn exn => SOME (bad_print name args exn))
   323         | Exn.Exn exn => SOME (bad_print name args exn))
   323       end;
   324       end;
   324 
   325