@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1998 Free Software Foundation, Inc.
+@c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1998, 1999, 2001, 2002,
+@c 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@setfilename ../info/streams
@node Read and Print, Minibuffers, Debugging, Top
text produces a list (but not the same list) with elements @code{a}
and @code{b}.
- However, these two operations are not precisely inverses. There are
-three kinds of exceptions:
+ However, these two operations are not precisely inverse to each other.
+There are three kinds of exceptions:
@itemize @bullet
@item
should save the argument and arrange to return it on the next call.
This is called @dfn{unreading} the character; it happens when the Lisp
reader reads one character too many and wants to ``put it back where it
-came from''. In this case, it makes no difference what value
+came from.'' In this case, it makes no difference what value
@var{function} returns.
@end itemize
@code{t} used as a stream means that the input is read from the
minibuffer. In fact, the minibuffer is invoked once and the text
given by the user is made into a string that is then used as the
-input stream.
+input stream. If Emacs is running in batch mode, standard input is used
+instead of the minibuffer. For example,
+@example
+(message "%s" (read t))
+@end example
+will read a Lisp expression from standard input and print the result
+to standard output.
@item @code{nil}
@cindex @code{nil} input stream
@defvar standard-input
This variable holds the default input stream---the stream that
@code{read} uses when the @var{stream} argument is @code{nil}.
+The default is @code{t}, meaning use the minibuffer.
@end defvar
@node Output Streams
points into, at the marker position. The marker position advances as
characters are inserted. The value of point in the buffer has no effect
on printing when the stream is a marker, and this kind of printing
-does not move point.
+does not move point (except that if the marker points at or before the
+position of point, point advances with the surrounding text, as
+usual).
@item @var{function}
@cindex function output stream
@group
last-output
- @result{} (10 34 116 117 112 116 117 111 32 101 104
+ @result{} (10 34 116 117 112 116 117 111 32 101 104
116 32 115 105 32 115 105 104 84 34 10)
@end group
@end example
(progn (print 'The\ cat\ in)
(print "the hat")
(print " came back"))
- @print{}
+ @print{}
@print{} The\ cat\ in
- @print{}
+ @print{}
@print{} "the hat"
- @print{}
+ @print{}
@print{} " came back"
- @print{}
@result{} " came back"
@end group
@end example
@example
@group
-(progn (prin1 'The\ cat\ in)
- (prin1 "the hat")
+(progn (prin1 'The\ cat\ in)
+ (prin1 "the hat")
(prin1 " came back"))
@print{} The\ cat\ in"the hat"" came back"
@result{} " came back"
@defun terpri &optional stream
@cindex newline in print
This function outputs a newline to @var{stream}. The name stands
-for ``terminate print''.
+for ``terminate print.''
@end defun
@defun write-char character &optional stream
@end group
@end example
-See @code{format}, in @ref{String Conversion}, for other ways to obtain
+See @code{format}, in @ref{Formatting Strings}, for other ways to obtain
the printed representation of a Lisp object as a string.
@end defun
-@defmac with-output-to-string body...
-@tindex with-output-to-string
+@defmac with-output-to-string body@dots{}
This macro executes the @var{body} forms with @code{standard-output} set
up to feed output into a string. Then it returns that string.
@node Output Variables
@section Variables Affecting Output
+@cindex output-controlling variables
@defvar standard-output
The value of this variable is the default output stream---the stream
that print functions use when the @var{stream} argument is @code{nil}.
+The default is @code{t}, meaning display in the echo area.
+@end defvar
+
+@defvar print-quoted
+If this is non-@code{nil}, that means to print quoted forms using
+abbreviated reader syntax. @code{(quote foo)} prints as @code{'foo},
+@code{(function foo)} as @code{#'foo}, and backquoted forms print
+using modern backquote syntax.
@end defvar
@defvar print-escape-newlines
@code{prin1}, but not during the printing of the result.
@end defvar
-@tindex print-escape-nonascii
@defvar print-escape-nonascii
-If this variable is non-@code{nil}, then unibyte non-@sc{ascii}
+If this variable is non-@code{nil}, then unibyte non-@acronym{ASCII}
characters in strings are unconditionally printed as backslash sequences
by the print functions @code{prin1} and @code{print} that print with
quoting.
-Those functions also use backslash sequences for unibyte non-@sc{ascii}
+Those functions also use backslash sequences for unibyte non-@acronym{ASCII}
characters, regardless of the value of this variable, when the output
stream is a multibyte buffer or a marker pointing into one.
@end defvar
-@tindex print-escape-multibyte
@defvar print-escape-multibyte
-If this variable is non-@code{nil}, then multibyte non-@sc{ascii}
+If this variable is non-@code{nil}, then multibyte non-@acronym{ASCII}
characters in strings are unconditionally printed as backslash sequences
by the print functions @code{prin1} and @code{print} that print with
quoting.
Those functions also use backslash sequences for multibyte
-non-@sc{ascii} characters, regardless of the value of this variable,
+non-@acronym{ASCII} characters, regardless of the value of this variable,
when the output stream is a unibyte buffer or a marker pointing into
one.
@end defvar
@code{nil} (which is the default) means no limit.
@end defvar
- These variables are used for detecting and reporting circular
-and shared structure---but they are only defined in Emacs 21.
+@defopt eval-expression-print-length
+@defoptx eval-expression-print-level
+These are the values for @code{print-length} and @code{print-level}
+used by @code{eval-expression}, and thus, indirectly, by many
+interactive evaluation commands (@pxref{Lisp Eval,, Evaluating
+Emacs-Lisp Expressions, emacs, The GNU Emacs Manual}).
+@end defopt
+
+ These variables are used for detecting and reporting circular
+and shared structure:
-@tindex print-circle
@defvar print-circle
-If non-@code{nil}, this variable enables detection of circular
+If non-@code{nil}, this variable enables detection of circular
and shared structure in printing.
@end defvar
-@tindex print-gensym
@defvar print-gensym
If non-@code{nil}, this variable enables detection of uninterned symbols
(@pxref{Creating Symbols}) in printing. When this is enabled,
reader to produce an uninterned symbol.
@end defvar
-@tindex print-continuous-numbering
@defvar print-continuous-numbering
-To print several objects with shared structure in common, you should
-bind @code{print-continuous-numbering} to @code{t} around them all.
-That tells @code{print} not to reinitialize @code{print-number-table}
-each time.
+If non-@code{nil}, that means number continuously across print calls.
+This affects the numbers printed for @samp{#@var{n}=} labels and
+@samp{#@var{m}#} references.
+
+Don't set this variable with @code{setq}; you should only bind it
+temporarily to @code{t} with @code{let}. When you do that, you should
+also bind @code{print-number-table} to @code{nil}.
@end defvar
-@tindex print-number-table
@defvar print-number-table
-This variable holds the table used as the basis of outputting
-@samp{#@var{n}=} and @samp{#@var{n}#} constructs for circular and shared
-structure. When you want to print several objects with shared structure
-in common, you should bind @code{print-number-table} to @code{nil}
-around them all.
+This variable holds a vector used internally by printing to implement
+the @code{print-circle} feature. You should not use it except
+to bind it to @code{nil} when you bind @code{print-continuous-numbering}.
@end defvar
- Here is an example of printing two objects with a common
-set of shared substructure:
+@defvar float-output-format
+This variable specifies how to print floating point numbers. Its
+default value is @code{nil}, meaning use the shortest output
+that represents the number without losing information.
-@example
-(let ((print-circle t)
- (print-continuous-numbering t)
- print-number-table)
- (print1 x)
- (print1 y))
-@end example
+To control output format more precisely, you can put a string in this
+variable. The string should hold a @samp{%}-specification to be used
+in the C function @code{sprintf}. For further restrictions on what
+you can use, see the variable's documentation string.
+@end defvar
+
+@ignore
+ arch-tag: 07636b8c-c4e3-4735-9e06-2e864320b434
+@end ignore