aboutsummaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorGravatar Emilio Jesus Gallego Arias <e+git@x80.org>2016-02-11 02:13:30 +0100
committerGravatar Emilio Jesus Gallego Arias <e+git@x80.org>2016-05-31 09:38:57 +0200
commit91ee24b4a7843793a84950379277d92992ba1651 (patch)
treef176a54110e5f394acee26351c079a395dbf6a10 /dev
parentb994e3195d296e9d12c058127ced381976c3a49e (diff)
Feedback cleanup
This patch splits pretty printing representation from IO operations. - `Pp` is kept in charge of the abstract pretty printing representation. - The `Feedback` module provides interface for doing printing IO. The patch continues work initiated for 8.5 and has the following effects: - The following functions in `Pp`: `pp`, `ppnl`, `pperr`, `pperrnl`, `pperr_flush`, `pp_flush`, `flush_all`, `msg`, `msgnl`, `msgerr`, `msgerrnl`, `message` are removed. `Feedback.msg_*` functions must be used instead. - Feedback provides different backends to handle output, currently, `stdout`, `emacs` and CoqIDE backends are provided. - Clients cannot specify flush policy anymore, thus `pp_flush` et al are gone. - `Feedback.feedback` takes an `edit_or_state_id` instead of the old mix. Lightly tested: Test-suite passes, Proof General and CoqIDE seem to work.
Diffstat (limited to 'dev')
-rw-r--r--dev/doc/changes.txt63
-rw-r--r--dev/printers.mllib11
-rw-r--r--dev/top_printers.ml9
-rw-r--r--dev/vm_printers.ml2
4 files changed, 75 insertions, 10 deletions
diff --git a/dev/doc/changes.txt b/dev/doc/changes.txt
index 2f631c633..53497ff0e 100644
--- a/dev/doc/changes.txt
+++ b/dev/doc/changes.txt
@@ -2,6 +2,69 @@
= CHANGES BETWEEN COQ V8.5 AND COQ V8.6 =
=========================================
+** Logging and Pretty Printing: **
+
+* Printing functions have been removed from `Pp.mli`, which is now a
+ purely pretty-printing interface. Functions affected are:
+
+```` ocaml
+val pp : std_ppcmds -> unit
+val ppnl : std_ppcmds -> unit
+val pperr : std_ppcmds -> unit
+val pperrnl : std_ppcmds -> unit
+val pperr_flush : unit -> unit
+val pp_flush : unit -> unit
+val flush_all : unit -> unit
+val msg : std_ppcmds -> unit
+val msgnl : std_ppcmds -> unit
+val msgerr : std_ppcmds -> unit
+val msgerrnl : std_ppcmds -> unit
+val message : string -> unit
+````
+
+ which are no more available. Users of `Pp.pp msg` should now use the
+ proper `Feedback.msg_*` function. Clients also have no control over
+ flushing, the back end takes care of it.
+
+* Feedback related functions and definitions have been moved to the
+ `Feedback` module. `message_level` has been renamed to
+ level. Functions moved from Pp to Feedback are:
+
+```` ocaml
+val set_logger : logger -> unit
+val std_logger : logger
+val emacs_logger : logger
+val feedback_logger : logger
+````
+
+* We now provide several loggers, `log_via_feedback` is removed in
+ favor of `set_logger feedback_logger`. Output functions are:
+
+```` ocaml
+val with_output_to_file : string -> ('a -> 'b) -> 'a -> 'b
+val msg_info : Pp.std_ppcmds -> unit
+val msg_notice : Pp.std_ppcmds -> unit
+val msg_warning : Pp.std_ppcmds -> unit
+val msg_error : Pp.std_ppcmds -> unit
+val msg_debug : Pp.std_ppcmds -> unit
+````
+
+ with the `msg_*` functions being just an alias for `logger $Level`.
+
+* The main feedback functions are:
+
+```` ocaml
+val set_feeder : (feedback -> unit) -> unit
+val feedback : ?id:edit_or_state_id -> ?route:route_id -> feedback_content -> unit
+val set_id_for_feedback : ?route:route_id -> edit_or_state_id -> unit
+````
+ Note that `feedback` doesn't take two parameters anymore. After
+ refactoring the following function has been removed:
+
+```` ocaml
+val get_id_for_feedback : unit -> edit_or_state_id * route_id
+````
+
- The interface of the Context module was changed.
Related types and functions were put in separate submodules.
The mapping from old identifiers to new identifiers is the following:
diff --git a/dev/printers.mllib b/dev/printers.mllib
index aa74cb508..0957197cc 100644
--- a/dev/printers.mllib
+++ b/dev/printers.mllib
@@ -26,16 +26,17 @@ Control
Loc
Serialize
Stateid
-Feedback
-Pp
-Segmenttree
-Unicodetable
-Unicode
CObj
CArray
CStack
Util
+Pp
Ppstyle
+Richpp
+Feedback
+Segmenttree
+Unicodetable
+Unicode
Errors
Bigint
CUnix
diff --git a/dev/top_printers.ml b/dev/top_printers.ml
index f5599d793..4da901e53 100644
--- a/dev/top_printers.ml
+++ b/dev/top_printers.ml
@@ -29,7 +29,8 @@ let _ = set_bool_option_value ["Printing";"Matching"] false
let _ = Detyping.set_detype_anonymous (fun _ _ -> raise Not_found)
(* std_ppcmds *)
-let pppp x = pp x
+let pp x = Feedback.msg_notice x
+let pppp x = Feedback.msg_notice x
(** Future printer *)
@@ -315,7 +316,7 @@ let constr_display csr =
| Anonymous -> "Anonymous"
in
- Pp.pp (str (term_display csr) ++fnl ()); Pp.pp_flush ()
+ Feedback.msg_notice (str (term_display csr) ++fnl ())
open Format;;
@@ -515,7 +516,7 @@ let _ =
(fun () -> in_current_context constr_display c)
| _ -> failwith "Vernac extension: cannot occur")
with
- e -> Pp.pp (Errors.print e)
+ e -> Feedback.msg_notice (Errors.print e)
let _ =
extend_vernac_command_grammar ("PrintConstr", 0) None
[GramTerminal "PrintConstr";
@@ -531,7 +532,7 @@ let _ =
(fun () -> in_current_context print_pure_constr c)
| _ -> failwith "Vernac extension: cannot occur")
with
- e -> Pp.pp (Errors.print e)
+ e -> Feedback.msg_notice (Errors.print e)
let _ =
extend_vernac_command_grammar ("PrintPureConstr", 0) None
[GramTerminal "PrintPureConstr";
diff --git a/dev/vm_printers.ml b/dev/vm_printers.ml
index 1c501df80..afa94a63e 100644
--- a/dev/vm_printers.ml
+++ b/dev/vm_printers.ml
@@ -79,7 +79,7 @@ and ppwhd whd =
| Vatom_stk(a,s) ->
open_hbox();ppatom a;close_box();
print_string"@";ppstack s
- | Vuniv_level lvl -> Pp.pp (Univ.Level.pr lvl)
+ | Vuniv_level lvl -> Feedback.msg_notice (Univ.Level.pr lvl)
and ppvblock b =
open_hbox();