8 signature PROOF_GENERAL_PGIP = |
8 signature PROOF_GENERAL_PGIP = |
9 sig |
9 sig |
10 val proof_general_emacsN: string |
10 val proof_general_emacsN: string |
11 |
11 |
12 val new_thms_deps: theory -> theory -> string list * string list |
12 val new_thms_deps: theory -> theory -> string list * string list |
13 val init_pgip: bool -> unit (* main PGIP loop with true; fail with false *) |
|
14 |
|
15 val init_pgip_session_id: unit -> unit |
|
16 |
13 |
17 (* More message functions... *) |
14 (* More message functions... *) |
18 val nonfatal_error : string -> unit (* recoverable (batch) error: carry on scripting *) |
15 val nonfatal_error : string -> unit (* recoverable (batch) error: carry on scripting *) |
19 val log_msg : string -> unit (* for internal log messages *) |
16 val log_msg : string -> unit (* for internal log messages *) |
20 val error_with_pos : PgipTypes.displayarea -> PgipTypes.fatality -> Position.T -> string -> unit |
17 val error_with_pos : PgipTypes.displayarea -> PgipTypes.fatality -> Position.T -> string -> unit |
45 val pgip_refseq = Unsynchronized.ref NONE: int option Unsynchronized.ref; |
42 val pgip_refseq = Unsynchronized.ref NONE: int option Unsynchronized.ref; |
46 |
43 |
47 local |
44 local |
48 val pgip_class = "pg" |
45 val pgip_class = "pg" |
49 val pgip_tag = "Isabelle/Isar" |
46 val pgip_tag = "Isabelle/Isar" |
50 val pgip_id = Unsynchronized.ref "" |
47 val pgip_id = "dummy" |
51 val pgip_seq = Unsynchronized.ref 0 |
48 val pgip_seq = Unsynchronized.ref 0 |
52 fun pgip_serial () = Unsynchronized.inc pgip_seq |
49 fun pgip_serial () = Unsynchronized.inc pgip_seq |
53 |
50 |
54 fun assemble_pgips pgips = |
51 fun assemble_pgips pgips = |
55 Pgip { tag = SOME pgip_tag, |
52 Pgip { tag = SOME pgip_tag, |
56 class = pgip_class, |
53 class = pgip_class, |
57 seq = pgip_serial (), |
54 seq = pgip_serial (), |
58 id = ! pgip_id, |
55 id = pgip_id, |
59 destid = ! pgip_refid, |
56 destid = ! pgip_refid, |
60 (* destid=refid since Isabelle only communicates back to sender *) |
57 (* destid=refid since Isabelle only communicates back to sender *) |
61 refid = ! pgip_refid, |
58 refid = ! pgip_refid, |
62 refseq = ! pgip_refseq, |
59 refseq = ! pgip_refseq, |
63 content = pgips } |
60 content = pgips } |
64 in |
61 in |
65 |
62 |
66 fun init_pgip_session_id () = |
63 fun matching_pgip_id id = (id = pgip_id) |
67 pgip_id := getenv "HOSTNAME" ^ "/" ^ getenv "USER" ^ "/" ^ |
|
68 getenv "ISABELLE_PID" ^ "/" ^ Time.toString (Time.now ()) |
|
69 |
|
70 fun matching_pgip_id id = (id = ! pgip_id) |
|
71 |
64 |
72 val output_xml_fn = Unsynchronized.ref Output.physical_writeln |
65 val output_xml_fn = Unsynchronized.ref Output.physical_writeln |
73 fun output_xml s = ! output_xml_fn (XML.string_of s); |
66 fun output_xml s = ! output_xml_fn (XML.string_of s); |
74 |
67 |
75 val output_pgips = XML.string_of o PgipOutput.output o assemble_pgips o map PgipOutput.output; |
68 val output_pgips = XML.string_of o PgipOutput.output o assemble_pgips o map PgipOutput.output; |
989 |
982 |
990 fun pgip_toplevel x = loop true x |
983 fun pgip_toplevel x = loop true x |
991 end |
984 end |
992 |
985 |
993 |
986 |
994 (* init *) |
|
995 |
|
996 val initialized = Unsynchronized.ref false; |
|
997 |
|
998 fun init_pgip false = panic "No Proof General interface support for Isabelle/classic mode." |
|
999 | init_pgip true = |
|
1000 (if ! initialized then () |
|
1001 else |
|
1002 (setup_preferences_tweak (); |
|
1003 Output.add_mode proof_generalN Output.default_output Output.default_escape; |
|
1004 Markup.add_mode proof_generalN YXML.output_markup; |
|
1005 setup_messages (); |
|
1006 setup_thy_loader (); |
|
1007 setup_present_hook (); |
|
1008 init_pgip_session_id (); |
|
1009 welcome (); |
|
1010 initialized := true); |
|
1011 sync_thy_loader (); |
|
1012 Unsynchronized.change print_mode (update (op =) proof_generalN); |
|
1013 pgip_toplevel tty_src); |
|
1014 |
|
1015 |
|
1016 |
|
1017 (** Out-of-loop PGIP commands (for Emacs hybrid mode) **) |
987 (** Out-of-loop PGIP commands (for Emacs hybrid mode) **) |
1018 |
988 |
1019 local |
989 local |
1020 |
990 |
1021 fun invalid_pgip () = raise PGIP "Invalid PGIP packet received"; |
991 fun invalid_pgip () = raise PGIP "Invalid PGIP packet received"; |