87 lines
5.1 KiB
HTML
87 lines
5.1 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
|
||
|
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
|
||
|
<HEAD>
|
||
|
<TITLE>27.2. Pretty Printing Control Variables</TITLE>
|
||
|
</HEAD>
|
||
|
<BODY>
|
||
|
<meta name="description" value=" Pretty Printing Control Variables">
|
||
|
<meta name="keywords" value="clm">
|
||
|
<meta name="resource-type" value="document">
|
||
|
<meta name="distribution" value="global">
|
||
|
<P>
|
||
|
<b>Common Lisp the Language, 2nd Edition</b>
|
||
|
<BR> <HR><A NAME=tex2html4752 HREF="node256.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html4750 HREF="node253.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html4744 HREF="node254.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html4754 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html4755 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
||
|
<B> Next:</B> <A NAME=tex2html4753 HREF="node256.html"> Dynamic Control of </A>
|
||
|
<B>Up:</B> <A NAME=tex2html4751 HREF="node253.html"> Pretty Printing</A>
|
||
|
<B> Previous:</B> <A NAME=tex2html4745 HREF="node254.html"> Introduction</A>
|
||
|
<HR> <P>
|
||
|
<H1><A NAME=SECTION003120000000000000000>27.2. Pretty Printing Control Variables</A></H1>
|
||
|
<P>
|
||
|
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
|
||
|
<A NAME=PPRINTVARIABLESSECTION>The</A>
|
||
|
function <tt>write</tt> accepts keyword arguments named
|
||
|
<tt>:pprint-dispatch</tt>, <tt>:miser-width</tt>, <tt>:right-margin</tt>, and <tt>:lines</tt>,
|
||
|
corresponding to these variables.
|
||
|
<P>
|
||
|
<BR><b>[Variable]</b><BR>
|
||
|
<tt>*print-pprint-dispatch*</tt><P>When <tt>*print-pretty*</tt> is not <tt>nil</tt>, printing is controlled by the `pprint
|
||
|
dispatch table' stored in the variable <tt>*print-pprint-dispatch*</tt>. The
|
||
|
initial value of <tt>*print-pprint-dispatch*</tt> is implementation-dependent and
|
||
|
causes traditional pretty printing of Lisp code. The last section of this
|
||
|
chapter explains how the contents of this table can be changed.
|
||
|
<P>
|
||
|
<BR><b>[Variable]</b><BR>
|
||
|
<tt>*print-right-margin*</tt><P>A primary goal of pretty printing is to keep the output between a pair of
|
||
|
margins. The left margin is set at the column where the output begins. If
|
||
|
this cannot be determined, the left margin is set to zero.
|
||
|
<P>
|
||
|
When <tt>*print-right-margin*</tt> is not <tt>nil</tt>, it specifies the right
|
||
|
margin to use when making layout decisions. When <tt>*print-right-margin*</tt>
|
||
|
is <tt>nil</tt> (the initial value), the right margin is set at the maximum
|
||
|
line length that can be displayed by the output stream without wraparound
|
||
|
or truncation. If this cannot be determined, the right margin is set to an
|
||
|
implementation-dependent value.
|
||
|
<P>
|
||
|
To allow for the possibility of variable-width fonts,
|
||
|
<tt>*print-right-margin*</tt> is in units of ems-the width of an
|
||
|
``m'' in the font being used to display characters on the relevant output
|
||
|
stream at the moment when the variables are consulted.
|
||
|
<P>
|
||
|
<BR><b>[Variable]</b><BR>
|
||
|
<tt>*print-miser-width*</tt><P>If <tt>*print-miser-width*</tt> is not <tt>nil</tt>, the pretty printer switches to a compact
|
||
|
style of output (called miser style) whenever the width available for
|
||
|
printing a substructure is less than or equal to <tt>*print-miser-width*</tt> ems.
|
||
|
The initial value of <tt>*print-miser-width*</tt> is implementation-dependent.
|
||
|
<P>
|
||
|
<BR><b>[Variable]</b><BR>
|
||
|
<tt>*print-lines*</tt><P>When given a value other than its initial value of <tt>nil</tt>,
|
||
|
<tt>*print-lines*</tt> limits the number of output lines produced when
|
||
|
something is pretty printed. If an attempt is made to go beyond
|
||
|
<tt>*print-lines*</tt> lines, ``<tt> ..</tt>'' (a space and two periods)
|
||
|
is printed at the end of the last
|
||
|
line followed by all of the suffixes (closing delimiters) that are pending
|
||
|
to be printed.
|
||
|
<P><pre>
|
||
|
(let ((*print-right-margin* 25) (*print-lines* 3))
|
||
|
(pprint '(progn (setq a 1 b 2 c 3 d 4))))
|
||
|
<BR>(PROGN (SETQ A 1
|
||
|
B 2
|
||
|
C 3 ..))
|
||
|
</pre><P>
|
||
|
<P>
|
||
|
(The symbol ``<tt>..</tt>'' is printed out to ensure that a reader error will
|
||
|
occur if the output is later read. A symbol different from ``<tt>...</tt>'' is
|
||
|
used to indicate that a different kind of abbreviation has occurred.)
|
||
|
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
|
||
|
<P>
|
||
|
<BR> <HR><A NAME=tex2html4752 HREF="node256.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html4750 HREF="node253.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html4744 HREF="node254.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html4754 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html4755 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
|
||
|
<B> Next:</B> <A NAME=tex2html4753 HREF="node256.html"> Dynamic Control of </A>
|
||
|
<B>Up:</B> <A NAME=tex2html4751 HREF="node253.html"> Pretty Printing</A>
|
||
|
<B> Previous:</B> <A NAME=tex2html4745 HREF="node254.html"> Introduction</A>
|
||
|
<HR> <P>
|
||
|
<HR>
|
||
|
<P><ADDRESS>
|
||
|
AI.Repository@cs.cmu.edu
|
||
|
</ADDRESS>
|
||
|
</BODY>
|