src/Pure/PIDE/document.ML
changeset 52850 9fff9f78240a
parent 52849 199e9fa5a5c2
child 52862 930ce8eacb87
equal deleted inserted replaced
52849:199e9fa5a5c2 52850:9fff9f78240a
    98 
    98 
    99 val required_node = #required o get_perspective;
    99 val required_node = #required o get_perspective;
   100 val visible_command = Inttab.defined o #visible o get_perspective;
   100 val visible_command = Inttab.defined o #visible o get_perspective;
   101 val visible_last = #visible_last o get_perspective;
   101 val visible_last = #visible_last o get_perspective;
   102 val visible_node = is_some o visible_last
   102 val visible_node = is_some o visible_last
   103 val overlays = #overlays o get_perspective;
   103 val overlays = Inttab.lookup_list o #overlays o get_perspective;
   104 
   104 
   105 fun map_entries f =
   105 fun map_entries f =
   106   map_node (fn (header, perspective, entries, result) => (header, perspective, f entries, result));
   106   map_node (fn (header, perspective, entries, result) => (header, perspective, f entries, result));
   107 fun get_entries (Node {entries, ...}) = entries;
   107 fun get_entries (Node {entries, ...}) = entries;
   108 
   108 
   440           val assign_update' = assign_update |> ok' ?
   440           val assign_update' = assign_update |> ok' ?
   441             (case opt_exec of
   441             (case opt_exec of
   442               SOME (eval, prints) =>
   442               SOME (eval, prints) =>
   443                 let
   443                 let
   444                   val command_visible = visible_command node command_id;
   444                   val command_visible = visible_command node command_id;
       
   445                   val command_overlays = overlays node command_id;
   445                   val command_name = the_command_name state command_id;
   446                   val command_name = the_command_name state command_id;
   446                 in
   447                 in
   447                   (case Command.print command_visible command_name eval prints of
   448                   (case Command.print command_visible command_overlays command_name eval prints of
   448                     SOME prints' => assign_update_new (command_id, SOME (eval, prints'))
   449                     SOME prints' => assign_update_new (command_id, SOME (eval, prints'))
   449                   | NONE => I)
   450                   | NONE => I)
   450                 end
   451                 end
   451             | NONE => I);
   452             | NONE => I);
   452         in SOME (prev, ok', flags', assign_update') end
   453         in SOME (prev, ok', flags', assign_update') end
   460       else (common, flags);
   461       else (common, flags);
   461   in (assign_update', common', flags') end;
   462   in (assign_update', common', flags') end;
   462 
   463 
   463 fun illegal_init _ = error "Illegal theory header after end of theory";
   464 fun illegal_init _ = error "Illegal theory header after end of theory";
   464 
   465 
   465 fun new_exec state proper_init command_visible command_id' (assign_update, command_exec, init) =
   466 fun new_exec state node proper_init command_id' (assign_update, command_exec, init) =
   466   if not proper_init andalso is_none init then NONE
   467   if not proper_init andalso is_none init then NONE
   467   else
   468   else
   468     let
   469     let
   469       val (_, (eval, _)) = command_exec;
   470       val (_, (eval, _)) = command_exec;
       
   471 
       
   472       val command_visible = visible_command node command_id';
       
   473       val command_overlays = overlays node command_id';
   470       val (command_name, span) = the_command state command_id' ||> Lazy.force;
   474       val (command_name, span) = the_command state command_id' ||> Lazy.force;
   471 
   475 
   472       val eval' = Command.eval (fn () => the_default illegal_init init span) span eval;
   476       val eval' = Command.eval (fn () => the_default illegal_init init span) span eval;
   473       val prints' = perhaps (Command.print command_visible command_name eval') [];
   477       val prints' = perhaps (Command.print command_visible command_overlays command_name eval') [];
   474       val exec' = (eval', prints');
   478       val exec' = (eval', prints');
   475 
   479 
   476       val assign_update' = assign_update_new (command_id', SOME exec') assign_update;
   480       val assign_update' = assign_update_new (command_id', SOME exec') assign_update;
   477       val init' = if Keyword.is_theory_begin command_name then NONE else init;
   481       val init' = if Keyword.is_theory_begin command_name then NONE else init;
   478     in SOME (assign_update', (command_id', (eval', prints')), init') end;
   482     in SOME (assign_update', (command_id', (eval', prints')), init') end;
   523                       (print_execs, common_command_exec, if initial then SOME init else NONE)
   527                       (print_execs, common_command_exec, if initial then SOME init else NONE)
   524                       |> (still_visible orelse node_required) ?
   528                       |> (still_visible orelse node_required) ?
   525                         iterate_entries_after common
   529                         iterate_entries_after common
   526                           (fn ((prev, id), _) => fn res =>
   530                           (fn ((prev, id), _) => fn res =>
   527                             if not node_required andalso prev = visible_last node then NONE
   531                             if not node_required andalso prev = visible_last node then NONE
   528                             else new_exec state proper_init (visible_command node id) id res) node;
   532                             else new_exec state node proper_init id res) node;
   529 
   533 
   530                     val assigned_execs =
   534                     val assigned_execs =
   531                       (node0, updated_execs) |-> iterate_entries_after common
   535                       (node0, updated_execs) |-> iterate_entries_after common
   532                         (fn ((_, command_id0), exec0) => fn res =>
   536                         (fn ((_, command_id0), exec0) => fn res =>
   533                           if is_none exec0 then NONE
   537                           if is_none exec0 then NONE