liveBook · Manning

*print-miser-width*

As explained in Clojure: The Essential Reference

*print-miser-width* is a Clojure dynamic variable specifying the width at which pretty printing may enter miser mode.

*print-miser-width* is a Clojure pretty-printing variable that sets the column threshold for entering miser mode. Its default value is 40. section 23.20

Miser mode helps format heavily nested source code near a narrow right margin by permitting more line breaks and reducing excessive left indentation. Bind it locally with the right margin and code dispatch. section 23.20

Changing the threshold

With *print-right-margin* bound to 30, nested code remains heavily broken across lines. Binding *print-miser-width* to 20 produces a more compact structure, keeping the outer `(condp = x ...)` together while formatting the nested form flexibly. section 23.20

Table 23.1. The dynamic variables related to pretty printing

Name

Namespace

Default

Description

*print-readably*

clojure.core

true

Print escape sequences literally.

*print-dup*

clojure.core

false

Print objects so they can be read back into memory.

*print-length*

clojure.core

nil

Number of items to print in a collection.

*print-level*

clojure.core

nil

Number of nesting collections level to print.

*print-meta*

clojure.core

false

Should metadata be printed as part of the object.

*print-pretty*

clojure.pprint

true

Enable/disable pretty printing.

*print-pprint-dispatch*

clojure.pprint

fn

Set pretty printer dispatch function.

*print-right-margin*

clojure.pprint

72

Number of columns to use before breaking into a newline.

*print-miser-width*

clojure.pprint

40

The column at which to enter miser style.

*print-suppress-namespaces*

clojure.pprint

nil

Remove namespace qualifier from symbols.

*print-radix*

clojure.pprint

nil

Print radix used for integers or ratio.

*print-base*

clojure.pprint

10

Change base for printing integers or ratio.

Compare *print-miser-width* with related pretty-printing controls, including *print-right-margin*, dispatch, and truncation variables. section 23.20

How Clojure: The Essential Reference covers it

How deep it goes
Defines the column threshold and demonstrates local rebinding, stopping short of implementation internals.
Examples
Uses nested condp forms printed with right margins of 30 and miser thresholds of 20.
What it assumes
Assumes familiarity with Clojure bindings, pretty printing, right margins, and nested code forms.
What you can do after
Apply it via clojure.pprint bindings to adjust formatting for deeply nested code.
How it connects
Connects pretty printing with dynamic variables, right margins, code dispatch, indentation, and nested source code.

This explainer was generated by Manning's knowledge graph from the text of Clojure: The Essential Reference. The section links point to the parts of the book it draws on.