Function: prin1-to-string
prin1-to-string is a function defined in print.c.
Signature
(prin1-to-string OBJECT &optional NOESCAPE)
Documentation
Return a string containing the printed representation of OBJECT.
OBJECT can be any Lisp object. This function outputs quoting characters
when necessary to make output that read can handle, whenever possible,
unless the optional second argument NOESCAPE is non-nil. For complex objects,
the behavior is controlled by print-level and print-length, which see.
OBJECT is any of the Lisp data types: a number, a string, a symbol, a list, a buffer, a window, a frame, etc.
A printed representation of an object is text which describes that object.
Probably introduced at or before Emacs version 16.
Aliases
cust-print-original-prin1-to-string
Source Code
// Defined in /usr/src/emacs/src/print.c
{
ptrdiff_t count = SPECPDL_INDEX ();
specbind (Qinhibit_modification_hooks, Qt);
/* Save and restore this: we are altering a buffer
but we don't want to deactivate the mark just for that.
No need for specbind, since errors deactivate the mark. */
Lisp_Object save_deactivate_mark = Vdeactivate_mark;
Lisp_Object printcharfun = Vprin1_to_string_buffer;
PRINTPREPARE;
print (object, printcharfun, NILP (noescape));
/* Make Vprin1_to_string_buffer be the default buffer after PRINTFINISH */
PRINTFINISH;
struct buffer *previous = current_buffer;
set_buffer_internal (XBUFFER (Vprin1_to_string_buffer));
object = Fbuffer_string ();
if (SBYTES (object) == SCHARS (object))
STRING_SET_UNIBYTE (object);
/* Note that this won't make prepare_to_modify_buffer call
ask-user-about-supersession-threat because this buffer
does not visit a file. */
Ferase_buffer ();
set_buffer_internal (previous);
Vdeactivate_mark = save_deactivate_mark;
return unbind_to (count, object);
}