Next: Time and Date, Previous: Parsing XML, Up: Textual Conversion Packages [Contents][Index]
Next: Object-To-String, Previous: Printing Scheme, Up: Printing Scheme [Contents][Index]
(require 'generic-write)
generic-write
is a procedure that transforms a Scheme data value
(or Scheme program expression) into its textual representation and
prints it. The interface to the procedure is sufficiently general to
easily implement other useful formatting procedures such as pretty
printing, output to a string and truncated output.
Scheme data value to transform.
Boolean, controls whether characters and strings are quoted.
Extended boolean, selects format:
single line format
pretty-print (value = max nb of chars per line)
Procedure of 1 argument of string type, called repeatedly with
successive substrings of the textual representation. This procedure can
return #f
to stop the transformation.
The value returned by generic-write
is undefined.
Examples:
(write obj) ≡ (generic-write obj #f #f display-string) (display obj) ≡ (generic-write obj #t #f display-string)
where
display-string ≡ (lambda (s) (for-each write-char (string->list s)) #t)
Next: Pretty-Print, Previous: Generic-Write, Up: Printing Scheme [Contents][Index]
(require 'object->string)
Returns the textual representation of obj as a string.
Returns the textual representation of obj as a string of length at most limit.
Previous: Object-To-String, Up: Printing Scheme [Contents][Index]
(require 'pretty-print)
pretty-print
s obj on port. If port is not
specified, current-output-port
is used.
Example:
(pretty-print '((1 2 3 4 5) (6 7 8 9 10) (11 12 13 14 15) (16 17 18 19 20) (21 22 23 24 25))) -| ((1 2 3 4 5) -| (6 7 8 9 10) -| (11 12 13 14 15) -| (16 17 18 19 20) -| (21 22 23 24 25))
Returns the string of obj pretty-print
ed in width
columns. If width is not specified, (output-port-width)
is
used.
Example:
(pretty-print->string '((1 2 3 4 5) (6 7 8 9 10) (11 12 13 14 15) (16 17 18 19 20) (21 22 23 24 25))) ⇒ "((1 2 3 4 5) (6 7 8 9 10) (11 12 13 14 15) (16 17 18 19 20) (21 22 23 24 25)) "
(pretty-print->string '((1 2 3 4 5) (6 7 8 9 10) (11 12 13 14 15) (16 17 18 19 20) (21 22 23 24 25)) 16) ⇒ "((1 2 3 4 5) (6 7 8 9 10) (11 12 13 14 15) (16 17 18 19 20) (21 22 23 24 25)) "
(require 'pprint-file)
Pretty-prints all the code in infile. If outfile is
specified, the output goes to outfile, otherwise it goes to
(current-output-port)
.
infile is a port or a string naming an existing file. Scheme source code expressions and definitions are read from the port (or file) and proc is applied to them sequentially.
outfile is a port or a string. If no outfile is specified
then current-output-port
is assumed. These expanded expressions
are then pretty-print
ed to this port.
Whitepsace and comments (introduced by ;
) which are not part of
scheme expressions are reproduced in the output. This procedure does
not affect the values returned by current-input-port
,
current-error-port
, and current-output-port
.
pprint-filter-file
can be used to pre-compile macro-expansion and
thus can reduce loading time. The following will write into
exp-code.scm the result of expanding all defmacros in
code.scm.
(require 'pprint-file) (require 'defmacroexpand) (defmacro:load "my-macros.scm") (pprint-filter-file "code.scm" defmacro:expand* "exp-code.scm")
Next: Time and Date, Previous: Parsing XML, Up: Textual Conversion Packages [Contents][Index]