| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 2 |
<html> |
| 3 |
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ --> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 |
<title>pprint-fill (ANSI and GNU Common Lisp Document)</title> |
| 7 |
|
| 8 |
<meta name="description" content="pprint-fill (ANSI and GNU Common Lisp Document)"> |
| 9 |
<meta name="keywords" content="pprint-fill (ANSI and GNU Common Lisp Document)"> |
| 10 |
<meta name="resource-type" content="document"> |
| 11 |
<meta name="distribution" content="global"> |
| 12 |
<meta name="Generator" content="makeinfo"> |
| 13 |
<link href="index.html" rel="start" title="Top"> |
| 14 |
<link href="Printer-Dictionary.html" rel="up" title="Printer Dictionary"> |
| 15 |
<link href="pprint_002dindent.html" rel="next" title="pprint-indent"> |
| 16 |
<link href="pprint_002dexit_002dif_002dlist_002dexhausted.html" rel="prev" title="pprint-exit-if-list-exhausted"> |
| 17 |
<style type="text/css"> |
| 18 |
<!-- |
| 19 |
a.summary-letter {text-decoration: none} |
| 20 |
blockquote.indentedblock {margin-right: 0em} |
| 21 |
div.display {margin-left: 3.2em} |
| 22 |
div.example {margin-left: 3.2em} |
| 23 |
div.lisp {margin-left: 3.2em} |
| 24 |
kbd {font-style: oblique} |
| 25 |
pre.display {font-family: inherit} |
| 26 |
pre.format {font-family: inherit} |
| 27 |
pre.menu-comment {font-family: serif} |
| 28 |
pre.menu-preformatted {font-family: serif} |
| 29 |
span.nolinebreak {white-space: nowrap} |
| 30 |
span.roman {font-family: initial; font-weight: normal} |
| 31 |
span.sansserif {font-family: sans-serif; font-weight: normal} |
| 32 |
ul.no-bullet {list-style: none} |
| 33 |
--> |
| 34 |
</style> |
| 35 |
|
| 36 |
|
| 37 |
</head> |
| 38 |
|
| 39 |
<body lang="en"> |
| 40 |
<span id="pprint_002dfill"></span><div class="header"> |
| 41 |
<p> |
| 42 |
Next: <a href="pprint_002dindent.html" accesskey="n" rel="next">pprint-indent</a>, Previous: <a href="pprint_002dexit_002dif_002dlist_002dexhausted.html" accesskey="p" rel="prev">pprint-exit-if-list-exhausted</a>, Up: <a href="Printer-Dictionary.html" accesskey="u" rel="up">Printer Dictionary</a> </p> |
| 43 |
</div> |
| 44 |
<hr> |
| 45 |
<span id="pprint_002dfill_002c-pprint_002dlinear_002c-pprint_002dtabular-_005bFunction_005d"></span><h4 class="subsection">22.4.5 pprint-fill, pprint-linear, pprint-tabular [Function]</h4> |
| 46 |
|
| 47 |
<p><code>pprint-fill</code> <i>stream object <span class="roman">&optional</span> colon-p at-sign-p</i> ⇒ <i><b>nil</b></i> |
| 48 |
</p> |
| 49 |
<p><code>pprint-linear</code> <i>stream object <span class="roman">&optional</span> colon-p at-sign-p</i> ⇒ <i><b>nil</b></i> |
| 50 |
</p> |
| 51 |
<p><code>pprint-tabular</code> <i>stream object <span class="roman">&optional</span> colon-p at-sign-p tabsize</i> ⇒ <i><b>nil</b></i> |
| 52 |
</p> |
| 53 |
<span id="Arguments-and-Values_003a_003a-458"></span><h4 class="subsubheading">Arguments and Values::</h4> |
| 54 |
|
| 55 |
<p><i>stream</i>—an <i>output</i> <i>stream designator</i>. |
| 56 |
</p> |
| 57 |
<p><i>object</i>—an <i>object</i>. |
| 58 |
</p> |
| 59 |
<p><i>colon-p</i>—a <i>generalized boolean</i>. |
| 60 |
The default is <i>true</i>. |
| 61 |
</p> |
| 62 |
<p><i>at-sign-p</i>—a <i>generalized boolean</i>. |
| 63 |
The default is <i>implementation-dependent</i>. |
| 64 |
</p> |
| 65 |
<p><i>tabsize</i>—a non-negative <i>integer</i>. |
| 66 |
The default is <tt>16</tt>. |
| 67 |
</p> |
| 68 |
<span id="Description_003a_003a-593"></span><h4 class="subsubheading">Description::</h4> |
| 69 |
|
| 70 |
<p>The functions <b>pprint-fill</b>, <b>pprint-linear</b>, and |
| 71 |
<b>pprint-tabular</b> specify particular ways of <i>pretty printing</i> |
| 72 |
a <i>list</i> to <i>stream</i>. |
| 73 |
Each function prints parentheses around the output if and only |
| 74 |
if <i>colon-p</i> is <i>true</i>. |
| 75 |
Each function ignores its <i>at-sign-p</i> argument. |
| 76 |
(Both arguments are included even though only one is needed |
| 77 |
so that these functions can be used via <tt>~/.../</tt> |
| 78 |
and as <b>set-pprint-dispatch</b> functions, as well as directly.) |
| 79 |
Each function handles abbreviation and the detection of circularity |
| 80 |
and sharing correctly, and uses <b>write</b> to print <i>object</i> |
| 81 |
when it is a <i>non-list</i>. |
| 82 |
</p> |
| 83 |
<p>If <i>object</i> is a <i>list</i> and |
| 84 |
if the <i>value</i> of <b>*print-pretty*</b> is <i>false</i>, |
| 85 |
each of these functions prints <i>object</i> |
| 86 |
using a minimum of <i>whitespace</i>, |
| 87 |
as described in <a href="Printing-Lists-and-Conses.html">Printing Lists and Conses</a>. |
| 88 |
Otherwise (if <i>object</i> is a <i>list</i> and |
| 89 |
if the <i>value</i> of <b>*print-pretty*</b> is <i>true</i>): |
| 90 |
</p> |
| 91 |
<dl compact="compact"> |
| 92 |
<dt><tt>*</tt></dt> |
| 93 |
<dd><p>The <i>function</i> <b>pprint-linear</b> prints a <i>list</i> either all on one line, |
| 94 |
or with each <i>element</i> on a separate line. |
| 95 |
</p> |
| 96 |
</dd> |
| 97 |
<dt><tt>*</tt></dt> |
| 98 |
<dd><p>The <i>function</i> <b>pprint-fill</b> prints a <i>list</i> with as many <i>elements</i> |
| 99 |
as possible on each line. |
| 100 |
</p> |
| 101 |
</dd> |
| 102 |
<dt><tt>*</tt></dt> |
| 103 |
<dd><p>The <i>function</i> <b>pprint-tabular</b> is the same as <b>pprint-fill</b> |
| 104 |
except that it prints the <i>elements</i> so that they line up in columns. |
| 105 |
The <i>tabsize</i> specifies the column spacing in <i>ems</i>, |
| 106 |
which is the total spacing from the leading edge of one column to |
| 107 |
the leading edge of the next. |
| 108 |
</p></dd> |
| 109 |
</dl> |
| 110 |
|
| 111 |
<span id="Examples_003a_003a-429"></span><h4 class="subsubheading">Examples::</h4> |
| 112 |
|
| 113 |
<p>Evaluating the following with a line length of <tt>25</tt> produces the output shown. |
| 114 |
</p> |
| 115 |
<div class="example"> |
| 116 |
<pre class="example">(progn (princ "Roads ") |
| 117 |
(pprint-tabular *standard-output* '(elm main maple center) nil nil 8)) |
| 118 |
Roads ELM MAIN |
| 119 |
MAPLE CENTER |
| 120 |
</pre></div> |
| 121 |
|
| 122 |
<span id="Side-Effects_003a_003a-75"></span><h4 class="subsubheading">Side Effects::</h4> |
| 123 |
|
| 124 |
<p>Performs output to the indicated <i>stream</i>. |
| 125 |
</p> |
| 126 |
<span id="Affected-By_003a_003a-98"></span><h4 class="subsubheading">Affected By::</h4> |
| 127 |
|
| 128 |
<p>The cursor position on the indicated <i>stream</i>, if it can be determined. |
| 129 |
</p> |
| 130 |
<span id="Notes_003a_003a-299"></span><h4 class="subsubheading">Notes::</h4> |
| 131 |
|
| 132 |
<p>The <i>function</i> <b>pprint-tabular</b> could be defined as follows: |
| 133 |
</p> |
| 134 |
<div class="example"> |
| 135 |
<pre class="example">(defun pprint-tabular (s list &optional (colon-p t) at-sign-p (tabsize nil)) |
| 136 |
(declare (ignore at-sign-p)) |
| 137 |
(when (null tabsize) (setq tabsize 16)) |
| 138 |
(pprint-logical-block (s list :prefix (if colon-p "(" "") |
| 139 |
:suffix (if colon-p ")" "")) |
| 140 |
(pprint-exit-if-list-exhausted) |
| 141 |
(loop (write (pprint-pop) :stream s) |
| 142 |
(pprint-exit-if-list-exhausted) |
| 143 |
(write-char #\Space s) |
| 144 |
(pprint-tab :section-relative 0 tabsize s) |
| 145 |
(pprint-newline :fill s)))) |
| 146 |
</pre></div> |
| 147 |
|
| 148 |
<p>Note that it would have been inconvenient to specify this function |
| 149 |
using <b>format</b>, because of the need to pass its <i>tabsize</i> argument |
| 150 |
through to a <tt>~:T</tt> format directive nested within an iteration over a list. |
| 151 |
</p> |
| 152 |
<hr> |
| 153 |
<div class="header"> |
| 154 |
<p> |
| 155 |
Next: <a href="pprint_002dindent.html" accesskey="n" rel="next">pprint-indent</a>, Previous: <a href="pprint_002dexit_002dif_002dlist_002dexhausted.html" accesskey="p" rel="prev">pprint-exit-if-list-exhausted</a>, Up: <a href="Printer-Dictionary.html" accesskey="u" rel="up">Printer Dictionary</a> </p> |
| 156 |
</div> |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
</body> |
| 161 |
</html> |