1 /* Lisp object printing and output streams.
3 Copyright (C) 1985-1986, 1988, 1993-1995, 1997-2015 Free Software
6 This file is part of GNU Emacs.
8 GNU Emacs is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 GNU Emacs is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26 #include "character.h"
33 #include "intervals.h"
34 #include "blockinput.h"
42 /* Avoid actual stack overflow in print. */
43 static ptrdiff_t print_depth
;
45 /* Level of nesting inside outputting backquote in new style. */
46 static ptrdiff_t new_backquote_output
;
48 /* Detect most circularities to print finite output. */
49 #define PRINT_CIRCLE 200
50 static Lisp_Object being_printed
[PRINT_CIRCLE
];
52 /* Last char printed to stdout by printchar. */
53 static unsigned int printchar_stdout_last
;
55 /* When printing into a buffer, first we put the text in this
56 block, then insert it all at once. */
57 static char *print_buffer
;
59 /* Size allocated in print_buffer. */
60 static ptrdiff_t print_buffer_size
;
61 /* Chars stored in print_buffer. */
62 static ptrdiff_t print_buffer_pos
;
63 /* Bytes stored in print_buffer. */
64 static ptrdiff_t print_buffer_pos_byte
;
66 /* Vprint_number_table is a table, that keeps objects that are going to
67 be printed, to allow use of #n= and #n# to express sharing.
68 For any given object, the table can give the following values:
69 t the object will be printed only once.
70 -N the object will be printed several times and will take number N.
71 N the object has been printed so we can refer to it as #N#.
72 print_number_index holds the largest N already used.
73 N has to be striclty larger than 0 since we need to distinguish -N. */
74 static ptrdiff_t print_number_index
;
75 static void print_interval (INTERVAL interval
, Lisp_Object printcharfun
);
77 /* GDB resets this to zero on W32 to disable OutputDebugString calls. */
78 bool print_output_debug_flag EXTERNALLY_VISIBLE
= 1;
81 /* Low level output routines for characters and strings. */
83 /* Lisp functions to do output using a stream
84 must have the stream in a variable called printcharfun
85 and must start with PRINTPREPARE, end with PRINTFINISH.
86 Use printchar to output one character,
87 or call strout to output a block of characters. */
89 #define PRINTPREPARE \
90 struct buffer *old = current_buffer; \
91 ptrdiff_t old_point = -1, start_point = -1; \
92 ptrdiff_t old_point_byte = -1, start_point_byte = -1; \
93 ptrdiff_t specpdl_count = SPECPDL_INDEX (); \
94 bool free_print_buffer = 0; \
96 = !NILP (BVAR (current_buffer, enable_multibyte_characters)); \
97 Lisp_Object original = printcharfun; \
98 if (NILP (printcharfun)) printcharfun = Qt; \
99 if (BUFFERP (printcharfun)) \
101 if (XBUFFER (printcharfun) != current_buffer) \
102 Fset_buffer (printcharfun); \
103 printcharfun = Qnil; \
105 if (MARKERP (printcharfun)) \
107 ptrdiff_t marker_pos; \
108 if (! XMARKER (printcharfun)->buffer) \
109 error ("Marker does not point anywhere"); \
110 if (XMARKER (printcharfun)->buffer != current_buffer) \
111 set_buffer_internal (XMARKER (printcharfun)->buffer); \
112 marker_pos = marker_position (printcharfun); \
113 if (marker_pos < BEGV || marker_pos > ZV) \
114 signal_error ("Marker is outside the accessible " \
115 "part of the buffer", printcharfun); \
117 old_point_byte = PT_BYTE; \
118 SET_PT_BOTH (marker_pos, \
119 marker_byte_position (printcharfun)); \
121 start_point_byte = PT_BYTE; \
122 printcharfun = Qnil; \
124 if (NILP (printcharfun)) \
126 Lisp_Object string; \
127 if (NILP (BVAR (current_buffer, enable_multibyte_characters)) \
128 && ! print_escape_multibyte) \
129 specbind (Qprint_escape_multibyte, Qt); \
130 if (! NILP (BVAR (current_buffer, enable_multibyte_characters)) \
131 && ! print_escape_nonascii) \
132 specbind (Qprint_escape_nonascii, Qt); \
133 if (print_buffer != 0) \
135 string = make_string_from_bytes (print_buffer, \
137 print_buffer_pos_byte); \
138 record_unwind_protect (print_unwind, string); \
142 int new_size = 1000; \
143 print_buffer = xmalloc (new_size); \
144 print_buffer_size = new_size; \
145 free_print_buffer = 1; \
147 print_buffer_pos = 0; \
148 print_buffer_pos_byte = 0; \
150 if (EQ (printcharfun, Qt) && ! noninteractive) \
151 setup_echo_area_for_printing (multibyte);
153 #define PRINTFINISH \
154 if (NILP (printcharfun)) \
156 if (print_buffer_pos != print_buffer_pos_byte \
157 && NILP (BVAR (current_buffer, enable_multibyte_characters)))\
160 unsigned char *temp = SAFE_ALLOCA (print_buffer_pos + 1); \
161 copy_text ((unsigned char *) print_buffer, temp, \
162 print_buffer_pos_byte, 1, 0); \
163 insert_1_both ((char *) temp, print_buffer_pos, \
164 print_buffer_pos, 0, 1, 0); \
168 insert_1_both (print_buffer, print_buffer_pos, \
169 print_buffer_pos_byte, 0, 1, 0); \
170 signal_after_change (PT - print_buffer_pos, 0, print_buffer_pos);\
172 if (free_print_buffer) \
174 xfree (print_buffer); \
177 unbind_to (specpdl_count, Qnil); \
178 if (MARKERP (original)) \
179 set_marker_both (original, Qnil, PT, PT_BYTE); \
180 if (old_point >= 0) \
181 SET_PT_BOTH (old_point + (old_point >= start_point \
182 ? PT - start_point : 0), \
183 old_point_byte + (old_point_byte >= start_point_byte \
184 ? PT_BYTE - start_point_byte : 0)); \
185 set_buffer_internal (old);
187 /* This is used to restore the saved contents of print_buffer
188 when there is a recursive call to print. */
191 print_unwind (Lisp_Object saved_text
)
193 memcpy (print_buffer
, SDATA (saved_text
), SCHARS (saved_text
));
196 /* Print character CH to the stdio stream STREAM. */
199 printchar_to_stream (unsigned int ch
, FILE *stream
)
201 Lisp_Object dv
IF_LINT (= Qnil
);
202 ptrdiff_t i
= 0, n
= 1;
204 if (CHAR_VALID_P (ch
) && DISP_TABLE_P (Vstandard_display_table
))
206 dv
= DISP_CHAR_VECTOR (XCHAR_TABLE (Vstandard_display_table
), ch
);
216 if (ASCII_CHAR_P (ch
))
220 /* Send the output to a debugger (nothing happens if there
222 if (print_output_debug_flag
&& stream
== stderr
)
223 OutputDebugString ((char []) {ch
, '\0'});
228 unsigned char mbstr
[MAX_MULTIBYTE_LENGTH
];
229 int len
= CHAR_STRING (ch
, mbstr
);
230 Lisp_Object encoded_ch
=
231 ENCODE_SYSTEM (make_multibyte_string ((char *) mbstr
, 1, len
));
233 fwrite (SSDATA (encoded_ch
), 1, SBYTES (encoded_ch
), stream
);
235 if (print_output_debug_flag
&& stream
== stderr
)
236 OutputDebugString (SSDATA (encoded_ch
));
244 if (CHARACTERP (AREF (dv
, i
)))
248 ch
= XFASTINT (AREF (dv
, i
));
252 /* Print character CH using method FUN. FUN nil means print to
253 print_buffer. FUN t means print to echo area or stdout if
254 non-interactive. If FUN is neither nil nor t, call FUN with CH as
258 printchar (unsigned int ch
, Lisp_Object fun
)
260 if (!NILP (fun
) && !EQ (fun
, Qt
))
261 call1 (fun
, make_number (ch
));
264 unsigned char str
[MAX_MULTIBYTE_LENGTH
];
265 int len
= CHAR_STRING (ch
, str
);
271 ptrdiff_t incr
= len
- (print_buffer_size
- print_buffer_pos_byte
);
273 print_buffer
= xpalloc (print_buffer
, &print_buffer_size
,
275 memcpy (print_buffer
+ print_buffer_pos_byte
, str
, len
);
276 print_buffer_pos
+= 1;
277 print_buffer_pos_byte
+= len
;
279 else if (noninteractive
)
281 printchar_stdout_last
= ch
;
282 if (DISP_TABLE_P (Vstandard_display_table
))
283 printchar_to_stream (ch
, stdout
);
285 fwrite (str
, 1, len
, stdout
);
286 noninteractive_need_newline
= 1;
291 = !NILP (BVAR (current_buffer
, enable_multibyte_characters
));
293 setup_echo_area_for_printing (multibyte_p
);
295 message_dolog ((char *) str
, len
, 0, multibyte_p
);
301 /* Output SIZE characters, SIZE_BYTE bytes from string PTR using
302 method PRINTCHARFUN. PRINTCHARFUN nil means output to
303 print_buffer. PRINTCHARFUN t means output to the echo area or to
304 stdout if non-interactive. If neither nil nor t, call Lisp
305 function PRINTCHARFUN for each character printed. MULTIBYTE
306 non-zero means PTR contains multibyte characters.
308 In the case where PRINTCHARFUN is nil, it is safe for PTR to point
309 to data in a Lisp string. Otherwise that is not safe. */
312 strout (const char *ptr
, ptrdiff_t size
, ptrdiff_t size_byte
,
313 Lisp_Object printcharfun
)
315 if (NILP (printcharfun
))
317 ptrdiff_t incr
= size_byte
- (print_buffer_size
- print_buffer_pos_byte
);
319 print_buffer
= xpalloc (print_buffer
, &print_buffer_size
, incr
, -1, 1);
320 memcpy (print_buffer
+ print_buffer_pos_byte
, ptr
, size_byte
);
321 print_buffer_pos
+= size
;
322 print_buffer_pos_byte
+= size_byte
;
324 else if (noninteractive
&& EQ (printcharfun
, Qt
))
326 if (DISP_TABLE_P (Vstandard_display_table
))
329 for (ptrdiff_t i
= 0; i
< size_byte
; i
+= len
)
331 int ch
= STRING_CHAR_AND_LENGTH ((const unsigned char *) ptr
+ i
,
333 printchar_to_stream (ch
, stdout
);
337 fwrite (ptr
, 1, size_byte
, stdout
);
339 noninteractive_need_newline
= 1;
341 else if (EQ (printcharfun
, Qt
))
343 /* Output to echo area. We're trying to avoid a little overhead
344 here, that's the reason we don't call printchar to do the
348 = !NILP (BVAR (current_buffer
, enable_multibyte_characters
));
350 setup_echo_area_for_printing (multibyte_p
);
351 message_dolog (ptr
, size_byte
, 0, multibyte_p
);
353 if (size
== size_byte
)
355 for (i
= 0; i
< size
; ++i
)
356 insert_char ((unsigned char) *ptr
++);
361 for (i
= 0; i
< size_byte
; i
+= len
)
363 int ch
= STRING_CHAR_AND_LENGTH ((const unsigned char *) ptr
+ i
,
371 /* PRINTCHARFUN is a Lisp function. */
374 if (size
== size_byte
)
376 while (i
< size_byte
)
379 printchar (ch
, printcharfun
);
384 while (i
< size_byte
)
386 /* Here, we must convert each multi-byte form to the
387 corresponding character code before handing it to
390 int ch
= STRING_CHAR_AND_LENGTH ((const unsigned char *) ptr
+ i
,
392 printchar (ch
, printcharfun
);
399 /* Print the contents of a string STRING using PRINTCHARFUN.
400 It isn't safe to use strout in many cases,
401 because printing one char can relocate. */
404 print_string (Lisp_Object string
, Lisp_Object printcharfun
)
406 if (EQ (printcharfun
, Qt
) || NILP (printcharfun
))
410 if (print_escape_nonascii
)
411 string
= string_escape_byte8 (string
);
413 if (STRING_MULTIBYTE (string
))
414 chars
= SCHARS (string
);
415 else if (! print_escape_nonascii
416 && (EQ (printcharfun
, Qt
)
417 ? ! NILP (BVAR (&buffer_defaults
, enable_multibyte_characters
))
418 : ! NILP (BVAR (current_buffer
, enable_multibyte_characters
))))
420 /* If unibyte string STRING contains 8-bit codes, we must
421 convert STRING to a multibyte string containing the same
426 chars
= SBYTES (string
);
427 bytes
= count_size_as_multibyte (SDATA (string
), chars
);
430 newstr
= make_uninit_multibyte_string (chars
, bytes
);
431 memcpy (SDATA (newstr
), SDATA (string
), chars
);
432 str_to_multibyte (SDATA (newstr
), bytes
, chars
);
437 chars
= SBYTES (string
);
439 if (EQ (printcharfun
, Qt
))
441 /* Output to echo area. */
442 ptrdiff_t nbytes
= SBYTES (string
);
444 /* Copy the string contents so that relocation of STRING by
445 GC does not cause trouble. */
447 char *buffer
= SAFE_ALLOCA (nbytes
);
448 memcpy (buffer
, SDATA (string
), nbytes
);
450 strout (buffer
, chars
, nbytes
, printcharfun
);
455 /* No need to copy, since output to print_buffer can't GC. */
456 strout (SSDATA (string
), chars
, SBYTES (string
), printcharfun
);
460 /* Otherwise, string may be relocated by printing one char.
461 So re-fetch the string address for each character. */
463 ptrdiff_t size
= SCHARS (string
);
464 ptrdiff_t size_byte
= SBYTES (string
);
465 if (size
== size_byte
)
466 for (i
= 0; i
< size
; i
++)
467 printchar (SREF (string
, i
), printcharfun
);
469 for (i
= 0; i
< size_byte
; )
471 /* Here, we must convert each multi-byte form to the
472 corresponding character code before handing it to PRINTCHAR. */
474 int ch
= STRING_CHAR_AND_LENGTH (SDATA (string
) + i
, len
);
475 printchar (ch
, printcharfun
);
481 DEFUN ("write-char", Fwrite_char
, Swrite_char
, 1, 2, 0,
482 doc
: /* Output character CHARACTER to stream PRINTCHARFUN.
483 PRINTCHARFUN defaults to the value of `standard-output' (which see). */)
484 (Lisp_Object character
, Lisp_Object printcharfun
)
486 if (NILP (printcharfun
))
487 printcharfun
= Vstandard_output
;
488 CHECK_NUMBER (character
);
490 printchar (XINT (character
), printcharfun
);
495 /* Print the contents of a unibyte C string STRING using PRINTCHARFUN.
496 The caller should arrange to put this inside PRINTPREPARE and PRINTFINISH.
497 Do not use this on the contents of a Lisp string. */
500 print_c_string (char const *string
, Lisp_Object printcharfun
)
502 ptrdiff_t len
= strlen (string
);
503 strout (string
, len
, len
, printcharfun
);
506 /* Print unibyte C string at DATA on a specified stream PRINTCHARFUN.
507 Do not use this on the contents of a Lisp string. */
510 write_string_1 (const char *data
, Lisp_Object printcharfun
)
513 print_c_string (data
, printcharfun
);
517 /* Used from outside of print.c to print a C unibyte
518 string at DATA on the default output stream.
519 Do not use this on the contents of a Lisp string. */
522 write_string (const char *data
)
524 write_string_1 (data
, Vstandard_output
);
529 temp_output_buffer_setup (const char *bufname
)
531 ptrdiff_t count
= SPECPDL_INDEX ();
532 register struct buffer
*old
= current_buffer
;
533 register Lisp_Object buf
;
535 record_unwind_current_buffer ();
537 Fset_buffer (Fget_buffer_create (build_string (bufname
)));
539 Fkill_all_local_variables ();
540 delete_all_overlays (current_buffer
);
541 bset_directory (current_buffer
, BVAR (old
, directory
));
542 bset_read_only (current_buffer
, Qnil
);
543 bset_filename (current_buffer
, Qnil
);
544 bset_undo_list (current_buffer
, Qt
);
545 eassert (current_buffer
->overlays_before
== NULL
);
546 eassert (current_buffer
->overlays_after
== NULL
);
547 bset_enable_multibyte_characters
548 (current_buffer
, BVAR (&buffer_defaults
, enable_multibyte_characters
));
549 specbind (Qinhibit_read_only
, Qt
);
550 specbind (Qinhibit_modification_hooks
, Qt
);
552 XSETBUFFER (buf
, current_buffer
);
554 run_hook (Qtemp_buffer_setup_hook
);
556 unbind_to (count
, Qnil
);
558 specbind (Qstandard_output
, buf
);
561 static void print (Lisp_Object
, Lisp_Object
, bool);
562 static void print_preprocess (Lisp_Object
);
563 static void print_preprocess_string (INTERVAL
, Lisp_Object
);
564 static void print_object (Lisp_Object
, Lisp_Object
, bool);
566 DEFUN ("terpri", Fterpri
, Sterpri
, 0, 2, 0,
567 doc
: /* Output a newline to stream PRINTCHARFUN.
568 If ENSURE is non-nil only output a newline if not already at the
569 beginning of a line. Value is non-nil if a newline is printed.
570 If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used. */)
571 (Lisp_Object printcharfun
, Lisp_Object ensure
)
575 if (NILP (printcharfun
))
576 printcharfun
= Vstandard_output
;
581 /* Difficult to check if at line beginning so abort. */
582 else if (FUNCTIONP (printcharfun
))
583 signal_error ("Unsupported function argument", printcharfun
);
584 else if (noninteractive
&& !NILP (printcharfun
))
585 val
= printchar_stdout_last
== 10 ? Qnil
: Qt
;
587 val
= NILP (Fbolp ()) ? Qt
: Qnil
;
590 printchar ('\n', printcharfun
);
595 DEFUN ("prin1", Fprin1
, Sprin1
, 1, 2, 0,
596 doc
: /* Output the printed representation of OBJECT, any Lisp object.
597 Quoting characters are printed when needed to make output that `read'
598 can handle, whenever this is possible. For complex objects, the behavior
599 is controlled by `print-level' and `print-length', which see.
601 OBJECT is any of the Lisp data types: a number, a string, a symbol,
602 a list, a buffer, a window, a frame, etc.
604 A printed representation of an object is text which describes that object.
606 Optional argument PRINTCHARFUN is the output stream, which can be one
609 - a buffer, in which case output is inserted into that buffer at point;
610 - a marker, in which case output is inserted at marker's position;
611 - a function, in which case that function is called once for each
612 character of OBJECT's printed representation;
613 - a symbol, in which case that symbol's function definition is called; or
614 - t, in which case the output is displayed in the echo area.
616 If PRINTCHARFUN is omitted, the value of `standard-output' (which see)
618 (Lisp_Object object
, Lisp_Object printcharfun
)
620 if (NILP (printcharfun
))
621 printcharfun
= Vstandard_output
;
623 print (object
, printcharfun
, 1);
628 /* a buffer which is used to hold output being built by prin1-to-string */
629 Lisp_Object Vprin1_to_string_buffer
;
631 DEFUN ("prin1-to-string", Fprin1_to_string
, Sprin1_to_string
, 1, 2, 0,
632 doc
: /* Return a string containing the printed representation of OBJECT.
633 OBJECT can be any Lisp object. This function outputs quoting characters
634 when necessary to make output that `read' can handle, whenever possible,
635 unless the optional second argument NOESCAPE is non-nil. For complex objects,
636 the behavior is controlled by `print-level' and `print-length', which see.
638 OBJECT is any of the Lisp data types: a number, a string, a symbol,
639 a list, a buffer, a window, a frame, etc.
641 A printed representation of an object is text which describes that object. */)
642 (Lisp_Object object
, Lisp_Object noescape
)
644 ptrdiff_t count
= SPECPDL_INDEX ();
646 specbind (Qinhibit_modification_hooks
, Qt
);
648 /* Save and restore this: we are altering a buffer
649 but we don't want to deactivate the mark just for that.
650 No need for specbind, since errors deactivate the mark. */
651 Lisp_Object save_deactivate_mark
= Vdeactivate_mark
;
652 bool prev_abort_on_gc
= abort_on_gc
;
655 Lisp_Object printcharfun
= Vprin1_to_string_buffer
;
657 print (object
, printcharfun
, NILP (noescape
));
658 /* Make Vprin1_to_string_buffer be the default buffer after PRINTFINISH */
661 struct buffer
*previous
= current_buffer
;
662 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer
));
663 object
= Fbuffer_string ();
664 if (SBYTES (object
) == SCHARS (object
))
665 STRING_SET_UNIBYTE (object
);
667 /* Note that this won't make prepare_to_modify_buffer call
668 ask-user-about-supersession-threat because this buffer
669 does not visit a file. */
671 set_buffer_internal (previous
);
673 Vdeactivate_mark
= save_deactivate_mark
;
675 abort_on_gc
= prev_abort_on_gc
;
676 return unbind_to (count
, object
);
679 DEFUN ("princ", Fprinc
, Sprinc
, 1, 2, 0,
680 doc
: /* Output the printed representation of OBJECT, any Lisp object.
681 No quoting characters are used; no delimiters are printed around
682 the contents of strings.
684 OBJECT is any of the Lisp data types: a number, a string, a symbol,
685 a list, a buffer, a window, a frame, etc.
687 A printed representation of an object is text which describes that object.
689 Optional argument PRINTCHARFUN is the output stream, which can be one
692 - a buffer, in which case output is inserted into that buffer at point;
693 - a marker, in which case output is inserted at marker's position;
694 - a function, in which case that function is called once for each
695 character of OBJECT's printed representation;
696 - a symbol, in which case that symbol's function definition is called; or
697 - t, in which case the output is displayed in the echo area.
699 If PRINTCHARFUN is omitted, the value of `standard-output' (which see)
701 (Lisp_Object object
, Lisp_Object printcharfun
)
703 if (NILP (printcharfun
))
704 printcharfun
= Vstandard_output
;
706 print (object
, printcharfun
, 0);
711 DEFUN ("print", Fprint
, Sprint
, 1, 2, 0,
712 doc
: /* Output the printed representation of OBJECT, with newlines around it.
713 Quoting characters are printed when needed to make output that `read'
714 can handle, whenever this is possible. For complex objects, the behavior
715 is controlled by `print-level' and `print-length', which see.
717 OBJECT is any of the Lisp data types: a number, a string, a symbol,
718 a list, a buffer, a window, a frame, etc.
720 A printed representation of an object is text which describes that object.
722 Optional argument PRINTCHARFUN is the output stream, which can be one
725 - a buffer, in which case output is inserted into that buffer at point;
726 - a marker, in which case output is inserted at marker's position;
727 - a function, in which case that function is called once for each
728 character of OBJECT's printed representation;
729 - a symbol, in which case that symbol's function definition is called; or
730 - t, in which case the output is displayed in the echo area.
732 If PRINTCHARFUN is omitted, the value of `standard-output' (which see)
734 (Lisp_Object object
, Lisp_Object printcharfun
)
736 if (NILP (printcharfun
))
737 printcharfun
= Vstandard_output
;
739 printchar ('\n', printcharfun
);
740 print (object
, printcharfun
, 1);
741 printchar ('\n', printcharfun
);
746 DEFUN ("external-debugging-output", Fexternal_debugging_output
, Sexternal_debugging_output
, 1, 1, 0,
747 doc
: /* Write CHARACTER to stderr.
748 You can call print while debugging emacs, and pass it this function
749 to make it write to the debugging output. */)
750 (Lisp_Object character
)
752 CHECK_NUMBER (character
);
753 printchar_to_stream (XINT (character
), stderr
);
757 /* This function is never called. Its purpose is to prevent
758 print_output_debug_flag from being optimized away. */
760 extern void debug_output_compilation_hack (bool) EXTERNALLY_VISIBLE
;
762 debug_output_compilation_hack (bool x
)
764 print_output_debug_flag
= x
;
767 #if defined (GNU_LINUX)
769 /* This functionality is not vitally important in general, so we rely on
770 non-portable ability to use stderr as lvalue. */
772 #define WITH_REDIRECT_DEBUGGING_OUTPUT 1
774 static FILE *initial_stderr_stream
= NULL
;
776 DEFUN ("redirect-debugging-output", Fredirect_debugging_output
, Sredirect_debugging_output
,
778 "FDebug output file: \nP",
779 doc
: /* Redirect debugging output (stderr stream) to file FILE.
780 If FILE is nil, reset target to the initial stderr stream.
781 Optional arg APPEND non-nil (interactively, with prefix arg) means
782 append to existing target file. */)
783 (Lisp_Object file
, Lisp_Object append
)
785 if (initial_stderr_stream
!= NULL
)
791 stderr
= initial_stderr_stream
;
792 initial_stderr_stream
= NULL
;
796 file
= Fexpand_file_name (file
, Qnil
);
797 initial_stderr_stream
= stderr
;
798 stderr
= emacs_fopen (SSDATA (file
), NILP (append
) ? "w" : "a");
801 stderr
= initial_stderr_stream
;
802 initial_stderr_stream
= NULL
;
803 report_file_error ("Cannot open debugging output stream", file
);
808 #endif /* GNU_LINUX */
811 /* This is the interface for debugging printing. */
814 debug_print (Lisp_Object arg
)
816 Fprin1 (arg
, Qexternal_debugging_output
);
817 fprintf (stderr
, "\r\n");
820 void safe_debug_print (Lisp_Object
) EXTERNALLY_VISIBLE
;
822 safe_debug_print (Lisp_Object arg
)
824 int valid
= valid_lisp_object_p (arg
);
830 EMACS_UINT n
= XLI (arg
);
831 fprintf (stderr
, "#<%s_LISP_OBJECT 0x%08"pI
"x>\r\n",
832 !valid
? "INVALID" : "SOME",
838 DEFUN ("error-message-string", Ferror_message_string
, Serror_message_string
,
840 doc
: /* Convert an error value (ERROR-SYMBOL . DATA) to an error message.
841 See Info anchor `(elisp)Definition of signal' for some details on how this
842 error message is constructed. */)
845 struct buffer
*old
= current_buffer
;
848 /* If OBJ is (error STRING), just return STRING.
849 That is not only faster, it also avoids the need to allocate
850 space here when the error is due to memory full. */
851 if (CONSP (obj
) && EQ (XCAR (obj
), Qerror
)
852 && CONSP (XCDR (obj
))
853 && STRINGP (XCAR (XCDR (obj
)))
854 && NILP (XCDR (XCDR (obj
))))
855 return XCAR (XCDR (obj
));
857 print_error_message (obj
, Vprin1_to_string_buffer
, 0, Qnil
);
859 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer
));
860 value
= Fbuffer_string ();
863 set_buffer_internal (old
);
868 /* Print an error message for the error DATA onto Lisp output stream
869 STREAM (suitable for the print functions).
870 CONTEXT is a C string describing the context of the error.
871 CALLER is the Lisp function inside which the error was signaled. */
874 print_error_message (Lisp_Object data
, Lisp_Object stream
, const char *context
,
877 Lisp_Object errname
, errmsg
, file_error
, tail
;
880 write_string_1 (context
, stream
);
882 /* If we know from where the error was signaled, show it in
884 if (!NILP (caller
) && SYMBOLP (caller
))
886 Lisp_Object cname
= SYMBOL_NAME (caller
);
887 ptrdiff_t cnamelen
= SBYTES (cname
);
889 char *name
= SAFE_ALLOCA (cnamelen
);
890 memcpy (name
, SDATA (cname
), cnamelen
);
891 message_dolog (name
, cnamelen
, 0, STRING_MULTIBYTE (cname
));
892 message_dolog (": ", 2, 0, 0);
896 errname
= Fcar (data
);
898 if (EQ (errname
, Qerror
))
903 errmsg
= Fcar (data
);
908 Lisp_Object error_conditions
= Fget (errname
, Qerror_conditions
);
909 errmsg
= Fget (errname
, Qerror_message
);
910 file_error
= Fmemq (Qfile_error
, error_conditions
);
913 /* Print an error message including the data items. */
915 tail
= Fcdr_safe (data
);
917 /* For file-error, make error message by concatenating
918 all the data items. They are all strings. */
919 if (!NILP (file_error
) && CONSP (tail
))
920 errmsg
= XCAR (tail
), tail
= XCDR (tail
);
923 const char *sep
= ": ";
925 if (!STRINGP (errmsg
))
926 write_string_1 ("peculiar error", stream
);
927 else if (SCHARS (errmsg
))
928 Fprinc (Fsubstitute_command_keys (errmsg
), stream
);
932 for (; CONSP (tail
); tail
= XCDR (tail
), sep
= ", ")
937 write_string_1 (sep
, stream
);
939 if (!NILP (file_error
)
940 || EQ (errname
, Qend_of_file
) || EQ (errname
, Quser_error
))
941 Fprinc (obj
, stream
);
943 Fprin1 (obj
, stream
);
951 * The buffer should be at least as large as the max string size of the
952 * largest float, printed in the biggest notation. This is undoubtedly
953 * 20d float_output_format, with the negative of the C-constant "HUGE"
956 * On the vax the worst case is -1e38 in 20d format which takes 61 bytes.
958 * I assume that IEEE-754 format numbers can take 329 bytes for the worst
959 * case of -1e307 in 20d float_output_format. What is one to do (short of
960 * re-writing _doprnt to be more sane)?
962 * Given the above, the buffer must be least FLOAT_TO_STRING_BUFSIZE bytes.
966 float_to_string (char *buf
, double data
)
972 /* Check for plus infinity in a way that won't lose
973 if there is no plus infinity. */
974 if (data
== data
/ 2 && data
> 1.0)
976 static char const infinity_string
[] = "1.0e+INF";
977 strcpy (buf
, infinity_string
);
978 return sizeof infinity_string
- 1;
980 /* Likewise for minus infinity. */
981 if (data
== data
/ 2 && data
< -1.0)
983 static char const minus_infinity_string
[] = "-1.0e+INF";
984 strcpy (buf
, minus_infinity_string
);
985 return sizeof minus_infinity_string
- 1;
987 /* Check for NaN in a way that won't fail if there are no NaNs. */
988 if (! (data
* 0.0 >= 0.0))
990 /* Prepend "-" if the NaN's sign bit is negative.
991 The sign bit of a double is the bit that is 1 in -0.0. */
992 static char const NaN_string
[] = "0.0e+NaN";
994 union { double d
; char c
[sizeof (double)]; } u_data
, u_minus_zero
;
997 u_minus_zero
.d
= - 0.0;
998 for (i
= 0; i
< sizeof (double); i
++)
999 if (u_data
.c
[i
] & u_minus_zero
.c
[i
])
1006 strcpy (buf
+ negative
, NaN_string
);
1007 return negative
+ sizeof NaN_string
- 1;
1010 if (NILP (Vfloat_output_format
)
1011 || !STRINGP (Vfloat_output_format
))
1014 /* Generate the fewest number of digits that represent the
1015 floating point value without losing information. */
1016 len
= dtoastr (buf
, FLOAT_TO_STRING_BUFSIZE
- 2, 0, 0, data
);
1017 /* The decimal point must be printed, or the byte compiler can
1018 get confused (Bug#8033). */
1021 else /* oink oink */
1023 /* Check that the spec we have is fully valid.
1024 This means not only valid for printf,
1025 but meant for floats, and reasonable. */
1026 cp
= SSDATA (Vfloat_output_format
);
1035 /* Check the width specification. */
1037 if ('0' <= *cp
&& *cp
<= '9')
1042 width
= (width
* 10) + (*cp
++ - '0');
1043 if (DBL_DIG
< width
)
1046 while (*cp
>= '0' && *cp
<= '9');
1048 /* A precision of zero is valid only for %f. */
1049 if (width
== 0 && *cp
!= 'f')
1053 if (*cp
!= 'e' && *cp
!= 'f' && *cp
!= 'g')
1059 len
= sprintf (buf
, SSDATA (Vfloat_output_format
), data
);
1062 /* Make sure there is a decimal point with digit after, or an
1063 exponent, so that the value is readable as a float. But don't do
1064 this with "%.0f"; it's valid for that not to produce a decimal
1065 point. Note that width can be 0 only for %.0f. */
1068 for (cp
= buf
; *cp
; cp
++)
1069 if ((*cp
< '0' || *cp
> '9') && *cp
!= '-')
1072 if (*cp
== '.' && cp
[1] == 0)
1092 print (Lisp_Object obj
, Lisp_Object printcharfun
, bool escapeflag
)
1094 new_backquote_output
= 0;
1096 /* Reset print_number_index and Vprint_number_table only when
1097 the variable Vprint_continuous_numbering is nil. Otherwise,
1098 the values of these variables will be kept between several
1100 if (NILP (Vprint_continuous_numbering
)
1101 || NILP (Vprint_number_table
))
1103 print_number_index
= 0;
1104 Vprint_number_table
= Qnil
;
1107 /* Construct Vprint_number_table for print-gensym and print-circle. */
1108 if (!NILP (Vprint_gensym
) || !NILP (Vprint_circle
))
1110 /* Construct Vprint_number_table.
1111 This increments print_number_index for the objects added. */
1113 print_preprocess (obj
);
1115 if (HASH_TABLE_P (Vprint_number_table
))
1116 { /* Remove unnecessary objects, which appear only once in OBJ;
1117 that is, whose status is Qt. */
1118 struct Lisp_Hash_Table
*h
= XHASH_TABLE (Vprint_number_table
);
1121 for (i
= 0; i
< HASH_TABLE_SIZE (h
); ++i
)
1122 if (!NILP (HASH_HASH (h
, i
))
1123 && EQ (HASH_VALUE (h
, i
), Qt
))
1124 Fremhash (HASH_KEY (h
, i
), Vprint_number_table
);
1129 print_object (obj
, printcharfun
, escapeflag
);
1132 #define PRINT_CIRCLE_CANDIDATE_P(obj) \
1133 (STRINGP (obj) || CONSP (obj) \
1134 || (VECTORLIKEP (obj) \
1135 && (VECTORP (obj) || COMPILEDP (obj) \
1136 || CHAR_TABLE_P (obj) || SUB_CHAR_TABLE_P (obj) \
1137 || HASH_TABLE_P (obj) || FONTP (obj))) \
1138 || (! NILP (Vprint_gensym) \
1140 && !SYMBOL_INTERNED_P (obj)))
1142 /* Construct Vprint_number_table according to the structure of OBJ.
1143 OBJ itself and all its elements will be added to Vprint_number_table
1144 recursively if it is a list, vector, compiled function, char-table,
1145 string (its text properties will be traced), or a symbol that has
1146 no obarray (this is for the print-gensym feature).
1147 The status fields of Vprint_number_table mean whether each object appears
1148 more than once in OBJ: Qnil at the first time, and Qt after that. */
1150 print_preprocess (Lisp_Object obj
)
1155 Lisp_Object halftail
;
1157 /* Avoid infinite recursion for circular nested structure
1158 in the case where Vprint_circle is nil. */
1159 if (NILP (Vprint_circle
))
1161 /* Give up if we go so deep that print_object will get an error. */
1162 /* See similar code in print_object. */
1163 if (print_depth
>= PRINT_CIRCLE
)
1164 error ("Apparently circular structure being printed");
1166 for (i
= 0; i
< print_depth
; i
++)
1167 if (EQ (obj
, being_printed
[i
]))
1169 being_printed
[print_depth
] = obj
;
1176 if (PRINT_CIRCLE_CANDIDATE_P (obj
))
1178 if (!HASH_TABLE_P (Vprint_number_table
))
1179 Vprint_number_table
= CALLN (Fmake_hash_table
, QCtest
, Qeq
);
1181 /* In case print-circle is nil and print-gensym is t,
1182 add OBJ to Vprint_number_table only when OBJ is a symbol. */
1183 if (! NILP (Vprint_circle
) || SYMBOLP (obj
))
1185 Lisp_Object num
= Fgethash (obj
, Vprint_number_table
, Qnil
);
1187 /* If Vprint_continuous_numbering is non-nil and OBJ is a gensym,
1188 always print the gensym with a number. This is a special for
1189 the lisp function byte-compile-output-docform. */
1190 || (!NILP (Vprint_continuous_numbering
)
1192 && !SYMBOL_INTERNED_P (obj
)))
1193 { /* OBJ appears more than once. Let's remember that. */
1194 if (!INTEGERP (num
))
1196 print_number_index
++;
1197 /* Negative number indicates it hasn't been printed yet. */
1198 Fputhash (obj
, make_number (- print_number_index
),
1199 Vprint_number_table
);
1205 /* OBJ is not yet recorded. Let's add to the table. */
1206 Fputhash (obj
, Qt
, Vprint_number_table
);
1209 switch (XTYPE (obj
))
1212 /* A string may have text properties, which can be circular. */
1213 traverse_intervals_noorder (string_intervals (obj
),
1214 print_preprocess_string
, Qnil
);
1218 /* Use HALFTAIL and LOOP_COUNT to detect circular lists,
1219 just as in print_object. */
1220 if (loop_count
&& EQ (obj
, halftail
))
1222 print_preprocess (XCAR (obj
));
1225 if (!(loop_count
& 1))
1226 halftail
= XCDR (halftail
);
1229 case Lisp_Vectorlike
:
1231 if (size
& PSEUDOVECTOR_FLAG
)
1232 size
&= PSEUDOVECTOR_SIZE_MASK
;
1233 for (i
= (SUB_CHAR_TABLE_P (obj
)
1234 ? SUB_CHAR_TABLE_OFFSET
: 0); i
< size
; i
++)
1235 print_preprocess (AREF (obj
, i
));
1236 if (HASH_TABLE_P (obj
))
1237 { /* For hash tables, the key_and_value slot is past
1238 `size' because it needs to be marked specially in case
1239 the table is weak. */
1240 struct Lisp_Hash_Table
*h
= XHASH_TABLE (obj
);
1241 print_preprocess (h
->key_and_value
);
1253 print_preprocess_string (INTERVAL interval
, Lisp_Object arg
)
1255 print_preprocess (interval
->plist
);
1258 static void print_check_string_charset_prop (INTERVAL interval
, Lisp_Object string
);
1260 #define PRINT_STRING_NON_CHARSET_FOUND 1
1261 #define PRINT_STRING_UNSAFE_CHARSET_FOUND 2
1263 /* Bitwise or of the above macros. */
1264 static int print_check_string_result
;
1267 print_check_string_charset_prop (INTERVAL interval
, Lisp_Object string
)
1271 if (NILP (interval
->plist
)
1272 || (print_check_string_result
== (PRINT_STRING_NON_CHARSET_FOUND
1273 | PRINT_STRING_UNSAFE_CHARSET_FOUND
)))
1275 for (val
= interval
->plist
; CONSP (val
) && ! EQ (XCAR (val
), Qcharset
);
1276 val
= XCDR (XCDR (val
)));
1279 print_check_string_result
|= PRINT_STRING_NON_CHARSET_FOUND
;
1282 if (! (print_check_string_result
& PRINT_STRING_NON_CHARSET_FOUND
))
1284 if (! EQ (val
, interval
->plist
)
1285 || CONSP (XCDR (XCDR (val
))))
1286 print_check_string_result
|= PRINT_STRING_NON_CHARSET_FOUND
;
1288 if (NILP (Vprint_charset_text_property
)
1289 || ! (print_check_string_result
& PRINT_STRING_UNSAFE_CHARSET_FOUND
))
1292 ptrdiff_t charpos
= interval
->position
;
1293 ptrdiff_t bytepos
= string_char_to_byte (string
, charpos
);
1294 Lisp_Object charset
;
1296 charset
= XCAR (XCDR (val
));
1297 for (i
= 0; i
< LENGTH (interval
); i
++)
1299 FETCH_STRING_CHAR_ADVANCE (c
, string
, charpos
, bytepos
);
1300 if (! ASCII_CHAR_P (c
)
1301 && ! EQ (CHARSET_NAME (CHAR_CHARSET (c
)), charset
))
1303 print_check_string_result
|= PRINT_STRING_UNSAFE_CHARSET_FOUND
;
1310 /* The value is (charset . nil). */
1311 static Lisp_Object print_prune_charset_plist
;
1314 print_prune_string_charset (Lisp_Object string
)
1316 print_check_string_result
= 0;
1317 traverse_intervals (string_intervals (string
), 0,
1318 print_check_string_charset_prop
, string
);
1319 if (! (print_check_string_result
& PRINT_STRING_UNSAFE_CHARSET_FOUND
))
1321 string
= Fcopy_sequence (string
);
1322 if (print_check_string_result
& PRINT_STRING_NON_CHARSET_FOUND
)
1324 if (NILP (print_prune_charset_plist
))
1325 print_prune_charset_plist
= list1 (Qcharset
);
1326 Fremove_text_properties (make_number (0),
1327 make_number (SCHARS (string
)),
1328 print_prune_charset_plist
, string
);
1331 Fset_text_properties (make_number (0), make_number (SCHARS (string
)),
1338 print_object (Lisp_Object obj
, Lisp_Object printcharfun
, bool escapeflag
)
1340 char buf
[max (sizeof "from..to..in " + 2 * INT_STRLEN_BOUND (EMACS_INT
),
1341 max (sizeof " . #" + INT_STRLEN_BOUND (printmax_t
),
1346 /* Detect circularities and truncate them. */
1347 if (NILP (Vprint_circle
))
1349 /* Simple but incomplete way. */
1352 /* See similar code in print_preprocess. */
1353 if (print_depth
>= PRINT_CIRCLE
)
1354 error ("Apparently circular structure being printed");
1356 for (i
= 0; i
< print_depth
; i
++)
1357 if (EQ (obj
, being_printed
[i
]))
1359 int len
= sprintf (buf
, "#%d", i
);
1360 strout (buf
, len
, len
, printcharfun
);
1363 being_printed
[print_depth
] = obj
;
1365 else if (PRINT_CIRCLE_CANDIDATE_P (obj
))
1367 /* With the print-circle feature. */
1368 Lisp_Object num
= Fgethash (obj
, Vprint_number_table
, Qnil
);
1371 EMACS_INT n
= XINT (num
);
1373 { /* Add a prefix #n= if OBJ has not yet been printed;
1374 that is, its status field is nil. */
1375 int len
= sprintf (buf
, "#%"pI
"d=", -n
);
1376 strout (buf
, len
, len
, printcharfun
);
1377 /* OBJ is going to be printed. Remember that fact. */
1378 Fputhash (obj
, make_number (- n
), Vprint_number_table
);
1382 /* Just print #n# if OBJ has already been printed. */
1383 int len
= sprintf (buf
, "#%"pI
"d#", n
);
1384 strout (buf
, len
, len
, printcharfun
);
1392 switch (XTYPE (obj
))
1396 int len
= sprintf (buf
, "%"pI
"d", XINT (obj
));
1397 strout (buf
, len
, len
, printcharfun
);
1403 char pigbuf
[FLOAT_TO_STRING_BUFSIZE
];
1404 int len
= float_to_string (pigbuf
, XFLOAT_DATA (obj
));
1405 strout (pigbuf
, len
, len
, printcharfun
);
1411 print_string (obj
, printcharfun
);
1414 ptrdiff_t i
, i_byte
;
1415 ptrdiff_t size_byte
;
1416 /* True means we must ensure that the next character we output
1417 cannot be taken as part of a hex character escape. */
1418 bool need_nonhex
= false;
1419 bool multibyte
= STRING_MULTIBYTE (obj
);
1421 if (! EQ (Vprint_charset_text_property
, Qt
))
1422 obj
= print_prune_string_charset (obj
);
1424 if (string_intervals (obj
))
1425 print_c_string ("#(", printcharfun
);
1427 printchar ('\"', printcharfun
);
1428 size_byte
= SBYTES (obj
);
1430 for (i
= 0, i_byte
= 0; i_byte
< size_byte
;)
1432 /* Here, we must convert each multi-byte form to the
1433 corresponding character code before handing it to printchar. */
1436 FETCH_STRING_CHAR_ADVANCE (c
, obj
, i
, i_byte
);
1441 ? (CHAR_BYTE8_P (c
) && (c
= CHAR_TO_BYTE8 (c
), true))
1442 : (SINGLE_BYTE_CHAR_P (c
) && ! ASCII_CHAR_P (c
)
1443 && print_escape_nonascii
))
1445 /* When printing a raw 8-bit byte in a multibyte buffer, or
1446 (when requested) a non-ASCII character in a unibyte buffer,
1447 print single-byte non-ASCII string chars
1448 using octal escapes. */
1450 int len
= sprintf (outbuf
, "\\%03o", c
+ 0u);
1451 strout (outbuf
, len
, len
, printcharfun
);
1452 need_nonhex
= false;
1455 && ! ASCII_CHAR_P (c
) && print_escape_multibyte
)
1457 /* When requested, print multibyte chars using hex escapes. */
1458 char outbuf
[sizeof "\\x" + INT_STRLEN_BOUND (c
)];
1459 int len
= sprintf (outbuf
, "\\x%04x", c
+ 0u);
1460 strout (outbuf
, len
, len
, printcharfun
);
1465 /* If we just had a hex escape, and this character
1466 could be taken as part of it,
1467 output `\ ' to prevent that. */
1468 if (need_nonhex
&& c_isxdigit (c
))
1469 print_c_string ("\\ ", printcharfun
);
1471 if (c
== '\n' && print_escape_newlines
1473 : c
== '\f' && print_escape_newlines
1475 : c
== '\"' || c
== '\\')
1476 printchar ('\\', printcharfun
);
1478 printchar (c
, printcharfun
);
1479 need_nonhex
= false;
1482 printchar ('\"', printcharfun
);
1484 if (string_intervals (obj
))
1486 traverse_intervals (string_intervals (obj
),
1487 0, print_interval
, printcharfun
);
1488 printchar (')', printcharfun
);
1496 unsigned char *p
= SDATA (SYMBOL_NAME (obj
));
1497 unsigned char *end
= p
+ SBYTES (SYMBOL_NAME (obj
));
1499 ptrdiff_t i
, i_byte
;
1500 ptrdiff_t size_byte
;
1503 name
= SYMBOL_NAME (obj
);
1505 if (p
!= end
&& (*p
== '-' || *p
== '+')) p
++;
1508 /* If symbol name begins with a digit, and ends with a digit,
1509 and contains nothing but digits and `e', it could be treated
1510 as a number. So set CONFUSING.
1512 Symbols that contain periods could also be taken as numbers,
1513 but periods are always escaped, so we don't have to worry
1515 else if (*p
>= '0' && *p
<= '9'
1516 && end
[-1] >= '0' && end
[-1] <= '9')
1518 while (p
!= end
&& ((*p
>= '0' && *p
<= '9')
1519 /* Needed for \2e10. */
1520 || *p
== 'e' || *p
== 'E'))
1522 confusing
= (end
== p
);
1527 size_byte
= SBYTES (name
);
1529 if (! NILP (Vprint_gensym
) && !SYMBOL_INTERNED_P (obj
))
1530 print_c_string ("#:", printcharfun
);
1531 else if (size_byte
== 0)
1533 print_c_string ("##", printcharfun
);
1537 for (i
= 0, i_byte
= 0; i_byte
< size_byte
;)
1539 /* Here, we must convert each multi-byte form to the
1540 corresponding character code before handing it to PRINTCHAR. */
1541 FETCH_STRING_CHAR_ADVANCE (c
, name
, i
, i_byte
);
1546 if (c
== '\"' || c
== '\\' || c
== '\''
1547 || c
== ';' || c
== '#' || c
== '(' || c
== ')'
1548 || c
== ',' || c
== '.' || c
== '`'
1549 || c
== '[' || c
== ']' || c
== '?' || c
<= 040
1552 printchar ('\\', printcharfun
);
1556 printchar (c
, printcharfun
);
1562 /* If deeper than spec'd depth, print placeholder. */
1563 if (INTEGERP (Vprint_level
)
1564 && print_depth
> XINT (Vprint_level
))
1565 print_c_string ("...", printcharfun
);
1566 else if (print_quoted
&& CONSP (XCDR (obj
)) && NILP (XCDR (XCDR (obj
)))
1567 && EQ (XCAR (obj
), Qquote
))
1569 printchar ('\'', printcharfun
);
1570 print_object (XCAR (XCDR (obj
)), printcharfun
, escapeflag
);
1572 else if (print_quoted
&& CONSP (XCDR (obj
)) && NILP (XCDR (XCDR (obj
)))
1573 && EQ (XCAR (obj
), Qfunction
))
1575 print_c_string ("#'", printcharfun
);
1576 print_object (XCAR (XCDR (obj
)), printcharfun
, escapeflag
);
1578 else if (print_quoted
&& CONSP (XCDR (obj
)) && NILP (XCDR (XCDR (obj
)))
1579 && EQ (XCAR (obj
), Qbackquote
))
1581 printchar ('`', printcharfun
);
1582 new_backquote_output
++;
1583 print_object (XCAR (XCDR (obj
)), printcharfun
, escapeflag
);
1584 new_backquote_output
--;
1586 else if (print_quoted
&& CONSP (XCDR (obj
)) && NILP (XCDR (XCDR (obj
)))
1587 && new_backquote_output
1588 && (EQ (XCAR (obj
), Qcomma
)
1589 || EQ (XCAR (obj
), Qcomma_at
)
1590 || EQ (XCAR (obj
), Qcomma_dot
)))
1592 print_object (XCAR (obj
), printcharfun
, false);
1593 new_backquote_output
--;
1594 print_object (XCAR (XCDR (obj
)), printcharfun
, escapeflag
);
1595 new_backquote_output
++;
1599 printchar ('(', printcharfun
);
1601 Lisp_Object halftail
= obj
;
1603 /* Negative values of print-length are invalid in CL.
1604 Treat them like nil, as CMUCL does. */
1605 printmax_t print_length
= (NATNUMP (Vprint_length
)
1606 ? XFASTINT (Vprint_length
)
1607 : TYPE_MAXIMUM (printmax_t
));
1612 /* Detect circular list. */
1613 if (NILP (Vprint_circle
))
1615 /* Simple but incomplete way. */
1616 if (i
!= 0 && EQ (obj
, halftail
))
1618 int len
= sprintf (buf
, " . #%"pMd
, i
/ 2);
1619 strout (buf
, len
, len
, printcharfun
);
1625 /* With the print-circle feature. */
1628 Lisp_Object num
= Fgethash (obj
, Vprint_number_table
, Qnil
);
1631 print_c_string (" . ", printcharfun
);
1632 print_object (obj
, printcharfun
, escapeflag
);
1639 printchar (' ', printcharfun
);
1641 if (print_length
<= i
)
1643 print_c_string ("...", printcharfun
);
1648 print_object (XCAR (obj
), printcharfun
, escapeflag
);
1652 halftail
= XCDR (halftail
);
1655 /* OBJ non-nil here means it's the end of a dotted list. */
1658 print_c_string (" . ", printcharfun
);
1659 print_object (obj
, printcharfun
, escapeflag
);
1663 printchar (')', printcharfun
);
1667 case Lisp_Vectorlike
:
1672 print_c_string ("#<process ", printcharfun
);
1673 print_string (XPROCESS (obj
)->name
, printcharfun
);
1674 printchar ('>', printcharfun
);
1677 print_string (XPROCESS (obj
)->name
, printcharfun
);
1679 else if (BOOL_VECTOR_P (obj
))
1683 EMACS_INT size
= bool_vector_size (obj
);
1684 ptrdiff_t size_in_chars
= bool_vector_bytes (size
);
1685 ptrdiff_t real_size_in_chars
= size_in_chars
;
1687 int len
= sprintf (buf
, "#&%"pI
"d\"", size
);
1688 strout (buf
, len
, len
, printcharfun
);
1690 /* Don't print more characters than the specified maximum.
1691 Negative values of print-length are invalid. Treat them
1692 like a print-length of nil. */
1693 if (NATNUMP (Vprint_length
)
1694 && XFASTINT (Vprint_length
) < size_in_chars
)
1695 size_in_chars
= XFASTINT (Vprint_length
);
1697 for (i
= 0; i
< size_in_chars
; i
++)
1700 c
= bool_vector_uchar_data (obj
)[i
];
1701 if (c
== '\n' && print_escape_newlines
)
1702 print_c_string ("\\n", printcharfun
);
1703 else if (c
== '\f' && print_escape_newlines
)
1704 print_c_string ("\\f", printcharfun
);
1705 else if (c
> '\177')
1707 /* Use octal escapes to avoid encoding issues. */
1708 len
= sprintf (buf
, "\\%o", c
);
1709 strout (buf
, len
, len
, printcharfun
);
1713 if (c
== '\"' || c
== '\\')
1714 printchar ('\\', printcharfun
);
1715 printchar (c
, printcharfun
);
1719 if (size_in_chars
< real_size_in_chars
)
1720 print_c_string (" ...", printcharfun
);
1721 printchar ('\"', printcharfun
);
1723 else if (SUBRP (obj
))
1725 print_c_string ("#<subr ", printcharfun
);
1726 print_c_string (XSUBR (obj
)->symbol_name
, printcharfun
);
1727 printchar ('>', printcharfun
);
1729 else if (WINDOWP (obj
))
1731 int len
= sprintf (buf
, "#<window %"pI
"d",
1732 XWINDOW (obj
)->sequence_number
);
1733 strout (buf
, len
, len
, printcharfun
);
1734 if (BUFFERP (XWINDOW (obj
)->contents
))
1736 print_c_string (" on ", printcharfun
);
1737 print_string (BVAR (XBUFFER (XWINDOW (obj
)->contents
), name
),
1740 printchar ('>', printcharfun
);
1742 else if (TERMINALP (obj
))
1744 struct terminal
*t
= XTERMINAL (obj
);
1745 int len
= sprintf (buf
, "#<terminal %d", t
->id
);
1746 strout (buf
, len
, len
, printcharfun
);
1749 print_c_string (" on ", printcharfun
);
1750 print_c_string (t
->name
, printcharfun
);
1752 printchar ('>', printcharfun
);
1754 else if (HASH_TABLE_P (obj
))
1756 struct Lisp_Hash_Table
*h
= XHASH_TABLE (obj
);
1758 ptrdiff_t real_size
, size
;
1762 print_c_string ("#<hash-table", printcharfun
);
1763 if (SYMBOLP (h
->test
))
1765 print_c_string (" '", printcharfun
);
1766 print_c_string (SSDATA (SYMBOL_NAME (h
->test
)), printcharfun
);
1767 printchar (' ', printcharfun
);
1768 print_c_string (SSDATA (SYMBOL_NAME (h
->weak
)), printcharfun
);
1769 len
= sprintf (buf
, " %"pD
"d/%"pD
"d", h
->count
, ASIZE (h
->next
));
1770 strout (buf
, len
, len
, printcharfun
);
1772 len
= sprintf (buf
, " %p>", ptr
);
1773 strout (buf
, len
, len
, printcharfun
);
1775 /* Implement a readable output, e.g.:
1776 #s(hash-table size 2 test equal data (k1 v1 k2 v2)) */
1777 /* Always print the size. */
1778 len
= sprintf (buf
, "#s(hash-table size %"pD
"d", ASIZE (h
->next
));
1779 strout (buf
, len
, len
, printcharfun
);
1781 if (!NILP (h
->test
.name
))
1783 print_c_string (" test ", printcharfun
);
1784 print_object (h
->test
.name
, printcharfun
, escapeflag
);
1787 if (!NILP (h
->weak
))
1789 print_c_string (" weakness ", printcharfun
);
1790 print_object (h
->weak
, printcharfun
, escapeflag
);
1793 if (!NILP (h
->rehash_size
))
1795 print_c_string (" rehash-size ", printcharfun
);
1796 print_object (h
->rehash_size
, printcharfun
, escapeflag
);
1799 if (!NILP (h
->rehash_threshold
))
1801 print_c_string (" rehash-threshold ", printcharfun
);
1802 print_object (h
->rehash_threshold
, printcharfun
, escapeflag
);
1805 print_c_string (" data ", printcharfun
);
1807 /* Print the data here as a plist. */
1808 real_size
= HASH_TABLE_SIZE (h
);
1811 /* Don't print more elements than the specified maximum. */
1812 if (NATNUMP (Vprint_length
)
1813 && XFASTINT (Vprint_length
) < size
)
1814 size
= XFASTINT (Vprint_length
);
1816 printchar ('(', printcharfun
);
1817 for (i
= 0; i
< size
; i
++)
1818 if (!NILP (HASH_HASH (h
, i
)))
1820 if (i
) printchar (' ', printcharfun
);
1821 print_object (HASH_KEY (h
, i
), printcharfun
, escapeflag
);
1822 printchar (' ', printcharfun
);
1823 print_object (HASH_VALUE (h
, i
), printcharfun
, escapeflag
);
1826 if (size
< real_size
)
1827 print_c_string (" ...", printcharfun
);
1829 print_c_string ("))", printcharfun
);
1832 else if (BUFFERP (obj
))
1834 if (!BUFFER_LIVE_P (XBUFFER (obj
)))
1835 print_c_string ("#<killed buffer>", printcharfun
);
1836 else if (escapeflag
)
1838 print_c_string ("#<buffer ", printcharfun
);
1839 print_string (BVAR (XBUFFER (obj
), name
), printcharfun
);
1840 printchar ('>', printcharfun
);
1843 print_string (BVAR (XBUFFER (obj
), name
), printcharfun
);
1845 else if (WINDOW_CONFIGURATIONP (obj
))
1846 print_c_string ("#<window-configuration>", printcharfun
);
1847 else if (FRAMEP (obj
))
1850 void *ptr
= XFRAME (obj
);
1851 Lisp_Object frame_name
= XFRAME (obj
)->name
;
1853 print_c_string ((FRAME_LIVE_P (XFRAME (obj
))
1857 if (!STRINGP (frame_name
))
1859 /* A frame could be too young and have no name yet;
1861 if (SYMBOLP (frame_name
))
1862 frame_name
= Fsymbol_name (frame_name
);
1863 else /* can't happen: name should be either nil or string */
1864 frame_name
= build_string ("*INVALID*FRAME*NAME*");
1866 print_string (frame_name
, printcharfun
);
1867 len
= sprintf (buf
, " %p>", ptr
);
1868 strout (buf
, len
, len
, printcharfun
);
1870 else if (FONTP (obj
))
1874 if (! FONT_OBJECT_P (obj
))
1876 if (FONT_SPEC_P (obj
))
1877 print_c_string ("#<font-spec", printcharfun
);
1879 print_c_string ("#<font-entity", printcharfun
);
1880 for (i
= 0; i
< FONT_SPEC_MAX
; i
++)
1882 printchar (' ', printcharfun
);
1883 if (i
< FONT_WEIGHT_INDEX
|| i
> FONT_WIDTH_INDEX
)
1884 print_object (AREF (obj
, i
), printcharfun
, escapeflag
);
1886 print_object (font_style_symbolic (obj
, i
, 0),
1887 printcharfun
, escapeflag
);
1892 print_c_string ("#<font-object ", printcharfun
);
1893 print_object (AREF (obj
, FONT_NAME_INDEX
), printcharfun
,
1896 printchar ('>', printcharfun
);
1900 ptrdiff_t size
= ASIZE (obj
);
1901 if (COMPILEDP (obj
))
1903 printchar ('#', printcharfun
);
1904 size
&= PSEUDOVECTOR_SIZE_MASK
;
1906 if (CHAR_TABLE_P (obj
) || SUB_CHAR_TABLE_P (obj
))
1908 /* We print a char-table as if it were a vector,
1909 lumping the parent and default slots in with the
1910 character slots. But we add #^ as a prefix. */
1912 /* Make each lowest sub_char_table start a new line.
1913 Otherwise we'll make a line extremely long, which
1914 results in slow redisplay. */
1915 if (SUB_CHAR_TABLE_P (obj
)
1916 && XSUB_CHAR_TABLE (obj
)->depth
== 3)
1917 printchar ('\n', printcharfun
);
1918 print_c_string ("#^", printcharfun
);
1919 if (SUB_CHAR_TABLE_P (obj
))
1920 printchar ('^', printcharfun
);
1921 size
&= PSEUDOVECTOR_SIZE_MASK
;
1923 if (size
& PSEUDOVECTOR_FLAG
)
1926 printchar ('[', printcharfun
);
1928 int i
, idx
= SUB_CHAR_TABLE_P (obj
) ? SUB_CHAR_TABLE_OFFSET
: 0;
1930 ptrdiff_t real_size
= size
;
1932 /* For a sub char-table, print heading non-Lisp data first. */
1933 if (SUB_CHAR_TABLE_P (obj
))
1935 i
= sprintf (buf
, "%d %d", XSUB_CHAR_TABLE (obj
)->depth
,
1936 XSUB_CHAR_TABLE (obj
)->min_char
);
1937 strout (buf
, i
, i
, printcharfun
);
1940 /* Don't print more elements than the specified maximum. */
1941 if (NATNUMP (Vprint_length
)
1942 && XFASTINT (Vprint_length
) < size
)
1943 size
= XFASTINT (Vprint_length
);
1945 for (i
= idx
; i
< size
; i
++)
1947 if (i
) printchar (' ', printcharfun
);
1948 tem
= AREF (obj
, i
);
1949 print_object (tem
, printcharfun
, escapeflag
);
1951 if (size
< real_size
)
1952 print_c_string (" ...", printcharfun
);
1954 printchar (']', printcharfun
);
1959 switch (XMISCTYPE (obj
))
1961 case Lisp_Misc_Marker
:
1962 print_c_string ("#<marker ", printcharfun
);
1963 /* Do you think this is necessary? */
1964 if (XMARKER (obj
)->insertion_type
!= 0)
1965 print_c_string ("(moves after insertion) ", printcharfun
);
1966 if (! XMARKER (obj
)->buffer
)
1967 print_c_string ("in no buffer", printcharfun
);
1970 int len
= sprintf (buf
, "at %"pD
"d in ", marker_position (obj
));
1971 strout (buf
, len
, len
, printcharfun
);
1972 print_string (BVAR (XMARKER (obj
)->buffer
, name
), printcharfun
);
1974 printchar ('>', printcharfun
);
1977 case Lisp_Misc_Overlay
:
1978 print_c_string ("#<overlay ", printcharfun
);
1979 if (! XMARKER (OVERLAY_START (obj
))->buffer
)
1980 print_c_string ("in no buffer", printcharfun
);
1983 int len
= sprintf (buf
, "from %"pD
"d to %"pD
"d in ",
1984 marker_position (OVERLAY_START (obj
)),
1985 marker_position (OVERLAY_END (obj
)));
1986 strout (buf
, len
, len
, printcharfun
);
1987 print_string (BVAR (XMARKER (OVERLAY_START (obj
))->buffer
, name
),
1990 printchar ('>', printcharfun
);
1994 case Lisp_Misc_User_Ptr
:
1996 print_c_string ("#<user-ptr ", printcharfun
);
1997 int i
= sprintf (buf
, "ptr=%p finalizer=%p",
1999 XUSER_PTR (obj
)->finalizer
);
2000 strout (buf
, i
, i
, printcharfun
);
2001 printchar ('>', printcharfun
);
2006 case Lisp_Misc_Finalizer
:
2007 print_c_string ("#<finalizer", printcharfun
);
2008 if (NILP (XFINALIZER (obj
)->function
))
2009 print_c_string (" used", printcharfun
);
2010 printchar ('>', printcharfun
);
2013 /* Remaining cases shouldn't happen in normal usage, but let's
2014 print them anyway for the benefit of the debugger. */
2016 case Lisp_Misc_Free
:
2017 print_c_string ("#<misc free cell>", printcharfun
);
2020 case Lisp_Misc_Save_Value
:
2023 struct Lisp_Save_Value
*v
= XSAVE_VALUE (obj
);
2025 print_c_string ("#<save-value ", printcharfun
);
2027 if (v
->save_type
== SAVE_TYPE_MEMORY
)
2029 ptrdiff_t amount
= v
->data
[1].integer
;
2031 /* valid_lisp_object_p is reliable, so try to print up
2032 to 8 saved objects. This code is rarely used, so
2033 it's OK that valid_lisp_object_p is slow. */
2035 int limit
= min (amount
, 8);
2036 Lisp_Object
*area
= v
->data
[0].pointer
;
2038 i
= sprintf (buf
, "with %"pD
"d objects", amount
);
2039 strout (buf
, i
, i
, printcharfun
);
2041 for (i
= 0; i
< limit
; i
++)
2043 Lisp_Object maybe
= area
[i
];
2044 int valid
= valid_lisp_object_p (maybe
);
2046 printchar (' ', printcharfun
);
2048 print_object (maybe
, printcharfun
, escapeflag
);
2050 print_c_string (valid
< 0 ? "<some>" : "<invalid>",
2053 if (i
== limit
&& i
< amount
)
2054 print_c_string (" ...", printcharfun
);
2058 /* Print each slot according to its type. */
2060 for (index
= 0; index
< SAVE_VALUE_SLOTS
; index
++)
2063 printchar (' ', printcharfun
);
2065 switch (save_type (v
, index
))
2068 i
= sprintf (buf
, "<unused>");
2072 i
= sprintf (buf
, "<pointer %p>",
2073 v
->data
[index
].pointer
);
2076 case SAVE_FUNCPOINTER
:
2077 i
= sprintf (buf
, "<funcpointer %p>",
2078 ((void *) (intptr_t)
2079 v
->data
[index
].funcpointer
));
2083 i
= sprintf (buf
, "<integer %"pD
"d>",
2084 v
->data
[index
].integer
);
2088 print_object (v
->data
[index
].object
, printcharfun
,
2096 strout (buf
, i
, i
, printcharfun
);
2099 printchar ('>', printcharfun
);
2112 /* We're in trouble if this happens!
2113 Probably should just emacs_abort (). */
2114 print_c_string ("#<EMACS BUG: INVALID DATATYPE ", printcharfun
);
2116 len
= sprintf (buf
, "(MISC 0x%04x)", (unsigned) XMISCTYPE (obj
));
2117 else if (VECTORLIKEP (obj
))
2118 len
= sprintf (buf
, "(PVEC 0x%08zx)", (size_t) ASIZE (obj
));
2120 len
= sprintf (buf
, "(0x%02x)", (unsigned) XTYPE (obj
));
2121 strout (buf
, len
, len
, printcharfun
);
2122 print_c_string ((" Save your buffers immediately"
2123 " and please report this bug>"),
2132 /* Print a description of INTERVAL using PRINTCHARFUN.
2133 This is part of printing a string that has text properties. */
2136 print_interval (INTERVAL interval
, Lisp_Object printcharfun
)
2138 if (NILP (interval
->plist
))
2140 printchar (' ', printcharfun
);
2141 print_object (make_number (interval
->position
), printcharfun
, 1);
2142 printchar (' ', printcharfun
);
2143 print_object (make_number (interval
->position
+ LENGTH (interval
)),
2145 printchar (' ', printcharfun
);
2146 print_object (interval
->plist
, printcharfun
, 1);
2149 /* Initialize debug_print stuff early to have it working from the very
2153 init_print_once (void)
2155 /* The subroutine object for external-debugging-output is kept here
2156 for the convenience of the debugger. */
2157 DEFSYM (Qexternal_debugging_output
, "external-debugging-output");
2159 defsubr (&Sexternal_debugging_output
);
2163 syms_of_print (void)
2165 DEFSYM (Qtemp_buffer_setup_hook
, "temp-buffer-setup-hook");
2167 DEFVAR_LISP ("standard-output", Vstandard_output
,
2168 doc
: /* Output stream `print' uses by default for outputting a character.
2169 This may be any function of one argument.
2170 It may also be a buffer (output is inserted before point)
2171 or a marker (output is inserted and the marker is advanced)
2172 or the symbol t (output appears in the echo area). */);
2173 Vstandard_output
= Qt
;
2174 DEFSYM (Qstandard_output
, "standard-output");
2176 DEFVAR_LISP ("float-output-format", Vfloat_output_format
,
2177 doc
: /* The format descriptor string used to print floats.
2178 This is a %-spec like those accepted by `printf' in C,
2179 but with some restrictions. It must start with the two characters `%.'.
2180 After that comes an integer precision specification,
2181 and then a letter which controls the format.
2182 The letters allowed are `e', `f' and `g'.
2183 Use `e' for exponential notation \"DIG.DIGITSeEXPT\"
2184 Use `f' for decimal point notation \"DIGITS.DIGITS\".
2185 Use `g' to choose the shorter of those two formats for the number at hand.
2186 The precision in any of these cases is the number of digits following
2187 the decimal point. With `f', a precision of 0 means to omit the
2188 decimal point. 0 is not allowed with `e' or `g'.
2190 A value of nil means to use the shortest notation
2191 that represents the number without losing information. */);
2192 Vfloat_output_format
= Qnil
;
2194 DEFVAR_LISP ("print-length", Vprint_length
,
2195 doc
: /* Maximum length of list to print before abbreviating.
2196 A value of nil means no limit. See also `eval-expression-print-length'. */);
2197 Vprint_length
= Qnil
;
2199 DEFVAR_LISP ("print-level", Vprint_level
,
2200 doc
: /* Maximum depth of list nesting to print before abbreviating.
2201 A value of nil means no limit. See also `eval-expression-print-level'. */);
2202 Vprint_level
= Qnil
;
2204 DEFVAR_BOOL ("print-escape-newlines", print_escape_newlines
,
2205 doc
: /* Non-nil means print newlines in strings as `\\n'.
2206 Also print formfeeds as `\\f'. */);
2207 print_escape_newlines
= 0;
2209 DEFVAR_BOOL ("print-escape-nonascii", print_escape_nonascii
,
2210 doc
: /* Non-nil means print unibyte non-ASCII chars in strings as \\OOO.
2211 (OOO is the octal representation of the character code.)
2212 Only single-byte characters are affected, and only in `prin1'.
2213 When the output goes in a multibyte buffer, this feature is
2214 enabled regardless of the value of the variable. */);
2215 print_escape_nonascii
= 0;
2217 DEFVAR_BOOL ("print-escape-multibyte", print_escape_multibyte
,
2218 doc
: /* Non-nil means print multibyte characters in strings as \\xXXXX.
2219 (XXXX is the hex representation of the character code.)
2220 This affects only `prin1'. */);
2221 print_escape_multibyte
= 0;
2223 DEFVAR_BOOL ("print-quoted", print_quoted
,
2224 doc
: /* Non-nil means print quoted forms with reader syntax.
2225 I.e., (quote foo) prints as \\='foo, (function foo) as #\\='foo. */);
2228 DEFVAR_LISP ("print-gensym", Vprint_gensym
,
2229 doc
: /* Non-nil means print uninterned symbols so they will read as uninterned.
2230 I.e., the value of (make-symbol \"foobar\") prints as #:foobar.
2231 When the uninterned symbol appears within a recursive data structure,
2232 and the symbol appears more than once, in addition use the #N# and #N=
2233 constructs as needed, so that multiple references to the same symbol are
2234 shared once again when the text is read back. */);
2235 Vprint_gensym
= Qnil
;
2237 DEFVAR_LISP ("print-circle", Vprint_circle
,
2238 doc
: /* Non-nil means print recursive structures using #N= and #N# syntax.
2239 If nil, printing proceeds recursively and may lead to
2240 `max-lisp-eval-depth' being exceeded or an error may occur:
2241 \"Apparently circular structure being printed.\" Also see
2242 `print-length' and `print-level'.
2243 If non-nil, shared substructures anywhere in the structure are printed
2244 with `#N=' before the first occurrence (in the order of the print
2245 representation) and `#N#' in place of each subsequent occurrence,
2246 where N is a positive decimal integer. */);
2247 Vprint_circle
= Qnil
;
2249 DEFVAR_LISP ("print-continuous-numbering", Vprint_continuous_numbering
,
2250 doc
: /* Non-nil means number continuously across print calls.
2251 This affects the numbers printed for #N= labels and #M# references.
2252 See also `print-circle', `print-gensym', and `print-number-table'.
2253 This variable should not be set with `setq'; bind it with a `let' instead. */);
2254 Vprint_continuous_numbering
= Qnil
;
2256 DEFVAR_LISP ("print-number-table", Vprint_number_table
,
2257 doc
: /* A vector used internally to produce `#N=' labels and `#N#' references.
2258 The Lisp printer uses this vector to detect Lisp objects referenced more
2261 When you bind `print-continuous-numbering' to t, you should probably
2262 also bind `print-number-table' to nil. This ensures that the value of
2263 `print-number-table' can be garbage-collected once the printing is
2264 done. If all elements of `print-number-table' are nil, it means that
2265 the printing done so far has not found any shared structure or objects
2266 that need to be recorded in the table. */);
2267 Vprint_number_table
= Qnil
;
2269 DEFVAR_LISP ("print-charset-text-property", Vprint_charset_text_property
,
2270 doc
: /* A flag to control printing of `charset' text property on printing a string.
2271 The value must be nil, t, or `default'.
2273 If the value is nil, don't print the text property `charset'.
2275 If the value is t, always print the text property `charset'.
2277 If the value is `default', print the text property `charset' only when
2278 the value is different from what is guessed in the current charset
2280 Vprint_charset_text_property
= Qdefault
;
2282 /* prin1_to_string_buffer initialized in init_buffer_once in buffer.c */
2283 staticpro (&Vprin1_to_string_buffer
);
2286 defsubr (&Sprin1_to_string
);
2287 defsubr (&Serror_message_string
);
2291 defsubr (&Swrite_char
);
2292 #ifdef WITH_REDIRECT_DEBUGGING_OUTPUT
2293 defsubr (&Sredirect_debugging_output
);
2296 DEFSYM (Qprint_escape_newlines
, "print-escape-newlines");
2297 DEFSYM (Qprint_escape_multibyte
, "print-escape-multibyte");
2298 DEFSYM (Qprint_escape_nonascii
, "print-escape-nonascii");
2300 print_prune_charset_plist
= Qnil
;
2301 staticpro (&print_prune_charset_plist
);