164 end; |
164 end; |
165 |
165 |
166 |
166 |
167 (* get informed about files *) |
167 (* get informed about files *) |
168 |
168 |
|
169 local |
|
170 |
|
171 (*liberal low-level version*) |
169 val thy_name = perhaps (try (unsuffix ".thy")) o List.last o space_explode "/"; |
172 val thy_name = perhaps (try (unsuffix ".thy")) o List.last o space_explode "/"; |
|
173 val thy_path = ThyLoad.thy_path o thy_name; |
|
174 |
|
175 in |
|
176 |
|
177 val check_thy = ThyInfo.check_known_thy o thy_name; |
|
178 |
|
179 fun proper_inform_file_processed file () = |
|
180 let |
|
181 val name = thy_name file; |
|
182 val _ = ThyInfo.touch_child_thys name; |
|
183 val _ = ThyInfo.register_thy name handle ERROR msg => |
|
184 (warning (cat_lines [msg, "Failed to register theory: " ^ quote name]); |
|
185 tell_file_retracted (thy_path file)); |
|
186 in () end; |
|
187 |
|
188 fun vacuous_inform_file_processed file () = tell_file_retracted (thy_path file); |
170 |
189 |
171 val inform_file_retracted = ThyInfo.if_known_thy ThyInfo.remove_thy o thy_name; |
190 val inform_file_retracted = ThyInfo.if_known_thy ThyInfo.remove_thy o thy_name; |
172 val inform_file_processed = ThyInfo.if_known_thy ThyInfo.touch_child_thys o thy_name; |
191 |
173 |
192 end; |
174 fun proper_inform_file_processed file () = |
|
175 let val name = thy_name file in |
|
176 if ThyInfo.known_thy name then |
|
177 (ThyInfo.touch_child_thys name; |
|
178 ThyInfo.register_thy name handle ERROR msg => |
|
179 (warning (cat_lines [msg, "Failed to register theory: " ^ quote name]); |
|
180 tell_file_retracted (Path.base (Path.explode file)))) |
|
181 else raise Toplevel.UNDEF |
|
182 end; |
|
183 |
|
184 fun vacuous_inform_file_processed file () = |
|
185 (warning ("No theory " ^ quote (thy_name file)); |
|
186 tell_file_retracted (Path.base (Path.explode file))); |
|
187 |
193 |
188 |
194 |
189 (* restart top-level loop (keeps most state information) *) |
195 (* restart top-level loop (keeps most state information) *) |
190 |
196 |
191 val welcome = priority o Session.welcome; |
197 val welcome = priority o Session.welcome; |
244 (Scan.succeed (Toplevel.no_timing o IsarCmd.kill_proof_notify tell_clear_goals)); |
250 (Scan.succeed (Toplevel.no_timing o IsarCmd.kill_proof_notify tell_clear_goals)); |
245 |
251 |
246 fun inform_file_processedP () = |
252 fun inform_file_processedP () = |
247 OuterSyntax.improper_command "ProofGeneral.inform_file_processed" "(internal)" K.control |
253 OuterSyntax.improper_command "ProofGeneral.inform_file_processed" "(internal)" K.control |
248 (P.name >> (fn file => Toplevel.no_timing o |
254 (P.name >> (fn file => Toplevel.no_timing o |
249 Toplevel.init_empty (vacuous_inform_file_processed file) o |
255 Toplevel.init_empty (K true) (vacuous_inform_file_processed file) o |
250 Toplevel.kill o |
256 Toplevel.kill o |
251 Toplevel.init_empty (proper_inform_file_processed file))); |
257 Toplevel.init_empty (fn _ => check_thy file) (proper_inform_file_processed file))); |
252 |
258 |
253 fun inform_file_retractedP () = |
259 fun inform_file_retractedP () = |
254 OuterSyntax.improper_command "ProofGeneral.inform_file_retracted" "(internal)" K.control |
260 OuterSyntax.improper_command "ProofGeneral.inform_file_retracted" "(internal)" K.control |
255 (P.name >> (Toplevel.no_timing oo |
261 (P.name >> (Toplevel.no_timing oo |
256 (fn file => Toplevel.imperative (fn () => inform_file_retracted file)))); |
262 (fn file => Toplevel.imperative (fn () => inform_file_retracted file)))); |