20.7 Overriding Output Variables

The previous section (see Output Functions) 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:


This overrides print-length.


This overrides print-level.


This overrides print-circle.


This overrides print-quoted.


This overrides print-escape-newlines.


This overrides print-escape-control-characters.


This overrides print-escape-nonascii.


This overrides print-escape-multibyte.


This overrides print-charset-text-property.


This overrides print-unreadable-function.


This overrides print-gensym.


This overrides print-continuous-numbering.


This overrides print-number-table.


This overrides float-output-format.


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.