Skip to content

Commit 4ed4018

Browse files
committed
honor Set Margin Width
1 parent ee60aff commit 4ed4018

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

src/coq_elpi_HOAS.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,13 @@ type options = {
345345
redflags : CClosure.RedFlags.reds option;
346346
}
347347

348-
let default_options = {
348+
let default_options () = {
349349
hoas_holes = Some Verbatim;
350350
local = None;
351351
deprecation = None;
352352
primitive = None;
353353
failsafe = false;
354-
ppwidth = 80;
354+
ppwidth = Option.default 80 (Topfmt.get_margin ());
355355
pp = Normal;
356356
pplevel = Constrexpr.LevelSome;
357357
using = None;
@@ -1360,7 +1360,7 @@ and under_coq2elpi_ctx ~calldepth state ctx ?(mk_ctx_item=fun decl -> mk_pi_arro
13601360
in
13611361
let state, coq_ctx, hyps =
13621362
let state, coq_ctx, hyps =
1363-
aux 0 ~depth:calldepth (mk_coq_context ~options:default_options state) [] state (List.rev ctx) in
1363+
aux 0 ~depth:calldepth (mk_coq_context ~options:(default_options ()) state) [] state (List.rev ctx) in
13641364
state, coq_ctx, hyps in
13651365
let state, t, gls_t = kont coq_ctx hyps ~depth:(calldepth + List.length hyps) state in
13661366
gls := gls_t @ !gls;

src/coq_elpi_HOAS.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type 'a coq_context = {
7272
}
7373
val mk_coq_context : options:options -> State.t -> empty coq_context
7474
val get_options : depth:int -> Data.hyps -> State.t -> options
75-
val default_options : options
75+
val default_options : unit -> options
7676
val upcast : [> `Options ] coq_context -> full coq_context
7777

7878
val get_current_env_sigma : depth:int ->

src/coq_elpi_builtins.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,7 @@ Supported attributes:
16671667
Out(list constant, "GlobalObjects",
16681668
Read(unit_ctx, "lists the global objects that are marked as to be abstracted at the end of the enclosing sections")),
16691669
(fun _ ~depth _ _ state ->
1670-
let { section } = mk_coq_context ~options:default_options state in
1670+
let { section } = mk_coq_context ~options:(default_options ()) state in
16711671
!: (section |> List.map (fun x -> Variable x)) )),
16721672
DocAbove);
16731673

src/coq_elpi_glob_quotation.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ let is_restricted_name =
6060

6161
(* XXX: I don't get why we use a coq_ctx here *)
6262
let under_ctx name ty bo gterm2lp ~depth state x =
63-
let coq_ctx, hyps as orig_ctx = Option.default (upcast @@ mk_coq_context ~options:default_options state,[]) (get_ctx state) in
63+
let coq_ctx, hyps as orig_ctx = Option.default (upcast @@ mk_coq_context ~options:(default_options ()) state,[]) (get_ctx state) in
6464
let state, name =
6565
let id =
6666
match name with
@@ -149,7 +149,7 @@ let rec gterm2lp ~depth state x =
149149
end
150150
| GRef(gr,_ul) -> state, in_elpi_gr ~depth state gr
151151
| GVar(id) ->
152-
let ctx, _ = Option.default (upcast @@ mk_coq_context ~options:default_options state, []) (get_ctx state) in
152+
let ctx, _ = Option.default (upcast @@ mk_coq_context ~options:(default_options ()) state, []) (get_ctx state) in
153153
if not (Id.Map.mem id ctx.name2db) then
154154
CErrors.user_err ?loc:x.CAst.loc
155155
Pp.(str"Free Coq variable " ++ Names.Id.print id ++ str " in context: " ++
@@ -178,7 +178,7 @@ let rec gterm2lp ~depth state x =
178178
match oty with
179179
| None ->
180180
let state, uv = F.Elpi.make state in
181-
let ctx, _ = Option.default (upcast @@ mk_coq_context ~options:default_options state, []) (get_ctx state) in
181+
let ctx, _ = Option.default (upcast @@ mk_coq_context ~options:(default_options ()) state, []) (get_ctx state) in
182182
let args = List.map (fun (_,x) -> E.mkBound x) (Id.Map.bindings ctx.name2db) in
183183
state, E.mkUnifVar uv ~args state
184184
| Some ty -> gterm2lp ~depth state ty in
@@ -191,7 +191,7 @@ let rec gterm2lp ~depth state x =
191191
let s, x =
192192
match E.look ~depth x with
193193
| E.App(c,call,[]) when c == E.Constants.spillc ->
194-
let _, hyps = Option.default (upcast @@ mk_coq_context ~options:default_options state, []) (get_ctx state) in
194+
let _, hyps = Option.default (upcast @@ mk_coq_context ~options:(default_options ()) state, []) (get_ctx state) in
195195
let hyps = List.map (fun { ctx_entry = t; depth = from } ->
196196
U.move ~from ~to_:depth t) hyps in
197197
s, E.mkApp c (E.mkApp E.Constants.implc (U.list_to_lp_list hyps) [call]) []
@@ -215,7 +215,7 @@ let rec gterm2lp ~depth state x =
215215

216216
| GHole (_,_,None) ->
217217
let state, uv = F.Elpi.make state in
218-
let ctx, _ = Option.default (upcast @@ mk_coq_context ~options:default_options state, []) (get_ctx state) in
218+
let ctx, _ = Option.default (upcast @@ mk_coq_context ~options:(default_options ()) state, []) (get_ctx state) in
219219
let args =
220220
Id.Map.bindings ctx.name2db |>
221221
List.filter (fun (n,_) -> not(is_restricted_name n)) |>

src/coq_elpi_utils.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ let nYI s = err Pp.(str"Not Yet Implemented: " ++ str s)
5757
let pp2string pp x =
5858
let b = Buffer.create 80 in
5959
let fmt = Format.formatter_of_buffer b in
60+
Format.pp_set_margin fmt (Option.default 80 (Topfmt.get_margin ()));
6061
Format.fprintf fmt "%a%!" pp x;
6162
Buffer.contents b
6263

src/coq_elpi_vernacular.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ let run_program loc name ~atts args =
693693
in
694694
let query ~depth state =
695695
let state, args, gls = EU.map_acc
696-
(Coq_elpi_arg_HOAS.in_elpi_cmd ~depth ~raw:raw_args Coq_elpi_HOAS.(mk_coq_context ~options:default_options state))
696+
(Coq_elpi_arg_HOAS.in_elpi_cmd ~depth ~raw:raw_args Coq_elpi_HOAS.(mk_coq_context ~options:(default_options ()) state))
697697
state args in
698698
let state, q = atts2impl loc ~depth state atts (ET.mkApp mainc (EU.list_to_lp_list args) []) in
699699
let state = API.State.set Coq_elpi_builtins.tactic_mode state false in

0 commit comments

Comments
 (0)