caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: OCaml Mailing List <caml-list@inria.fr>
Subject: [Caml-list] How can I change the margin size in the toplevel?
Date: Mon, 21 Sep 2015 16:20:18 +0200	[thread overview]
Message-ID: <m2io733lct.fsf@polytechnique.org> (raw)

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

Hello,

I’m writing some slides for an ocaml course that contain the output sent
by the toplevel, such as the following:

# let x = 1 + "toto";;
Error: This expression has type string but an expression was expected of type
         int

As the messages are too wide to fit on the width of the slide, they are
put in an environment that wraps them. The results look like this:

Characters 12-18:
  let x = 1 + "toto";;
              ^^^^^^
Error: This expression has type string but an expression was expected of
      type
         int

I’m trying to get rid of the line break before “int”, and looking at the
code, I see that the toplevel uses Format with break hints for these
messages, so I should be able to do this by setting the margin to a big
number. Unfortunately I don’t seem to be able to change the margin of
the formatter used in the toplevel. I tried both:

Format.pp_set_margin Format.err_formatter 200

and

Format.pp_set_margin Format.std_formatter 200

inside the toplevel but it does not change the formatter for these
messages.

Is there a way to access the formatter used by the toplevel? And if not,
is it possible to change the column at which word wrap happens?

Thanks,

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Last week athmospheric CO₂ average (Updated September 13, 2015, Mauna Loa Obs.):
397.77 ppm

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

             reply	other threads:[~2015-09-21 14:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-21 14:20 Alan Schmitt [this message]
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
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=m2io733lct.fsf@polytechnique.org \
    --to=alan.schmitt@polytechnique.org \
    --cc=caml-list@inria.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).