src/Pure/ProofGeneral/proof_general_emacs.ML
author wenzelm
Mon, 13 May 2013 20:15:06 +0200
changeset 51963 7e014c16da7d
parent 51939 65548ab2fc55
child 51970 f08366cb9fd1
permissions -rw-r--r--
dummy PGIP id, which appears to be sufficient for PG/Emacs; removed obsolete init operations;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
     1
(*  Title:      Pure/ProofGeneral/proof_general_emacs.ML
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
     2
    Author:     David Aspinall and Markus Wenzel
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
     3
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
     4
Isabelle/Isar configuration for Emacs Proof General.
26549
9838e45c6e6c moved test_markup here;
wenzelm
parents: 26542
diff changeset
     5
See also http://proofgeneral.inf.ed.ac.uk
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
     6
*)
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
     7
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
     8
signature PROOF_GENERAL =
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
     9
sig
51938
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
    10
  val init: unit -> unit
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
    11
  structure ThyLoad: sig val add_path: string -> unit end
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    12
end;
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    13
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    14
structure ProofGeneral: PROOF_GENERAL =
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    15
struct
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    16
51939
65548ab2fc55 removed obsolete test_markup;
wenzelm
parents: 51938
diff changeset
    17
(* render markup *)
26549
9838e45c6e6c moved test_markup here;
wenzelm
parents: 26542
diff changeset
    18
43777
22c87ff1b8a9 tuned signature -- less cryptic ASCII names;
wenzelm
parents: 43557
diff changeset
    19
fun special ch = chr 1 ^ ch;
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    20
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    21
local
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    22
29326
da275b7809bd xsymbols: use plain Symbol.output;
wenzelm
parents: 29321
diff changeset
    23
fun render_trees ts = fold render_tree ts
49658
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    24
and render_tree t =
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    25
  (case XML.unwrap_elem t of
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    26
    SOME (_, ts) => render_trees ts
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    27
  | NONE =>
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    28
      (case t of
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    29
        XML.Text s => Buffer.add s
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    30
      | XML.Elem ((name, props), ts) =>
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    31
          let
51939
65548ab2fc55 removed obsolete test_markup;
wenzelm
parents: 51938
diff changeset
    32
            val (bg, en) =
49658
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    33
              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
    34
              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
    35
              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
    36
              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
    37
              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
    38
              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
    39
              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
    40
              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
    41
              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
    42
              else if name = Markup.skolemN then (special "H", special "A")
49658
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    43
              else
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50163
diff changeset
    44
                (case Markup.get_entity_kind (name, props) of
49658
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    45
                  SOME kind =>
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50163
diff changeset
    46
                    if kind = Markup.classN then (special "B", special "A")
49658
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    47
                    else Markup.no_output
ae8c8b745f82 ignore wrapped markup elements in Proof General;
wenzelm
parents: 49358
diff changeset
    48
                | NONE => Markup.no_output);
51939
65548ab2fc55 removed obsolete test_markup;
wenzelm
parents: 51938
diff changeset
    49
          in Buffer.add bg #> render_trees ts #> Buffer.add en end));
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    50
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    51
in
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    52
29326
da275b7809bd xsymbols: use plain Symbol.output;
wenzelm
parents: 29321
diff changeset
    53
fun render text =
da275b7809bd xsymbols: use plain Symbol.output;
wenzelm
parents: 29321
diff changeset
    54
  Buffer.content (render_trees (YXML.parse_body text) Buffer.empty);
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    55
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    56
end;
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    57
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    58
29326
da275b7809bd xsymbols: use plain Symbol.output;
wenzelm
parents: 29321
diff changeset
    59
(* messages *)
da275b7809bd xsymbols: use plain Symbol.output;
wenzelm
parents: 29321
diff changeset
    60
da275b7809bd xsymbols: use plain Symbol.output;
wenzelm
parents: 29321
diff changeset
    61
fun message bg en prfx text =
da275b7809bd xsymbols: use plain Symbol.output;
wenzelm
parents: 29321
diff changeset
    62
  (case render text of
da275b7809bd xsymbols: use plain Symbol.output;
wenzelm
parents: 29321
diff changeset
    63
    "" => ()
44389
a3b5fdfb04a3 tuned signature -- contrast physical output primitives versus Output.raw_message;
wenzelm
parents: 44270
diff changeset
    64
  | 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
    65
29326
da275b7809bd xsymbols: use plain Symbol.output;
wenzelm
parents: 29321
diff changeset
    66
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
    67
 (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
    68
  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
    69
  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
    70
  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
    71
  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
    72
  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
    73
  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
    74
  Output.Private_Hooks.prompt_fn := (fn s => Output.physical_stdout (render s ^ special "S")));
29326
da275b7809bd xsymbols: use plain Symbol.output;
wenzelm
parents: 29321
diff changeset
    75
23641
d6f9d3acffaa toplevel prompt/print_state: proper markup, removed hooks;
wenzelm
parents: 23621
diff changeset
    76
29326
da275b7809bd xsymbols: use plain Symbol.output;
wenzelm
parents: 29321
diff changeset
    77
(* notification *)
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    78
29326
da275b7809bd xsymbols: use plain Symbol.output;
wenzelm
parents: 29321
diff changeset
    79
val emacs_notify = message (special "I") (special "J") "";
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    80
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    81
fun tell_clear_goals () =
21940
fbd068dd4d29 minor tuning;
wenzelm
parents: 21858
diff changeset
    82
  emacs_notify "Proof General, please clear the goals buffer.";
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    83
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    84
fun tell_clear_response () =
21940
fbd068dd4d29 minor tuning;
wenzelm
parents: 21858
diff changeset
    85
  emacs_notify "Proof General, please clear the response buffer.";
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    86
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    87
fun tell_file_loaded path =
21940
fbd068dd4d29 minor tuning;
wenzelm
parents: 21858
diff changeset
    88
  emacs_notify ("Proof General, this file is loaded: " ^ quote (File.platform_path path));
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    89
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    90
fun tell_file_retracted path =
21940
fbd068dd4d29 minor tuning;
wenzelm
parents: 21858
diff changeset
    91
  emacs_notify ("Proof General, you can unlock the file " ^ quote (File.platform_path path));
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    92
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    93
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    94
(* theory loader actions *)
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    95
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    96
local
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    97
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
    98
fun trace_action action name =
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 36953
diff changeset
    99
  if action = Thy_Info.Update then
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 36953
diff changeset
   100
    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
   101
  else if action = Thy_Info.Remove then
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 36953
diff changeset
   102
    List.app tell_file_retracted (Thy_Info.loaded_files name)
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   103
  else ();
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   104
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   105
in
37216
3165bc303f66 modernized some structure names, keeping a few legacy aliases;
wenzelm
parents: 36953
diff changeset
   106
  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
   107
  fun sync_thy_loader () = List.app (trace_action Thy_Info.Update) (Thy_Info.get_names ());
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   108
end;
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   109
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   110
21948
e34bc5e4e7bc removed obsolete init_pgip;
wenzelm
parents: 21945
diff changeset
   111
(* get informed about files *)
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   112
25442
0337e3df3187 removed unused inform_file_processed;
wenzelm
parents: 25436
diff changeset
   113
(*liberal low-level version*)
0337e3df3187 removed unused inform_file_processed;
wenzelm
parents: 25436
diff changeset
   114
val thy_name = perhaps (try (unsuffix ".thy")) o List.last o space_explode "/";
0337e3df3187 removed unused inform_file_processed;
wenzelm
parents: 25436
diff changeset
   115
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
   116
val inform_file_retracted = Thy_Info.kill_thy o thy_name;
25442
0337e3df3187 removed unused inform_file_processed;
wenzelm
parents: 25436
diff changeset
   117
27577
7c7a9a343ca5 proper_inform_file_processed: new implementation based on global Isar state (cf. isar.ML);
wenzelm
parents: 27537
diff changeset
   118
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
   119
  let
7c7a9a343ca5 proper_inform_file_processed: new implementation based on global Isar state (cf. isar.ML);
wenzelm
parents: 27537
diff changeset
   120
    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
   121
    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
   122
    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
   123
      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
   124
        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
   125
          (warning (cat_lines ["Failed to register theory: " ^ quote name, msg]);
46737
09ab89658a5d clarified module Thy_Load;
wenzelm
parents: 45666
diff changeset
   126
            tell_file_retracted (Thy_Load.thy_path (Path.basic name)))
29349
b49d8501720a Isar.init;
wenzelm
parents: 29326
diff changeset
   127
    val _ = Isar.init ();
27577
7c7a9a343ca5 proper_inform_file_processed: new implementation based on global Isar state (cf. isar.ML);
wenzelm
parents: 27537
diff changeset
   128
  in () end;
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   129
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   130
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   131
(* restart top-level loop (keeps most state information) *)
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   132
40132
7ee65dbffa31 renamed Output.priority to Output.urgent_message to emphasize its special role more clearly;
wenzelm
parents: 39733
diff changeset
   133
val welcome = Output.urgent_message o Session.welcome;
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   134
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   135
fun restart () =
21940
fbd068dd4d29 minor tuning;
wenzelm
parents: 21858
diff changeset
   136
 (sync_thy_loader ();
fbd068dd4d29 minor tuning;
wenzelm
parents: 21858
diff changeset
   137
  tell_clear_goals ();
fbd068dd4d29 minor tuning;
wenzelm
parents: 21858
diff changeset
   138
  tell_clear_response ();
29349
b49d8501720a Isar.init;
wenzelm
parents: 29326
diff changeset
   139
  Isar.init ();
27577
7c7a9a343ca5 proper_inform_file_processed: new implementation based on global Isar state (cf. isar.ML);
wenzelm
parents: 27537
diff changeset
   140
  welcome ());
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   141
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   142
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   143
(* theorem dependency output *)
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   144
51939
65548ab2fc55 removed obsolete test_markup;
wenzelm
parents: 51938
diff changeset
   145
val thm_depsN = "thm_deps";
65548ab2fc55 removed obsolete test_markup;
wenzelm
parents: 51938
diff changeset
   146
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   147
local
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   148
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   149
val spaces_quote = space_implode " " o map quote;
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   150
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   151
fun thm_deps_message (thms, deps) =
21948
e34bc5e4e7bc removed obsolete init_pgip;
wenzelm
parents: 21945
diff changeset
   152
  emacs_notify ("Proof General, theorem dependencies of " ^ thms ^ " are " ^ deps);
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   153
28096
046418f64474 theorem dependency output: Toplevel.add_hook, ProofGeneralPgip.new_thms_deps;
wenzelm
parents: 28020
diff changeset
   154
in
046418f64474 theorem dependency output: Toplevel.add_hook, ProofGeneralPgip.new_thms_deps;
wenzelm
parents: 28020
diff changeset
   155
28103
b79e61861f0f simplified Toplevel.add_hook: cover successful transactions only;
wenzelm
parents: 28100
diff changeset
   156
fun setup_present_hook () = Toplevel.add_hook (fn _ => fn state => fn state' =>
28106
48b9c8756020 theorem dependency hook: check previous state;
wenzelm
parents: 28103
diff changeset
   157
  if print_mode_active thm_depsN andalso
48b9c8756020 theorem dependency hook: check previous state;
wenzelm
parents: 28103
diff changeset
   158
    can Toplevel.theory_of state andalso Toplevel.is_theory state'
48b9c8756020 theorem dependency hook: check previous state;
wenzelm
parents: 28103
diff changeset
   159
  then
28100
7650d5e0f8fb refined theorem dependency output: previous state needs to contain a theory (not empty toplevel);
wenzelm
parents: 28096
diff changeset
   160
    let val (names, deps) =
7650d5e0f8fb refined theorem dependency output: previous state needs to contain a theory (not empty toplevel);
wenzelm
parents: 28096
diff changeset
   161
      ProofGeneralPgip.new_thms_deps (Toplevel.theory_of state) (Toplevel.theory_of state')
7650d5e0f8fb refined theorem dependency output: previous state needs to contain a theory (not empty toplevel);
wenzelm
parents: 28096
diff changeset
   162
    in
21968
883cd697112e removed conditional combinator;
wenzelm
parents: 21959
diff changeset
   163
      if null names orelse null deps then ()
883cd697112e removed conditional combinator;
wenzelm
parents: 21959
diff changeset
   164
      else thm_deps_message (spaces_quote names, spaces_quote deps)
883cd697112e removed conditional combinator;
wenzelm
parents: 21959
diff changeset
   165
    end
28096
046418f64474 theorem dependency output: Toplevel.add_hook, ProofGeneralPgip.new_thms_deps;
wenzelm
parents: 28020
diff changeset
   166
  else ());
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   167
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   168
end;
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   169
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   170
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   171
(* additional outer syntax for Isar *)
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   172
38837
b47ee8df7ab4 discontinued separate Pure-ProofGeneral keywords session -- protocol commands are already defined in Pure;
wenzelm
parents: 38833
diff changeset
   173
val _ =
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 46961
diff changeset
   174
  Outer_Syntax.improper_command
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 46961
diff changeset
   175
    (("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
   176
    (Scan.succeed (Toplevel.keep (fn state =>
33872
04c560b4ebc1 added command 'ProofGeneral.pr' for PG 4.0;
wenzelm
parents: 32966
diff changeset
   177
      if Toplevel.is_toplevel state orelse Toplevel.is_theory state then tell_clear_goals ()
04c560b4ebc1 added command 'ProofGeneral.pr' for PG 4.0;
wenzelm
parents: 32966
diff changeset
   178
      else (Toplevel.quiet := false; Toplevel.print_state true state))));
04c560b4ebc1 added command 'ProofGeneral.pr' for PG 4.0;
wenzelm
parents: 32966
diff changeset
   179
38837
b47ee8df7ab4 discontinued separate Pure-ProofGeneral keywords session -- protocol commands are already defined in Pure;
wenzelm
parents: 38833
diff changeset
   180
val _ = (*undo without output -- historical*)
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 46961
diff changeset
   181
  Outer_Syntax.improper_command
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 46961
diff changeset
   182
    (("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
   183
    (Scan.succeed (Toplevel.imperative (fn () => Isar.undo 1)));
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   184
38837
b47ee8df7ab4 discontinued separate Pure-ProofGeneral keywords session -- protocol commands are already defined in Pure;
wenzelm
parents: 38833
diff changeset
   185
val _ =
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 46961
diff changeset
   186
  Outer_Syntax.improper_command
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 46961
diff changeset
   187
    (("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
   188
    (Parse.opt_unit >> (K (Toplevel.imperative restart)));
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   189
38837
b47ee8df7ab4 discontinued separate Pure-ProofGeneral keywords session -- protocol commands are already defined in Pure;
wenzelm
parents: 38833
diff changeset
   190
val _ =
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 46961
diff changeset
   191
  Outer_Syntax.improper_command
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 46961
diff changeset
   192
    (("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
   193
    (Scan.succeed (Toplevel.imperative (fn () => (Isar.kill_proof (); tell_clear_goals ()))));
27532
f3d92b5dcd45 added ProofGeneral.isar_kill_proof;
wenzelm
parents: 26706
diff changeset
   194
38837
b47ee8df7ab4 discontinued separate Pure-ProofGeneral keywords session -- protocol commands are already defined in Pure;
wenzelm
parents: 38833
diff changeset
   195
val _ =
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 46961
diff changeset
   196
  Outer_Syntax.improper_command
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 46961
diff changeset
   197
    (("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
   198
    (Parse.name >> (fn file => Toplevel.imperative (fn () => inform_file_processed file)));
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   199
38837
b47ee8df7ab4 discontinued separate Pure-ProofGeneral keywords session -- protocol commands are already defined in Pure;
wenzelm
parents: 38833
diff changeset
   200
val _ =
48646
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 46961
diff changeset
   201
  Outer_Syntax.improper_command
91281e9472d8 more official command specifications, including source position;
wenzelm
parents: 46961
diff changeset
   202
    (("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
   203
    (Parse.name >> (fn file => Toplevel.imperative (fn () => inform_file_retracted file)));
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   204
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   205
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   206
(* init *)
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   207
32738
15bb09ca0378 explicit indication of Unsynchronized.ref;
wenzelm
parents: 30670
diff changeset
   208
val initialized = Unsynchronized.ref false;
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   209
51938
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   210
fun init () =
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   211
  (if ! initialized then ()
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   212
   else
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   213
    (Output.add_mode Symbol.xsymbolsN Symbol.output Output.default_escape;
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   214
     Output.add_mode ProofGeneralPgip.proof_general_emacsN
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   215
      Output.default_output Output.default_escape;
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   216
     Markup.add_mode ProofGeneralPgip.proof_general_emacsN YXML.output_markup;
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   217
     setup_messages ();
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   218
     setup_thy_loader ();
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   219
     setup_present_hook ();
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   220
     initialized := true);
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   221
   sync_thy_loader ();
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   222
   Unsynchronized.change print_mode (update (op =) ProofGeneralPgip.proof_general_emacsN);
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   223
   Secure.PG_setup ();
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   224
   Isar.toplevel_loop TextIO.stdIn
cf9c8d8d8939 Proof General interaction always uses Isar loop;
wenzelm
parents: 51935
diff changeset
   225
    {init = true, welcome = true, sync = true, secure = Secure.is_secure ()});
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   226
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
   227
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
   228
(* fake old ThyLoad -- with new semantics *)
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
   229
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
   230
structure ThyLoad =
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
   231
struct
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
   232
  val add_path = Thy_Load.set_master_path o Path.explode;
21642
54b00ca67e0e Add separate PG Emacs configuration
aspinall
parents:
diff changeset
   233
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
   234
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
   235
end;