1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Body/f_ppr_nl.htm
2024-04-01 10:24:07 +02:00

71 lines
8.6 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Function PPRINT-NEWLINE</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="m_ppr_lo.htm">
<LINK REL=UP HREF="c_printe.htm">
<LINK REL=NEXT HREF="m_ppr_po.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="m_ppr_lo.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_printe.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="m_ppr_po.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<A NAME="pprint-newline"><I>Function</I> <B>PPRINT-NEWLINE</B></A> <P>
<P>
<P><B>Syntax:</B><P>
<P>
<B>pprint-newline</B> <I>kind <TT>&amp;optional</TT> stream</I> =&gt; <I><A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A></I><P>
<P>
<P><B>Arguments and Values:</B><P>
<P>
<I>kind</I>---one of <TT>:linear</TT>, <TT>:fill</TT>, <TT>:miser</TT>, or <TT>:mandatory</TT>. <P>
<I>stream</I>---a <A REL=DEFINITION HREF="26_glo_s.htm#stream_designator"><I>stream designator</I></A>. The default is <A REL=DEFINITION HREF="26_glo_s.htm#standard_output"><I>standard output</I></A>. <P>
<P><B>Description:</B><P>
<P>
If <I>stream</I> is a <A REL=DEFINITION HREF="26_glo_p.htm#pretty_printing_stream"><I>pretty printing stream</I></A> and the <A REL=DEFINITION HREF="26_glo_v.htm#value"><I>value</I></A> of <A REL=DEFINITION HREF="v_pr_pre.htm#STprint-prettyST"><B>*print-pretty*</B></A> is <A REL=DEFINITION HREF="26_glo_t.htm#true"><I>true</I></A>, a line break is inserted in the output when the appropriate condition below is satisfied; otherwise, <A REL=DEFINITION HREF="#pprint-newline"><B>pprint-newline</B></A> has no effect. <P>
<I>Kind</I> specifies the style of conditional newline. This <A REL=DEFINITION HREF="26_glo_p.htm#parameter"><I>parameter</I></A> is treated as follows: <P>
<P><DL><P>
<DT><TT>:linear</TT> <P><DD>
This specifies a ``linear-style'' <A REL=DEFINITION HREF="26_glo_c.htm#conditional_newline"><I>conditional newline</I></A>. A line break is inserted if and only if the immediately containing <A REL=DEFINITION HREF="26_glo_s.htm#section"><I>section</I></A> cannot be printed on one line. The effect of this is that line breaks are either inserted at every linear-style conditional newline in a logical block or at none of them. <P>
<DT><TT>:miser</TT> <P><DD>
This specifies a ``miser-style'' <A REL=DEFINITION HREF="26_glo_c.htm#conditional_newline"><I>conditional newline</I></A>. A line break is inserted if and only if the immediately containing <A REL=DEFINITION HREF="26_glo_s.htm#section"><I>section</I></A> cannot be printed on one line and miser style is in effect in the immediately containing logical block. The effect of this is that miser-style conditional newlines act like linear-style conditional newlines, but only when miser style is in effect. Miser style is in effect for a logical block if and only if the starting position of the logical block is less than or equal to <A REL=DEFINITION HREF="v_pr_mis.htm#STprint-miser-widthST"><B>*print-miser-width*</B></A> <A REL=DEFINITION HREF="26_glo_e.htm#em"><I>ems</I></A> from the right margin. <P>
<DT><TT>:fill</TT> <P><DD>
This specifies a ``fill-style'' <A REL=DEFINITION HREF="26_glo_c.htm#conditional_newline"><I>conditional newline</I></A>. A line break is inserted if and only if either (a) the following <A REL=DEFINITION HREF="26_glo_s.htm#section"><I>section</I></A> cannot be printed on the end of the current line, (b) the preceding <A REL=DEFINITION HREF="26_glo_s.htm#section"><I>section</I></A> was not printed on a single line, or (c) the immediately containing <A REL=DEFINITION HREF="26_glo_s.htm#section"><I>section</I></A> cannot be printed on one line and miser style is in effect in the immediately containing logical block. If a logical block is broken up into a number of subsections by fill-style conditional newlines, the basic effect is that the logical block is printed with as many subsections as possible on each line. However, if miser style is in effect, fill-style conditional newlines act like linear-style conditional newlines. <P>
<DT><TT>:mandatory</TT> <P><DD>
This specifies a ``mandatory-style'' <A REL=DEFINITION HREF="26_glo_c.htm#conditional_newline"><I>conditional newline</I></A>. A line break is always inserted. This implies that none of the containing <A REL=DEFINITION HREF="26_glo_s.htm#section"><I>sections</I></A> can be printed on a single line and will therefore trigger the insertion of line breaks at linear-style conditional newlines in these <A REL=DEFINITION HREF="26_glo_s.htm#section"><I>sections</I></A>. <P>
<P></DL><P>
When a line break is inserted by any type of conditional newline, any blanks that immediately precede the conditional newline are omitted from the output and indentation is introduced at the beginning of the next line. By default, the indentation causes the following line to begin in the same horizontal position as the first character in the immediately containing logical block. (The indentation can be changed via <A REL=DEFINITION HREF="f_ppr_in.htm#pprint-indent"><B>pprint-indent</B></A>.) <P>
There are a variety of ways unconditional newlines can be introduced into the output (i.e., via <A REL=DEFINITION HREF="f_terpri.htm#terpri"><B>terpri</B></A> or by printing a string containing a newline character). As with mandatory conditional newlines, this prevents any of the containing <A REL=DEFINITION HREF="26_glo_s.htm#section"><I>sections</I></A> from being printed on one line. In general, when an unconditional newline is encountered, it is printed out without suppression of the preceding blanks and without any indentation following it. However, if a per-line prefix has been specified (see <A REL=DEFINITION HREF="m_ppr_lo.htm#pprint-logical-block"><B>pprint-logical-block</B></A>), this prefix will always be printed no matter how a newline originates. <P>
<P><B>Examples:</B><P>
<P>
See <A REL=CHILD HREF="22_bb.htm">Section 22.2.2 (Examples of using the Pretty Printer)</A>. <P>
<P><B>Side Effects:</B><P>
<P>
Output to <I>stream</I>. <P>
<P><B>Affected By:</B><P>
<P>
<A REL=DEFINITION HREF="v_pr_pre.htm#STprint-prettyST"><B>*print-pretty*</B></A>, <B>*print-miser*</B>. The presence of containing logical blocks. The placement of newlines and conditional newlines. <P>
<P><B>Exceptional Situations:</B><P>
<P>
An error of <A REL=DEFINITION HREF="26_glo_t.htm#type"><I>type</I></A> <A REL=DEFINITION HREF="e_tp_err.htm#type-error"><B>type-error</B></A> is signaled if <I>kind</I> is not one of <TT>:linear</TT>, <TT>:fill</TT>, <TT>:miser</TT>, or <TT>:mandatory</TT>. <P>
<P><B>See Also:</B><P>
<P>
<A REL=CHILD HREF="22_cea.htm">Section 22.3.5.1 (Tilde Underscore: Conditional Newline)</A>, <A REL=CHILD HREF="22_bb.htm">Section 22.2.2 (Examples of using the Pretty Printer)</A> <P>
<P><B>Notes:</B> None.
<P>
<P>
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss180.htm">GENERALIZE-PRETTY-PRINTER:UNIFY</A><LI> <A REL=CHILD HREF="../Issues/iss270.htm">PRETTY-PRINT-INTERFACE</A><P></UL><HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>