API for pprint - clojure-contrib v1.2 (stable)

by Tom Faulhaber

clojure-contrib is now deprecated

clojure-contrib is no longer being developed or maintained.

Rather than a single, monolithic, contributions library, Clojure now has a set of separate libraries for each unit of functionality. The libraries are in the Clojure GitHub organization at https://github.com/clojure. API documentation of the libraries can be found at http://clojure.github.io.

If you're looking for a specific function or namespace from the old clojure-contrib, see "Where Did Clojure.Contrib Go".


Full namespace name: clojure.contrib.pprint

Overview

This module comprises two elements:
1) A pretty printer for Clojure data structures, implemented in the
   function "pprint"
2) A Common Lisp compatible format function, implemented as
   "cl-format" because Clojure is using the name "format"
   for its Java-based format function.

See documentation for those functions for more information or complete
documentation on the the clojure-contrib web site on github.
Deprecated since clojure-contrib version 1.2

Related documentation:
A Common Lisp-compatible Format Function

A Pretty Printer for Clojure

Public Variables and Functions



*code-dispatch*

multimethod
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (*code-dispatch* object)
The pretty print dispatch function for pretty printing Clojure code.
Source


*print-base*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
The base to use for printing integers and rationals.
Source


*print-circle*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Mark circular structures (N.B. This is not yet used)
Source


*print-lines*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Maximum number of lines to print in a pretty print instance (N.B. This is not yet used)
Source


*print-miser-width*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
The column at which to enter miser style. Depending on the dispatch table,
miser style add newlines in more places to try to keep lines short allowing for further
levels of nesting.
Source


*print-pprint-dispatch*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
The pretty print dispatch function. Use with-pprint-dispatch or set-pprint-dispatch
to modify.
Source


*print-pretty*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Bind to true if you want write to use pretty printing
Source


*print-radix*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Print a radix specifier in front of integers and rationals. If *print-base* is 2, 8,
or 16, then the radix specifier used is #b, #o, or #x, respectively. Otherwise the
radix specifier is in the form #XXr where XX is the decimal value of *print-base* 
Source


*print-right-margin*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Pretty printing will try to avoid anything going beyond this column.
Set it to nil to have pprint let the line be arbitrarily long. This will ignore all
non-mandatory newlines.
Source


*print-shared*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Mark repeated structures rather than repeat them (N.B. This is not yet used)
Source


*print-suppress-namespaces*

var
This library, clojure-contrib, is deprecated. See here for more information.

  
Don't print namespaces with symbols. This is particularly useful when
pretty printing the results of macro expansions
Source


*simple-dispatch*

multimethod
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (*simple-dispatch* object)
The pretty print dispatch function for simple data structure format.
Source


cl-format

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (cl-format writer format-in & args)
An implementation of a Common Lisp compatible format function. cl-format formats its
arguments to an output stream or string based on the format control string given. It
supports sophisticated formatting of structured data.

Writer is an instance of java.io.Writer, true to output to *out* or nil to output
to a string, format-in is the format control string and the remaining arguments
are the data to be formatted.

The format control string is a string to be output with embedded 'format directives'
describing how to format the various arguments passed in.

If writer is nil, cl-format returns the formatted result string. Otherwise, cl-format
returns nil.

For example:
 (let [results [46 38 22]]
        (cl-format true "There ~[are~;is~:;are~]~:* ~d result~:p: ~{~d~^, ~}~%"
                   (count results) results))

Prints to *out*:
 There are 3 results: 46, 38, 22

Detailed documentation on format control strings is available in the "Common Lisp the
Language, 2nd edition", Chapter 22 (available online at:
http://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node200.html#SECTION002633000000000000000)
and in the Common Lisp HyperSpec at
http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm
Source


compile-format

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (compile-format format-str)
Compiles format-str into a compiled format which can be used as an argument
to cl-format just like a plain format string. Use this function for improved
performance when you're using the same format string repeatedly
Source


formatter

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (formatter format-in)
Makes a function which can directly run format-in. The function is
fn [stream & args] ... and returns nil unless the stream is nil (meaning
output to a string) in which case it returns the resulting string.

format-in can be either a control string or a previously compiled format.
Source


formatter-out

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (formatter-out format-in)
Makes a function which can directly run format-in. The function is
fn [& args] ... and returns nil. This version of the formatter macro is
designed to be used with *out* set to an appropriate Writer. In particular,
this is meant to be used as part of a pretty printer dispatch method.

format-in can be either a control string or a previously compiled format.
Source


fresh-line

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (fresh-line)
Make a newline if the Writer is not already at the beginning of the line.
N.B. Only works on ColumnWriters right now.
Source


pp

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (pp)
A convenience macro that pretty prints the last thing output. This is
exactly equivalent to (pprint *1).
Source


pprint

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (pprint object)
       (pprint object writer)
Pretty print object to the optional output writer. If the writer is not provided,
print the object to the currently bound value of *out*.
Source


pprint-indent

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (pprint-indent relative-to n)
Create an indent at this point in the pretty printing stream. This defines how
following lines are indented. relative-to can be either :block or :current depending
whether the indent should be computed relative to the start of the logical block or
the current column position. n is an offset.

Output is sent to *out* which must be a pretty printing writer.
Source


pprint-logical-block

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (pprint-logical-block options* body)
Execute the body as a pretty printing logical block with output to *out* which
must be a pretty printing writer. When used from pprint or cl-format, this can be
assumed.

Before the body, the caller can optionally specify options: :prefix, :per-line-prefix,
and :suffix.
Source


pprint-newline

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (pprint-newline kind)
Print a conditional newline to a pretty printing stream. kind specifies if the
newline is :linear, :miser, :fill, or :mandatory.

Output is sent to *out* which must be a pretty printing writer.
Source


pprint-tab

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (pprint-tab kind colnum colinc)
Tab at this point in the pretty printing stream. kind specifies whether the tab
is :line, :section, :line-relative, or :section-relative.

Colnum and colinc specify the target column and the increment to move the target
forward if the output is already past the original target.

Output is sent to *out* which must be a pretty printing writer.

THIS FUNCTION IS NOT YET IMPLEMENTED.
Source


set-pprint-dispatch

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (set-pprint-dispatch function)
Set the pretty print dispatch function to a function matching (fn [obj] ...)
where obj is the object to pretty print. That function will be called with *out* set
to a pretty printing writer to which it should do its printing.

For example functions, see *simple-dispatch* and *code-dispatch* in
clojure.contrib.pprint.dispatch.clj.
Source


use-method

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (use-method multifn dispatch-val func)
Installs a function as a new method of multimethod associated with dispatch-value. 
Source


with-pprint-dispatch

macro
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (with-pprint-dispatch function & body)
Execute body with the pretty print dispatch function bound to function.
Source


write

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (write object & kw-args)
Write an object subject to the current bindings of the printer control variables.
Use the kw-args argument to override individual variables for this call (and any
recursive calls). Returns the string result if :stream is nil or nil otherwise.

The following keyword arguments can be passed with values:
  Keyword              Meaning                              Default value
  :stream              Writer for output or nil             true (indicates *out*)
  :base                Base to use for writing rationals    Current value of *print-base*
  :circle*             If true, mark circular structures    Current value of *print-circle*
  :length              Maximum elements to show in sublists Current value of *print-length*
  :level               Maximum depth                        Current value of *print-level*
  :lines*              Maximum lines of output              Current value of *print-lines*
  :miser-width         Width to enter miser mode            Current value of *print-miser-width*
  :dispatch            The pretty print dispatch function   Current value of *print-pprint-dispatch*
  :pretty              If true, do pretty printing          Current value of *print-pretty*
  :radix               If true, prepend a radix specifier   Current value of *print-radix*
  :readably*           If true, print readably              Current value of *print-readably*
  :right-margin        The column for the right margin      Current value of *print-right-margin*
  :suppress-namespaces If true, no namespaces in symbols    Current value of *print-suppress-namespaces*

  * = not yet supported
Source


write-out

function
This library, clojure-contrib, is deprecated. See here for more information.
Usage: (write-out object)
Write an object to *out* subject to the current bindings of the printer control
variables. Use the kw-args argument to override individual variables for this call (and
any recursive calls).

*out* must be a PrettyWriter if pretty printing is enabled. This is the responsibility
of the caller.

This method is primarily intended for use by pretty print dispatch functions that
already know that the pretty printer will have set up their environment appropriately.
Normal library clients should use the standard "write" interface. 
Source
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.