caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: "Emilio Jesús Gallego Arias" <gallego@cri.ensmp.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] How can I change the margin size in the toplevel?
Date: Wed, 23 Sep 2015 13:34:37 +0200	[thread overview]
Message-ID: <1443008077.4442.1.camel@e130.lan.sumadev.de> (raw)
In-Reply-To: <877fnh77pk.fsf@cri.ensmp.fr>

[-- Attachment #1: Type: text/plain, Size: 2102 bytes --]

Am Mittwoch, den 23.09.2015, 12:25 +0200 schrieb Emilio Jesús Gallego
Arias:
> Hi Alan,
> 
> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> 
> > Thanks a lot for this suggestion. Unfortunately it does not seem to work
> > in the toplevel: it’s as if the toplevel was not using
> > Format.std_formatter for its output. I don’t know how to get hold of the
> > formatter used in the toplevel to change its options…
> 
> Oh I see, indeed the particular problem here seems that typing errors
> are first formatted to a fresh buffer formatter, which won't inherit
> stderr's margin.
> 
> The code seems to have changed in the last months (likely due to color
> support), but the corresponding code in trunk is at parsing/location.ml:335.
> 
> Indeed, this little hack works for me(TM):
> 
> 8<--------------------------------------------------------------------8<
> Index: parsing/location.ml
> ===================================================================
> --- parsing/location.ml	(revision 16441)
> +++ parsing/location.ml	(working copy)
> @@ -333,6 +333,7 @@
>  let pp_ksprintf ?before k fmt =
>    let buf = Buffer.create 64 in
>    let ppf = Format.formatter_of_buffer buf in
> +  Format.pp_set_margin ppf (200 + 1);
>    Misc.Color.set_color_tag_handling ppf;
>    begin match before with
>      | None -> ()
> 8<--------------------------------------------------------------------8<
> 
> I don't know what would be the proper way to integrate it upstream.

Maybe to propagate the margin?

Format.pp_set_margin ppf (Format.pp_get_margin Format.std_formatter())

Don't know whether std_formatter or err_formatter is the right one.

Gerd


> Best regards,
> Emilio
> 
> 

-- 
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany    gerd@gerd-stolpmann.de
My OCaml site:          http://www.camlcity.org
Contact details:        http://www.camlcity.org/contact.html
Company homepage:       http://www.gerd-stolpmann.de
------------------------------------------------------------


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2015-09-23 11:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-21 14:20 Alan Schmitt
2015-09-22 17:14 ` Emilio Jesús Gallego Arias
2015-09-23  6:48   ` Alan Schmitt
2015-09-23  7:26     ` David MENTRE
2015-09-23 12:23       ` Alan Schmitt
2015-09-23 16:05         ` Alan Schmitt
2015-09-23 16:39           ` Gabriel Scherer
2015-09-23 10:25     ` Emilio Jesús Gallego Arias
2015-09-23 11:34       ` Gerd Stolpmann [this message]
2015-09-23 12:16         ` Alan Schmitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443008077.4442.1.camel@e130.lan.sumadev.de \
    --to=info@gerd-stolpmann.de \
    --cc=caml-list@inria.fr \
    --cc=gallego@cri.ensmp.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).