Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] pretty-printing with camlp4
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-02-05 (14:13)
From: Remi VANICAT <vanicat@l...>
Subject: Re: [Caml-list] pretty-printing with camlp4
Daniel de Rauglaudre <> writes:

> Hi,
> On Tue, Feb 05, 2002 at 01:17:05PM +0100, Markus Mottl wrote:
> > I would like to adapt pretty-printing of OCaml-sources with camlp4 to
> > match my style.  What would be the best way to go about this? Just copy
> > e.g. camlp4/etc/ and change it to my needs?
> You can do that indeed, but my pretty printer is badly written, it is
> probably difficult to understand. I should rewrite it using Format one
> day, but it is a big work.

by the way, if you have the file :

-- begin of file --
value set_dt x =
  Spretty.dt.val := x

value set_tol x =
  Spretty.tol.val := x

value set_sp st =
  Spretty.sp.val := Token.eval_char st

Pcaml.add_option "-dt" (Arg.Int set_dt) "change dt value";
Pcaml.add_option "-tol" (Arg.Int set_tol) "change tol value";
Pcaml.add_option "-sp" (Arg.String set_sp) "change sp value";
-- end of file --

(compile with :
 ocamlc -I +camlp4 -pp camlp4r -c 

then camlp4 will have 3 new option : -dt -tol and -sp that will
change some pretty printer action :
- tol seem to change the way you indent in a long application
- dt is the default indentation
- sp is the space char  (not sure it may be useful to change it)

(just try).

Rémi Vanicat
Bug reports:  FAQ:
To unsubscribe, mail  Archives: