396 |
396 |
397 fun check_theory full name node = |
397 fun check_theory full name node = |
398 is_some (Thy_Info.lookup_theory name) orelse |
398 is_some (Thy_Info.lookup_theory name) orelse |
399 can get_header node andalso (not full orelse is_some (get_result node)); |
399 can get_header node andalso (not full orelse is_some (get_result node)); |
400 |
400 |
401 fun check_prints prints (prints': Command.print list) = |
|
402 if eq_list (op = o pairself #exec_id) (prints, prints') then NONE |
|
403 else SOME prints'; |
|
404 |
|
405 fun update_prints command_visible command_name eval prints = |
|
406 if command_visible then |
|
407 let |
|
408 val new_prints = Command.print command_name eval; |
|
409 val prints' = |
|
410 new_prints |> map (fn new_print => |
|
411 (case find_first (fn {name, ...} => name = #name new_print) prints of |
|
412 SOME print => if Command.stable_print print then print else new_print |
|
413 | NONE => new_print)); |
|
414 in check_prints prints prints' end |
|
415 else check_prints prints (filter Command.stable_print prints); |
|
416 |
|
417 fun last_common state node0 node = |
401 fun last_common state node0 node = |
418 let |
402 let |
419 fun update_flags prev (visible, initial) = |
403 fun update_flags prev (visible, initial) = |
420 let |
404 let |
421 val visible' = visible andalso prev <> visible_last node; |
405 val visible' = visible andalso prev <> visible_last node; |
442 SOME (eval, prints) => |
426 SOME (eval, prints) => |
443 let |
427 let |
444 val command_visible = visible_command node command_id; |
428 val command_visible = visible_command node command_id; |
445 val command_name = the_command_name state command_id; |
429 val command_name = the_command_name state command_id; |
446 in |
430 in |
447 (case update_prints command_visible command_name eval prints of |
431 (case Command.print command_visible command_name eval prints of |
448 SOME prints' => assign_update_new (command_id, SOME (eval, prints')) |
432 SOME prints' => assign_update_new (command_id, SOME (eval, prints')) |
449 | NONE => I) |
433 | NONE => I) |
450 end |
434 end |
451 | NONE => I); |
435 | NONE => I); |
452 in SOME (prev, same', flags', assign_update') end |
436 in SOME (prev, same', flags', assign_update') end |
468 let |
452 let |
469 val (_, (eval, _)) = command_exec; |
453 val (_, (eval, _)) = command_exec; |
470 val (command_name, span) = the_command state command_id' ||> Lazy.force; |
454 val (command_name, span) = the_command state command_id' ||> Lazy.force; |
471 |
455 |
472 val eval' = Command.eval (fn () => the_default illegal_init init span) span eval; |
456 val eval' = Command.eval (fn () => the_default illegal_init init span) span eval; |
473 val prints' = perhaps (update_prints command_visible command_name eval') []; |
457 val prints' = perhaps (Command.print command_visible command_name eval') []; |
474 val exec' = (eval', prints'); |
458 val exec' = (eval', prints'); |
475 |
459 |
476 val assign_update' = assign_update_new (command_id', SOME exec') assign_update; |
460 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; |
461 val init' = if Keyword.is_theory_begin command_name then NONE else init; |
478 in SOME (assign_update', (command_id', (eval', prints')), init') end; |
462 in SOME (assign_update', (command_id', (eval', prints')), init') end; |
479 |
|
480 in |
463 in |
481 |
464 |
482 fun update old_version_id new_version_id edits state = |
465 fun update old_version_id new_version_id edits state = |
483 let |
466 let |
484 val old_version = the_version state old_version_id; |
467 val old_version = the_version state old_version_id; |