author | wenzelm |
Wed, 15 May 2013 21:46:07 +0200 | |
changeset 52014 | 45929e0e1d73 |
parent 52013 | ebb119a9f712 |
child 52015 | d021c180e7df |
permissions | -rw-r--r-- |
52009 | 1 |
(* Title: Pure/Tools/proof_general.ML |
52006 | 2 |
Author: David Aspinall |
3 |
Author: Makarius |
|
21642 | 4 |
|
52006 | 5 |
Isabelle/Isar configuration for Proof General / Emacs. |
26549 | 6 |
See also http://proofgeneral.inf.ed.ac.uk |
21642 | 7 |
*) |
8 |
||
9 |
signature PROOF_GENERAL = |
|
10 |
sig |
|
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
11 |
type category = string |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
12 |
val category_display: category |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
13 |
val category_advanced_display: category |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
14 |
val category_tracing: category |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
15 |
val category_proof: category |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
16 |
type pgiptype = string |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
17 |
val pgipbool: pgiptype |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
18 |
val pgipint: pgiptype |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
19 |
val pgipfloat: pgiptype |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
20 |
val pgipstring: pgiptype |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
21 |
val preference_raw: category -> |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
22 |
(unit -> string) -> (string -> unit) -> string -> string -> string -> unit |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
23 |
val preference_bool: category -> bool Unsynchronized.ref -> string -> string -> unit |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
24 |
val preference_int: category -> int Unsynchronized.ref -> string -> string -> unit |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
25 |
val preference_real: category -> real Unsynchronized.ref -> string -> string -> unit |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
26 |
val preference_string: category -> string Unsynchronized.ref -> string -> string -> unit |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
27 |
val preference_option: category -> string -> string -> string -> unit |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
28 |
structure ThyLoad: sig val add_path: string -> unit end |
52012
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
29 |
val thm_deps: bool Unsynchronized.ref |
52013 | 30 |
val proof_generalN: string |
51938 | 31 |
val init: unit -> unit |
21642 | 32 |
end; |
33 |
||
34 |
structure ProofGeneral: PROOF_GENERAL = |
|
35 |
struct |
|
36 |
||
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
37 |
(** preferences **) |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
38 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
39 |
(* type preference *) |
52006 | 40 |
|
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
41 |
type category = string; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
42 |
val category_display = "Display"; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
43 |
val category_advanced_display = "Advanced Display"; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
44 |
val category_tracing = "Tracing"; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
45 |
val category_proof = "Proof"; |
52006 | 46 |
|
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
47 |
type pgiptype = string; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
48 |
val pgipbool = "pgipbool"; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
49 |
val pgipint = "pgipint"; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
50 |
val pgipfloat = "pgipint"; (*NB: PG 3.7.x and 4.0 lack pgipfloat, but accept floats as pgipint*) |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
51 |
val pgipstring = "pgipstring"; |
52006 | 52 |
|
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
53 |
type preference = |
52014
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
54 |
{category: string, |
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
55 |
descr: string, |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
56 |
default: string, |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
57 |
pgiptype: pgiptype, |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
58 |
get: unit -> string, |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
59 |
set: string -> unit}; |
52006 | 60 |
|
61 |
||
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
62 |
(* global preferences *) |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
63 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
64 |
local |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
65 |
val preferences = |
52014
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
66 |
Synchronized.var "ProofGeneral.preferences" ([]: (string * preference) list); |
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
67 |
in |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
68 |
|
52014
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
69 |
fun add_preference name pref = |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
70 |
Synchronized.change preferences (fn prefs => |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
71 |
(if not (AList.defined (op =) prefs name) then () |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
72 |
else warning ("Redefining ProofGeneral preference: " ^ quote name); |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
73 |
AList.update (op =) (name, pref) prefs)); |
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
74 |
|
52014
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
75 |
fun set_preference name value = |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
76 |
(case AList.lookup (op =) (Synchronized.value preferences) name of |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
77 |
SOME {set, ...} => set value |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
78 |
| NONE => error ("Unknown ProofGeneral preference: " ^ quote name)); |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
79 |
|
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
80 |
fun all_preferences () = |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
81 |
rev (Synchronized.value preferences) |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
82 |
|> map (fn (name, {category, descr, default, pgiptype, ...}) => |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
83 |
(category, {name = name, descr = descr, default = default, pgiptype = pgiptype})) |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
84 |
|> AList.group (op =); |
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
85 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
86 |
end; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
87 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
88 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
89 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
90 |
(* raw preferences *) |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
91 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
92 |
fun preference_raw category raw_get raw_set typ name descr = |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
93 |
let |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
94 |
fun get () = CRITICAL raw_get; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
95 |
fun set x = CRITICAL (fn () => raw_set x); |
52014
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
96 |
in |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
97 |
add_preference name |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
98 |
{category = category, descr = descr, pgiptype = typ, get = get, set = set, default = get ()} |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
99 |
end; |
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
100 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
101 |
fun preference_ref category read write typ r = |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
102 |
preference_raw category (fn () => read (! r)) (fn x => r := write x) typ; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
103 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
104 |
fun preference_bool category = preference_ref category Markup.print_bool Markup.parse_bool pgipbool; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
105 |
fun preference_int category = preference_ref category Markup.print_int Markup.parse_int pgipint; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
106 |
fun preference_real category = preference_ref category Markup.print_real Markup.parse_real pgipfloat; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
107 |
fun preference_string category = preference_ref category I I pgipstring; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
108 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
109 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
110 |
(* system options *) |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
111 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
112 |
fun preference_option category option_name pgip_name descr = |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
113 |
let |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
114 |
val typ = Options.default_typ option_name; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
115 |
val pgiptype = |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
116 |
if typ = Options.boolT then pgipbool |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
117 |
else if typ = Options.intT then pgipint |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
118 |
else if typ = Options.realT then pgipfloat |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
119 |
else pgipstring; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
120 |
in |
52014
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
121 |
add_preference pgip_name |
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
122 |
{category = category, |
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
123 |
descr = descr, |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
124 |
default = Options.get_default option_name, |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
125 |
pgiptype = pgiptype, |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
126 |
get = fn () => Options.get_default option_name, |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
127 |
set = Options.put_default option_name} |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
128 |
end; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
129 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
130 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
131 |
(* minimal PGIP support for <askprefs>, <haspref>, <setpref> *) |
52006 | 132 |
|
133 |
local |
|
134 |
||
135 |
fun get_attr attrs name = |
|
136 |
(case Properties.get attrs name of |
|
137 |
SOME value => value |
|
138 |
| NONE => raise Fail ("Missing attribute: " ^ quote name)); |
|
139 |
||
140 |
fun attr x y = [(x, y)] : XML.attributes; |
|
141 |
||
142 |
fun opt_attr _ NONE = [] |
|
143 |
| opt_attr name (SOME value) = attr name value; |
|
144 |
||
145 |
val pgip_id = "dummy"; |
|
146 |
val pgip_serial = Synchronized.counter (); |
|
147 |
||
148 |
fun output_pgip refid refseq content = |
|
149 |
XML.Elem (("pgip", |
|
150 |
attr "tag" "Isabelle/Isar" @ |
|
151 |
attr "id" pgip_id @ |
|
152 |
opt_attr "destid" refid @ |
|
153 |
attr "class" "pg" @ |
|
154 |
opt_attr "refid" refid @ |
|
155 |
attr "refseq" refseq @ |
|
156 |
attr "seq" (string_of_int (pgip_serial ()))), content) |
|
157 |
|> XML.string_of |
|
158 |
|> Output.urgent_message; |
|
159 |
||
160 |
||
161 |
fun invalid_pgip () = raise Fail "Invalid PGIP packet"; |
|
162 |
||
52014
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
163 |
fun haspref {name, descr, default, pgiptype} = |
52006 | 164 |
XML.Elem (("haspref", [("name", name), ("descr", descr), ("default", default)]), |
165 |
[XML.Elem ((pgiptype, []), [])]); |
|
166 |
||
167 |
fun process_element refid refseq (XML.Elem (("askprefs", _), _)) = |
|
52014
45929e0e1d73
more standard Isabelle/ML structures for global preferences;
wenzelm
parents:
52013
diff
changeset
|
168 |
all_preferences () |> List.app (fn (category, prefs) => |
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
169 |
output_pgip refid refseq |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
170 |
[XML.Elem (("hasprefs", [("prefcategory", category)]), map haspref prefs)]) |
52006 | 171 |
| process_element _ _ (XML.Elem (("setpref", attrs), data)) = |
172 |
let |
|
173 |
val name = |
|
174 |
(case Properties.get attrs "name" of |
|
175 |
SOME name => name |
|
176 |
| NONE => invalid_pgip ()); |
|
177 |
val value = XML.content_of data; |
|
178 |
in set_preference name value end |
|
179 |
| process_element _ _ _ = invalid_pgip (); |
|
180 |
||
181 |
in |
|
182 |
||
183 |
fun process_pgip str = |
|
184 |
(case XML.parse str of |
|
185 |
XML.Elem (("pgip", attrs), pgips) => |
|
186 |
let |
|
187 |
val class = get_attr attrs "class"; |
|
188 |
val dest = Properties.get attrs "destid"; |
|
189 |
val refid = Properties.get attrs "id"; |
|
190 |
val refseq = get_attr attrs "seq"; |
|
191 |
val processit = |
|
192 |
(case dest of |
|
193 |
NONE => class = "pa" |
|
194 |
| SOME id => id = pgip_id); |
|
195 |
in if processit then List.app (process_element refid refseq) pgips else () end |
|
196 |
| _ => invalid_pgip ()) |
|
197 |
handle Fail msg => raise Fail (msg ^ "\n" ^ str); |
|
198 |
||
199 |
end; |
|
200 |
||
201 |
||
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
202 |
(** messages **) |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
203 |
|
51939 | 204 |
(* render markup *) |
26549 | 205 |
|
43777 | 206 |
fun special ch = chr 1 ^ ch; |
21642 | 207 |
|
208 |
local |
|
209 |
||
29326 | 210 |
fun render_trees ts = fold render_tree ts |
49658 | 211 |
and render_tree t = |
212 |
(case XML.unwrap_elem t of |
|
213 |
SOME (_, ts) => render_trees ts |
|
214 |
| NONE => |
|
215 |
(case t of |
|
216 |
XML.Text s => Buffer.add s |
|
217 |
| XML.Elem ((name, props), ts) => |
|
218 |
let |
|
51939 | 219 |
val (bg, en) = |
49658 | 220 |
if null ts then Markup.no_output |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
221 |
else if name = Markup.stateN then (special "O" ^ "\n", "\n" ^ special "P") |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
222 |
else if name = Markup.sendbackN then (special "W", special "X") |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
223 |
else if name = Markup.intensifyN then (special "0", special "1") |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
224 |
else if name = Markup.tfreeN then (special "C", special "A") |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
225 |
else if name = Markup.tvarN then (special "D", special "A") |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
226 |
else if name = Markup.freeN then (special "E", special "A") |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
227 |
else if name = Markup.boundN then (special "F", special "A") |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
228 |
else if name = Markup.varN then (special "G", special "A") |
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
229 |
else if name = Markup.skolemN then (special "H", special "A") |
49658 | 230 |
else |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
231 |
(case Markup.get_entity_kind (name, props) of |
49658 | 232 |
SOME kind => |
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50163
diff
changeset
|
233 |
if kind = Markup.classN then (special "B", special "A") |
49658 | 234 |
else Markup.no_output |
235 |
| NONE => Markup.no_output); |
|
51939 | 236 |
in Buffer.add bg #> render_trees ts #> Buffer.add en end)); |
21642 | 237 |
|
238 |
in |
|
239 |
||
29326 | 240 |
fun render text = |
241 |
Buffer.content (render_trees (YXML.parse_body text) Buffer.empty); |
|
21642 | 242 |
|
243 |
end; |
|
244 |
||
245 |
||
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
246 |
(* hooks *) |
29326 | 247 |
|
248 |
fun message bg en prfx text = |
|
249 |
(case render text of |
|
250 |
"" => () |
|
44389
a3b5fdfb04a3
tuned signature -- contrast physical output primitives versus Output.raw_message;
wenzelm
parents:
44270
diff
changeset
|
251 |
| s => Output.physical_writeln (enclose bg en (prefix_lines prfx s))); |
23641
d6f9d3acffaa
toplevel prompt/print_state: proper markup, removed hooks;
wenzelm
parents:
23621
diff
changeset
|
252 |
|
29326 | 253 |
fun setup_messages () = |
40133
b61d52de66f0
more explicit indication of Output.Private_Hooks (still public to accomodate clones of Proof General for now);
wenzelm
parents:
40132
diff
changeset
|
254 |
(Output.Private_Hooks.writeln_fn := message "" "" ""; |
b61d52de66f0
more explicit indication of Output.Private_Hooks (still public to accomodate clones of Proof General for now);
wenzelm
parents:
40132
diff
changeset
|
255 |
Output.Private_Hooks.status_fn := (fn _ => ()); |
b61d52de66f0
more explicit indication of Output.Private_Hooks (still public to accomodate clones of Proof General for now);
wenzelm
parents:
40132
diff
changeset
|
256 |
Output.Private_Hooks.report_fn := (fn _ => ()); |
b61d52de66f0
more explicit indication of Output.Private_Hooks (still public to accomodate clones of Proof General for now);
wenzelm
parents:
40132
diff
changeset
|
257 |
Output.Private_Hooks.urgent_message_fn := message (special "I") (special "J") ""; |
b61d52de66f0
more explicit indication of Output.Private_Hooks (still public to accomodate clones of Proof General for now);
wenzelm
parents:
40132
diff
changeset
|
258 |
Output.Private_Hooks.tracing_fn := message (special "I" ^ special "V") (special "J") ""; |
b61d52de66f0
more explicit indication of Output.Private_Hooks (still public to accomodate clones of Proof General for now);
wenzelm
parents:
40132
diff
changeset
|
259 |
Output.Private_Hooks.warning_fn := message (special "K") (special "L") "### "; |
44270
3eaad39e520c
more careful treatment of exception serial numbers, with propagation to message channel;
wenzelm
parents:
43840
diff
changeset
|
260 |
Output.Private_Hooks.error_fn := (fn (_, s) => message (special "M") (special "N") "*** " s); |
44389
a3b5fdfb04a3
tuned signature -- contrast physical output primitives versus Output.raw_message;
wenzelm
parents:
44270
diff
changeset
|
261 |
Output.Private_Hooks.prompt_fn := (fn s => Output.physical_stdout (render s ^ special "S"))); |
29326 | 262 |
|
23641
d6f9d3acffaa
toplevel prompt/print_state: proper markup, removed hooks;
wenzelm
parents:
23621
diff
changeset
|
263 |
|
29326 | 264 |
(* notification *) |
21642 | 265 |
|
29326 | 266 |
val emacs_notify = message (special "I") (special "J") ""; |
21642 | 267 |
|
268 |
fun tell_clear_goals () = |
|
21940 | 269 |
emacs_notify "Proof General, please clear the goals buffer."; |
21642 | 270 |
|
271 |
fun tell_clear_response () = |
|
21940 | 272 |
emacs_notify "Proof General, please clear the response buffer."; |
21642 | 273 |
|
274 |
fun tell_file_loaded path = |
|
21940 | 275 |
emacs_notify ("Proof General, this file is loaded: " ^ quote (File.platform_path path)); |
21642 | 276 |
|
277 |
fun tell_file_retracted path = |
|
21940 | 278 |
emacs_notify ("Proof General, you can unlock the file " ^ quote (File.platform_path path)); |
21642 | 279 |
|
280 |
||
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
281 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
282 |
(** theory loader **) |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
283 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
284 |
(* fake old ThyLoad -- with new semantics *) |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
285 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
286 |
structure ThyLoad = |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
287 |
struct |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
288 |
val add_path = Thy_Load.set_master_path o Path.explode; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
289 |
end; |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
290 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
291 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
292 |
(* actions *) |
21642 | 293 |
|
294 |
local |
|
295 |
||
296 |
fun trace_action action name = |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
36953
diff
changeset
|
297 |
if action = Thy_Info.Update then |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
36953
diff
changeset
|
298 |
List.app tell_file_loaded (Thy_Info.loaded_files name) |
37981
9a15982f41fe
theory loader: removed obsolete touch/outdate operations (require_thy no longer changes the database implicitly);
wenzelm
parents:
37977
diff
changeset
|
299 |
else if action = Thy_Info.Remove then |
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
36953
diff
changeset
|
300 |
List.app tell_file_retracted (Thy_Info.loaded_files name) |
21642 | 301 |
else (); |
302 |
||
303 |
in |
|
37216
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
36953
diff
changeset
|
304 |
fun setup_thy_loader () = Thy_Info.add_hook trace_action; |
3165bc303f66
modernized some structure names, keeping a few legacy aliases;
wenzelm
parents:
36953
diff
changeset
|
305 |
fun sync_thy_loader () = List.app (trace_action Thy_Info.Update) (Thy_Info.get_names ()); |
21642 | 306 |
end; |
307 |
||
308 |
||
21948 | 309 |
(* get informed about files *) |
21642 | 310 |
|
25442 | 311 |
(*liberal low-level version*) |
312 |
val thy_name = perhaps (try (unsuffix ".thy")) o List.last o space_explode "/"; |
|
313 |
||
37977
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37954
diff
changeset
|
314 |
val inform_file_retracted = Thy_Info.kill_thy o thy_name; |
25442 | 315 |
|
27577
7c7a9a343ca5
proper_inform_file_processed: new implementation based on global Isar state (cf. isar.ML);
wenzelm
parents:
27537
diff
changeset
|
316 |
fun inform_file_processed file = |
7c7a9a343ca5
proper_inform_file_processed: new implementation based on global Isar state (cf. isar.ML);
wenzelm
parents:
27537
diff
changeset
|
317 |
let |
7c7a9a343ca5
proper_inform_file_processed: new implementation based on global Isar state (cf. isar.ML);
wenzelm
parents:
27537
diff
changeset
|
318 |
val name = thy_name file; |
7c7a9a343ca5
proper_inform_file_processed: new implementation based on global Isar state (cf. isar.ML);
wenzelm
parents:
27537
diff
changeset
|
319 |
val _ = name = "" andalso error ("Bad file name: " ^ quote file); |
7c7a9a343ca5
proper_inform_file_processed: new implementation based on global Isar state (cf. isar.ML);
wenzelm
parents:
27537
diff
changeset
|
320 |
val _ = |
37977
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37954
diff
changeset
|
321 |
Thy_Info.register_thy (Toplevel.end_theory Position.none (Isar.state ())) |
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37954
diff
changeset
|
322 |
handle ERROR msg => |
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37954
diff
changeset
|
323 |
(warning (cat_lines ["Failed to register theory: " ^ quote name, msg]); |
46737 | 324 |
tell_file_retracted (Thy_Load.thy_path (Path.basic name))) |
29349 | 325 |
val _ = Isar.init (); |
27577
7c7a9a343ca5
proper_inform_file_processed: new implementation based on global Isar state (cf. isar.ML);
wenzelm
parents:
27537
diff
changeset
|
326 |
in () end; |
21642 | 327 |
|
328 |
||
329 |
||
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
330 |
(** theorem dependencies **) |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
331 |
|
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
332 |
(* thm_deps *) |
51970 | 333 |
|
334 |
local |
|
335 |
||
336 |
fun add_proof_body (PBody {thms, ...}) = |
|
337 |
thms |> fold (fn (_, (name, _, _)) => name <> "" ? Symtab.update (name, ())); |
|
21642 | 338 |
|
51970 | 339 |
fun add_thm th = |
340 |
(case Thm.proof_body_of th of |
|
341 |
PBody {proof = PThm (_, ((name, _, _), body)), ...} => |
|
342 |
if Thm.has_name_hint th andalso Thm.get_name_hint th = name |
|
343 |
then add_proof_body (Future.join body) |
|
344 |
else I |
|
345 |
| body => add_proof_body body); |
|
346 |
||
347 |
in |
|
348 |
||
52011 | 349 |
fun get_thm_deps ths = |
51970 | 350 |
let |
351 |
(* FIXME proper derivation names!? *) |
|
352 |
val names = map Thm.get_name_hint (filter Thm.has_name_hint ths); |
|
353 |
val deps = Symtab.keys (fold add_thm ths Symtab.empty); |
|
354 |
in (names, deps) end; |
|
355 |
||
356 |
end; |
|
357 |
||
358 |
||
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
359 |
(* report via hook *) |
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
360 |
|
52011 | 361 |
val thm_deps = Unsynchronized.ref false; |
51939 | 362 |
|
21642 | 363 |
local |
364 |
||
365 |
val spaces_quote = space_implode " " o map quote; |
|
366 |
||
367 |
fun thm_deps_message (thms, deps) = |
|
21948 | 368 |
emacs_notify ("Proof General, theorem dependencies of " ^ thms ^ " are " ^ deps); |
21642 | 369 |
|
28096
046418f64474
theorem dependency output: Toplevel.add_hook, ProofGeneralPgip.new_thms_deps;
wenzelm
parents:
28020
diff
changeset
|
370 |
in |
046418f64474
theorem dependency output: Toplevel.add_hook, ProofGeneralPgip.new_thms_deps;
wenzelm
parents:
28020
diff
changeset
|
371 |
|
28103
b79e61861f0f
simplified Toplevel.add_hook: cover successful transactions only;
wenzelm
parents:
28100
diff
changeset
|
372 |
fun setup_present_hook () = Toplevel.add_hook (fn _ => fn state => fn state' => |
52011 | 373 |
if ! thm_deps andalso can Toplevel.theory_of state andalso Toplevel.is_theory state' |
28106 | 374 |
then |
51970 | 375 |
let |
376 |
val prev_facts = Global_Theory.facts_of (Toplevel.theory_of state); |
|
377 |
val facts = Global_Theory.facts_of (Toplevel.theory_of state'); |
|
52011 | 378 |
val (names, deps) = get_thm_deps (maps #2 (Facts.dest_static [prev_facts] facts)); |
28100
7650d5e0f8fb
refined theorem dependency output: previous state needs to contain a theory (not empty toplevel);
wenzelm
parents:
28096
diff
changeset
|
379 |
in |
21968 | 380 |
if null names orelse null deps then () |
381 |
else thm_deps_message (spaces_quote names, spaces_quote deps) |
|
382 |
end |
|
28096
046418f64474
theorem dependency output: Toplevel.add_hook, ProofGeneralPgip.new_thms_deps;
wenzelm
parents:
28020
diff
changeset
|
383 |
else ()); |
21642 | 384 |
|
385 |
end; |
|
386 |
||
387 |
||
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
388 |
|
52012
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
389 |
(** startup **) |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
390 |
|
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
391 |
val welcome = Output.urgent_message o Session.welcome; |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
392 |
|
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
393 |
|
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
394 |
(* init *) |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
395 |
|
52013 | 396 |
val proof_generalN = "ProofGeneral"; |
52012
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
397 |
|
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
398 |
val initialized = Unsynchronized.ref false; |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
399 |
|
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
400 |
fun init () = |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
401 |
(if ! initialized then () |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
402 |
else |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
403 |
(Output.add_mode Symbol.xsymbolsN Symbol.output Output.default_escape; |
52013 | 404 |
Output.add_mode proof_generalN Output.default_output Output.default_escape; |
405 |
Markup.add_mode proof_generalN YXML.output_markup; |
|
52012
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
406 |
setup_messages (); |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
407 |
setup_thy_loader (); |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
408 |
setup_present_hook (); |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
409 |
initialized := true); |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
410 |
sync_thy_loader (); |
52013 | 411 |
Unsynchronized.change print_mode (update (op =) proof_generalN); |
52012
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
412 |
Secure.PG_setup (); |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
413 |
welcome (); |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
414 |
Isar.toplevel_loop TextIO.stdIn |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
415 |
{init = true, welcome = false, sync = true, secure = Secure.is_secure ()}); |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
416 |
|
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
417 |
|
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
418 |
(* restart *) |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
419 |
|
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
420 |
fun restart () = |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
421 |
(sync_thy_loader (); |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
422 |
tell_clear_goals (); |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
423 |
tell_clear_response (); |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
424 |
Isar.init (); |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
425 |
welcome ()); |
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
426 |
|
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
427 |
|
9ebf2da69b29
uniform welcome -- actually visible on startup via Output.urgent_message;
wenzelm
parents:
52011
diff
changeset
|
428 |
|
52007
0b1183012a3c
maintain ProofGeneral preferences within ProofGeneral module;
wenzelm
parents:
52006
diff
changeset
|
429 |
(** Isar command syntax **) |
21642 | 430 |
|
38837
b47ee8df7ab4
discontinued separate Pure-ProofGeneral keywords session -- protocol commands are already defined in Pure;
wenzelm
parents:
38833
diff
changeset
|
431 |
val _ = |
48646
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
46961
diff
changeset
|
432 |
Outer_Syntax.improper_command |
52006 | 433 |
(("ProofGeneral.process_pgip", Keyword.control), Position.none) "(internal)" |
434 |
(Parse.text >> (fn str => Toplevel.imperative (fn () => process_pgip str))); |
|
435 |
||
436 |
val _ = |
|
437 |
Outer_Syntax.improper_command |
|
48646
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
46961
diff
changeset
|
438 |
(("ProofGeneral.pr", Keyword.diag), Position.none) "print state (internal)" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
50201
diff
changeset
|
439 |
(Scan.succeed (Toplevel.keep (fn state => |
33872 | 440 |
if Toplevel.is_toplevel state orelse Toplevel.is_theory state then tell_clear_goals () |
441 |
else (Toplevel.quiet := false; Toplevel.print_state true state)))); |
|
442 |
||
38837
b47ee8df7ab4
discontinued separate Pure-ProofGeneral keywords session -- protocol commands are already defined in Pure;
wenzelm
parents:
38833
diff
changeset
|
443 |
val _ = (*undo without output -- historical*) |
48646
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
46961
diff
changeset
|
444 |
Outer_Syntax.improper_command |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
46961
diff
changeset
|
445 |
(("ProofGeneral.undo", Keyword.control), Position.none) "(internal)" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
50201
diff
changeset
|
446 |
(Scan.succeed (Toplevel.imperative (fn () => Isar.undo 1))); |
21642 | 447 |
|
38837
b47ee8df7ab4
discontinued separate Pure-ProofGeneral keywords session -- protocol commands are already defined in Pure;
wenzelm
parents:
38833
diff
changeset
|
448 |
val _ = |
48646
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
46961
diff
changeset
|
449 |
Outer_Syntax.improper_command |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
46961
diff
changeset
|
450 |
(("ProofGeneral.restart", Keyword.control), Position.none) "(internal)" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
50201
diff
changeset
|
451 |
(Parse.opt_unit >> (K (Toplevel.imperative restart))); |
21642 | 452 |
|
38837
b47ee8df7ab4
discontinued separate Pure-ProofGeneral keywords session -- protocol commands are already defined in Pure;
wenzelm
parents:
38833
diff
changeset
|
453 |
val _ = |
48646
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
46961
diff
changeset
|
454 |
Outer_Syntax.improper_command |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
46961
diff
changeset
|
455 |
(("ProofGeneral.kill_proof", Keyword.control), Position.none) "(internal)" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
50201
diff
changeset
|
456 |
(Scan.succeed (Toplevel.imperative (fn () => (Isar.kill_proof (); tell_clear_goals ())))); |
27532 | 457 |
|
38837
b47ee8df7ab4
discontinued separate Pure-ProofGeneral keywords session -- protocol commands are already defined in Pure;
wenzelm
parents:
38833
diff
changeset
|
458 |
val _ = |
48646
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
46961
diff
changeset
|
459 |
Outer_Syntax.improper_command |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
46961
diff
changeset
|
460 |
(("ProofGeneral.inform_file_processed", Keyword.control), Position.none) "(internal)" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
50201
diff
changeset
|
461 |
(Parse.name >> (fn file => Toplevel.imperative (fn () => inform_file_processed file))); |
21642 | 462 |
|
38837
b47ee8df7ab4
discontinued separate Pure-ProofGeneral keywords session -- protocol commands are already defined in Pure;
wenzelm
parents:
38833
diff
changeset
|
463 |
val _ = |
48646
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
46961
diff
changeset
|
464 |
Outer_Syntax.improper_command |
91281e9472d8
more official command specifications, including source position;
wenzelm
parents:
46961
diff
changeset
|
465 |
(("ProofGeneral.inform_file_retracted", Keyword.control), Position.none) "(internal)" |
51658
21c10672633b
discontinued Toplevel.no_timing complication -- also recovers timing of diagnostic commands, e.g. 'find_theorems';
wenzelm
parents:
50201
diff
changeset
|
466 |
(Parse.name >> (fn file => Toplevel.imperative (fn () => inform_file_retracted file))); |
21642 | 467 |
|
468 |
end; |
|
37977
3ceccd415145
simplified/clarified theory loader: more explicit task management, kill old versions at start, commit results only in the very end, non-optional master dependency, do not store text in deps;
wenzelm
parents:
37954
diff
changeset
|
469 |