Hi, The set_margin function configure the std_formatter, ie the formatter of the standard output (the one used by printf). To change the margin when printing in a buffer, you can run something like this : # open Format;; # let buf = Buffer.create 16;; val buf : Buffer.t = # let formatter = formatter_of_buffer buf;; val formatter : Format.formatter = # pp_set_margin formatter 9;; - : unit = () # fprintf formatter "@[111,@,222,@,333,@,444,@,555,@,666@]@.";; - : unit = () # Buffer.contents buf;; - : string = "111,222,\n333,444,\n555,666\n" Best regards, Benoît Vaugon. 2014-03-06 17:34 GMT+01:00 Matthieu Dubuget : > Is the following behaviour expected, or a misunderstanding of mine? > > In short, I'd like to use the Format module to prepare an > output inside a Buffer.t. But a basic box does not > break lines as I would expect, while printf does. > > OCaml version 4.01.0 > > # open Format;; > # printf "@[111,@,222,@,333,@,444,@,555,@,666@]@.";; > 111,222,333,444,555,666 > - : unit = () > # set_margin 9;; > - : unit > = () > # printf "@[111,@,222,@,333,@,444,@,555,@,666@]@.";; > 111,222, > 333,444, > 555,666 > - : unit > = () > # sprintf "@[111,@,222,@,333,@,444,@,555,@,666@]@.";; > - : string > = > "111,222,333,444,555,666\n" > > Why doesn't sprintf exhibit the same behaviour as printf? > Trying with fprintf... > > # fprintf str_formatter "@[111,@,222,@,333,@,444,@,555,@,666@]@.";; > - : unit > = () > # flush_str_formatter ();; > - : string > = > "111,222,333,444,555,666\n" > > -- > Matthieu Dubuget > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >