Variable: print-unreadable-function
print-unreadable-function is a variable defined in print.c.
Value
nil
Documentation
If non-nil, a function to call when printing unreadable objects.
By default, Emacs printing functions (like prin1) print unreadable
objects as "#<...>", where "..." describes the object (for
instance, "#<marker in no buffer>").
If non-nil, it should be a function that will be called with two
arguments: the object to be printed, and the NOESCAPE flag (see
prin1-to-string). If this function returns nil, the object will be
printed as usual. If it returns a string, that string will then be
printed. If the function returns anything else, the object will not
be printed.
Probably introduced at or before Emacs version 29.1.
Source Code
// Defined in /usr/src/emacs/src/print.c
DEFVAR_LISP ("print-unreadable-function", Vprint_unreadable_function,
doc: /* If non-nil, a function to call when printing unreadable objects.
By default, Emacs printing functions (like `prin1') print unreadable
objects as \"#<...>\", where \"...\" describes the object (for
instance, \"#<marker in no buffer>\").
If non-nil, it should be a function that will be called with two
arguments: the object to be printed, and the NOESCAPE flag (see
`prin1-to-string'). If this function returns nil, the object will be
printed as usual. If it returns a string, that string will then be
printed. If the function returns anything else, the object will not
be printed. */);