20.7 Overriding Output Variables
The previous section (see Variables Affecting Output) lists the numerous variables that control how the Emacs Lisp printer formats data for outputs. These are generally available for users to change, but sometimes you want to output data in the default format, or override the user settings in some other way. For instance, if you're storing Emacs Lisp data in a file, you don't want that data to be shortened by a print-length setting.
The prin1 and prin1-to-string functions therefore have an optional overrides argument. This argument can either be t (which means that all printing variables should be reset to the default values), or a list of settings for some of the variables. Each element in the list can be either t (which means "reset to defaults", and will usually be the first element of the list), or a pair whose car is a symbol that stands for an output variable and whose cdr is the value for that variable.
For instance, this prints using nothing but defaults:
(prin1 object nil t)
This prints object using the current printing settings, but overrides the value of print-length to be 5:
(prin1 object nil '((length . 5)))
And finally, this prints object using only default settings, but with print-length bound to 5:
(prin1 object nil '(t (length . 5)))
Below is a list of symbols that can be used, and which variables they map to:
length
This overrides print-length.
level
This overrides print-level.
circle
This overrides print-circle.
quoted
This overrides print-quoted.
escape-newlines
This overrides print-escape-newlines.
escape-control-characters
This overrides print-escape-control-characters.
escape-nonascii
This overrides print-escape-nonascii.
escape-multibyte
This overrides print-escape-multibyte.
charset-text-property
This overrides print-charset-text-property.
unreadeable-function
This overrides print-unreadable-function.
gensym
This overrides print-gensym.
continuous-numbering
This overrides print-continuous-numbering.
number-table
This overrides print-number-table.
float-format
This overrides float-output-format.
integers-as-characters
This overrides print-integers-as-characters.
In the future, more overrides may be offered that do not map directly to a variable, but can only be used via this parameter.