Function: pp-to-string
pp-to-string is an autoloaded and byte-compiled function defined in
pp.el.gz.
Signature
(pp-to-string OBJECT &optional PP-FUNCTION)
Documentation
Return a string containing the pretty-printed representation of OBJECT.
OBJECT can be any Lisp object. Quoting characters are used as needed
to make output that read can handle, whenever this is possible.
Optional argument PP-FUNCTION overrides pp-default-function.
Probably introduced at or before Emacs version 30.1.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/pp.el.gz
;;;###autoload
(defun pp-to-string (object &optional pp-function)
"Return a string containing the pretty-printed representation of OBJECT.
OBJECT can be any Lisp object. Quoting characters are used as needed
to make output that `read' can handle, whenever this is possible.
Optional argument PP-FUNCTION overrides `pp-default-function'."
(with-temp-buffer
(lisp-mode-variables nil)
(set-syntax-table emacs-lisp-mode-syntax-table)
(funcall (or pp-function pp-default-function) object)
;; Preserve old behavior of (usually) finishing with a newline.
(unless (bolp) (insert "\n"))
(buffer-string)))