732 (Toplevel.actual_proof (fn prf => (report_back (); Proof_Node.back prf)) o |
732 (Toplevel.actual_proof (fn prf => (report_back (); Proof_Node.back prf)) o |
733 Toplevel.skip_proof (fn h => (report_back (); h)))); |
733 Toplevel.skip_proof (fn h => (report_back (); h)))); |
734 |
734 |
735 |
735 |
736 |
736 |
737 (** nested commands **) |
|
738 |
|
739 val props_text = |
|
740 Scan.optional Parse.properties [] -- Parse.position Parse.string |
|
741 >> (fn (props, (str, pos)) => |
|
742 (Position.of_properties (Position.default_properties pos props), str)); |
|
743 |
|
744 val _ = |
|
745 Outer_Syntax.improper_command @{command_spec "Isabelle.command"} "evaluate nested Isabelle command" |
|
746 (props_text :|-- (fn (pos, str) => |
|
747 (case Outer_Syntax.parse (Outer_Syntax.get_syntax ()) pos str of |
|
748 [tr] => Scan.succeed (K tr) |
|
749 | _ => Scan.fail_with (K (fn () => "exactly one command expected"))) |
|
750 handle ERROR msg => Scan.fail_with (K (fn () => msg)))); |
|
751 |
|
752 |
|
753 |
|
754 (** diagnostic commands (for interactive mode only) **) |
737 (** diagnostic commands (for interactive mode only) **) |
755 |
738 |
756 val opt_modes = |
739 val opt_modes = |
757 Scan.optional (@{keyword "("} |-- Parse.!!! (Scan.repeat1 Parse.xname --| @{keyword ")"})) []; |
740 Scan.optional (@{keyword "("} |-- Parse.!!! (Scan.repeat1 Parse.xname --| @{keyword ")"})) []; |
758 |
741 |
759 val opt_bang = Scan.optional (@{keyword "!"} >> K true) false; |
742 val opt_bang = Scan.optional (@{keyword "!"} >> K true) false; |
760 |
|
761 val _ = (*Proof General legacy*) |
|
762 Outer_Syntax.improper_command @{command_spec "pretty_setmargin"} |
|
763 "change default margin for pretty printing" |
|
764 (Parse.nat >> (fn n => Toplevel.imperative (fn () => Pretty.margin_default := n))); |
|
765 |
743 |
766 val _ = |
744 val _ = |
767 Outer_Syntax.improper_command @{command_spec "help"} |
745 Outer_Syntax.improper_command @{command_spec "help"} |
768 "retrieve outer syntax commands according to name patterns" |
746 "retrieve outer syntax commands according to name patterns" |
769 (Scan.repeat Parse.name >> |
747 (Scan.repeat Parse.name >> |
888 val _ = |
866 val _ = |
889 Outer_Syntax.improper_command @{command_spec "locale_deps"} "visualize locale dependencies" |
867 Outer_Syntax.improper_command @{command_spec "locale_deps"} "visualize locale dependencies" |
890 (Scan.succeed Isar_Cmd.locale_deps); |
868 (Scan.succeed Isar_Cmd.locale_deps); |
891 |
869 |
892 val _ = |
870 val _ = |
893 Outer_Syntax.improper_command @{command_spec "print_binds"} |
|
894 "print term bindings of proof context -- Proof General legacy" |
|
895 (Scan.succeed (Toplevel.unknown_context o |
|
896 Toplevel.keep |
|
897 (Pretty.writeln_chunks o Proof_Context.pretty_term_bindings o Toplevel.context_of))); |
|
898 |
|
899 val _ = |
|
900 Outer_Syntax.improper_command @{command_spec "print_term_bindings"} |
871 Outer_Syntax.improper_command @{command_spec "print_term_bindings"} |
901 "print term bindings of proof context" |
872 "print term bindings of proof context" |
902 (Scan.succeed (Toplevel.unknown_context o |
873 (Scan.succeed (Toplevel.unknown_context o |
903 Toplevel.keep |
874 Toplevel.keep |
904 (Pretty.writeln_chunks o Proof_Context.pretty_term_bindings o Toplevel.context_of))); |
875 (Pretty.writeln_chunks o Proof_Context.pretty_term_bindings o Toplevel.context_of))); |
964 val _ = |
935 val _ = |
965 Outer_Syntax.improper_command @{command_spec "kill_thy"} |
936 Outer_Syntax.improper_command @{command_spec "kill_thy"} |
966 "kill theory -- try to remove from loader database" |
937 "kill theory -- try to remove from loader database" |
967 (Parse.name >> (fn name => Toplevel.imperative (fn () => Thy_Info.kill_thy name))); |
938 (Parse.name >> (fn name => Toplevel.imperative (fn () => Thy_Info.kill_thy name))); |
968 |
939 |
969 val _ = (*partial Proof General legacy*) |
940 val _ = |
970 Outer_Syntax.improper_command @{command_spec "display_drafts"} |
941 Outer_Syntax.improper_command @{command_spec "display_drafts"} |
971 "display raw source files with symbols" |
942 "display raw source files with symbols" |
972 (Scan.repeat1 Parse.path >> (fn names => |
943 (Scan.repeat1 Parse.path >> (fn names => |
973 Toplevel.imperative (fn () => ignore (Present.display_drafts (map Path.explode names))))); |
944 Toplevel.imperative (fn () => ignore (Present.display_drafts (map Path.explode names))))); |
974 |
945 |
975 val _ = |
946 val _ = |
976 Outer_Syntax.improper_command @{command_spec "print_state"} |
947 Outer_Syntax.improper_command @{command_spec "print_state"} |
977 "print current proof state (if present)" |
948 "print current proof state (if present)" |
978 (opt_modes >> (fn modes => Toplevel.keep (Print_Mode.with_modes modes Toplevel.print_state))); |
949 (opt_modes >> (fn modes => Toplevel.keep (Print_Mode.with_modes modes Toplevel.print_state))); |
979 |
|
980 val _ = (*Proof General legacy, e.g. for ProofGeneral-3.7.x*) |
|
981 Outer_Syntax.improper_command @{command_spec "pr"} "print current proof state (if present)" |
|
982 (opt_modes -- Scan.option Parse.nat >> (fn (modes, limit) => |
|
983 Toplevel.keep (fn state => |
|
984 (if Isabelle_Process.is_active () then error "Illegal TTY command" else (); |
|
985 case limit of NONE => () | SOME n => Options.default_put_int @{system_option goals_limit} n; |
|
986 Toplevel.quiet := false; |
|
987 Print_Mode.with_modes modes Toplevel.print_state state)))); |
|
988 |
|
989 val _ = (*Proof General legacy*) |
|
990 Outer_Syntax.improper_command @{command_spec "disable_pr"} |
|
991 "disable printing of toplevel state" |
|
992 (Scan.succeed (Toplevel.imperative (fn () => Toplevel.quiet := true))); |
|
993 |
|
994 val _ = (*Proof General legacy*) |
|
995 Outer_Syntax.improper_command @{command_spec "enable_pr"} |
|
996 "enable printing of toplevel state" |
|
997 (Scan.succeed (Toplevel.imperative (fn () => Toplevel.quiet := false))); |
|
998 |
950 |
999 val _ = |
951 val _ = |
1000 Outer_Syntax.improper_command @{command_spec "commit"} |
952 Outer_Syntax.improper_command @{command_spec "commit"} |
1001 "commit current session to ML session image" |
953 "commit current session to ML session image" |
1002 (Parse.opt_unit >> K (Toplevel.imperative Secure.commit)); |
954 (Parse.opt_unit >> K (Toplevel.imperative Secure.commit)); |
1040 (Scan.optional Parse.nat 1 >> (fn n => |
992 (Scan.optional Parse.nat 1 >> (fn n => |
1041 Toplevel.keep (fn state => |
993 Toplevel.keep (fn state => |
1042 if Toplevel.is_proof state then (Isar.undo n; Isar.print ()) else raise Toplevel.UNDEF))); |
994 if Toplevel.is_proof state then (Isar.undo n; Isar.print ()) else raise Toplevel.UNDEF))); |
1043 |
995 |
1044 val _ = |
996 val _ = |
1045 Outer_Syntax.improper_command @{command_spec "cannot_undo"} |
|
1046 "partial undo -- Proof General legacy" |
|
1047 (Parse.name >> |
|
1048 (fn "end" => Toplevel.imperative (fn () => Isar.undo 1) |
|
1049 | txt => Toplevel.imperative (fn () => error ("Cannot undo " ^ quote txt)))); |
|
1050 |
|
1051 val _ = |
|
1052 Outer_Syntax.improper_command @{command_spec "kill"} |
997 Outer_Syntax.improper_command @{command_spec "kill"} |
1053 "kill partial proof or theory development" |
998 "kill partial proof or theory development" |
1054 (Scan.succeed (Toplevel.imperative Isar.kill)); |
999 (Scan.succeed (Toplevel.imperative Isar.kill)); |
1055 |
1000 |
1056 |
1001 |