Commit | Line | Data |
---|---|---|
38010d50 | 1 | /* Lisp object printing and output streams. |
9dffd511 RS |
2 | Copyright (C) 1985, 86, 88, 93, 94, 95, 97, 1998 |
3 | Free Software Foundation, Inc. | |
38010d50 JB |
4 | |
5 | This file is part of GNU Emacs. | |
6 | ||
7 | GNU Emacs is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
4746118a | 9 | the Free Software Foundation; either version 2, or (at your option) |
38010d50 JB |
10 | any later version. |
11 | ||
12 | GNU Emacs is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GNU Emacs; see the file COPYING. If not, write to | |
3b7ad313 EN |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
38010d50 JB |
21 | |
22 | ||
18160b98 | 23 | #include <config.h> |
38010d50 | 24 | #include <stdio.h> |
38010d50 JB |
25 | #include "lisp.h" |
26 | ||
27 | #ifndef standalone | |
28 | #include "buffer.h" | |
087e3c46 | 29 | #include "charset.h" |
0137dbf7 | 30 | #include "frame.h" |
38010d50 JB |
31 | #include "window.h" |
32 | #include "process.h" | |
33 | #include "dispextern.h" | |
34 | #include "termchar.h" | |
077d751f | 35 | #include "keyboard.h" |
38010d50 JB |
36 | #endif /* not standalone */ |
37 | ||
7651e1f5 RS |
38 | #ifdef USE_TEXT_PROPERTIES |
39 | #include "intervals.h" | |
40 | #endif | |
41 | ||
38010d50 JB |
42 | Lisp_Object Vstandard_output, Qstandard_output; |
43 | ||
d9c21094 RS |
44 | Lisp_Object Qtemp_buffer_setup_hook; |
45 | ||
2f100b5c EN |
46 | /* These are used to print like we read. */ |
47 | extern Lisp_Object Qbackquote, Qcomma, Qcomma_at, Qcomma_dot, Qfunction; | |
48 | ||
38010d50 JB |
49 | #ifdef LISP_FLOAT_TYPE |
50 | Lisp_Object Vfloat_output_format, Qfloat_output_format; | |
f356c3fb PE |
51 | |
52 | /* Work around a problem that happens because math.h on hpux 7 | |
53 | defines two static variables--which, in Emacs, are not really static, | |
54 | because `static' is defined as nothing. The problem is that they are | |
55 | defined both here and in lread.c. | |
56 | These macros prevent the name conflict. */ | |
57 | #if defined (HPUX) && !defined (HPUX8) | |
58 | #define _MAXLDBL print_maxldbl | |
59 | #define _NMAXLDBL print_nmaxldbl | |
60 | #endif | |
61 | ||
62 | #include <math.h> | |
63 | ||
64 | #if STDC_HEADERS | |
65 | #include <float.h> | |
66 | #include <stdlib.h> | |
67 | #endif | |
68 | ||
69 | /* Default to values appropriate for IEEE floating point. */ | |
70 | #ifndef FLT_RADIX | |
71 | #define FLT_RADIX 2 | |
72 | #endif | |
73 | #ifndef DBL_MANT_DIG | |
74 | #define DBL_MANT_DIG 53 | |
75 | #endif | |
76 | #ifndef DBL_DIG | |
77 | #define DBL_DIG 15 | |
78 | #endif | |
b0a1044b PE |
79 | #ifndef DBL_MIN |
80 | #define DBL_MIN 2.2250738585072014e-308 | |
81 | #endif | |
82 | ||
83 | #ifdef DBL_MIN_REPLACEMENT | |
84 | #undef DBL_MIN | |
85 | #define DBL_MIN DBL_MIN_REPLACEMENT | |
86 | #endif | |
f356c3fb PE |
87 | |
88 | /* Define DOUBLE_DIGITS_BOUND, an upper bound on the number of decimal digits | |
89 | needed to express a float without losing information. | |
90 | The general-case formula is valid for the usual case, IEEE floating point, | |
91 | but many compilers can't optimize the formula to an integer constant, | |
92 | so make a special case for it. */ | |
93 | #if FLT_RADIX == 2 && DBL_MANT_DIG == 53 | |
94 | #define DOUBLE_DIGITS_BOUND 17 /* IEEE floating point */ | |
95 | #else | |
96 | #define DOUBLE_DIGITS_BOUND ((int) ceil (log10 (pow (FLT_RADIX, DBL_MANT_DIG)))) | |
97 | #endif | |
98 | ||
38010d50 JB |
99 | #endif /* LISP_FLOAT_TYPE */ |
100 | ||
101 | /* Avoid actual stack overflow in print. */ | |
102 | int print_depth; | |
103 | ||
ec838c39 RS |
104 | /* Detect most circularities to print finite output. */ |
105 | #define PRINT_CIRCLE 200 | |
106 | Lisp_Object being_printed[PRINT_CIRCLE]; | |
107 | ||
6fec5601 RS |
108 | /* When printing into a buffer, first we put the text in this |
109 | block, then insert it all at once. */ | |
110 | char *print_buffer; | |
111 | ||
112 | /* Size allocated in print_buffer. */ | |
113 | int print_buffer_size; | |
dc2a0b79 | 114 | /* Chars stored in print_buffer. */ |
6fec5601 | 115 | int print_buffer_pos; |
dc2a0b79 RS |
116 | /* Bytes stored in print_buffer. */ |
117 | int print_buffer_pos_byte; | |
6fec5601 | 118 | |
38010d50 JB |
119 | /* Maximum length of list to print in full; noninteger means |
120 | effectively infinity */ | |
121 | ||
122 | Lisp_Object Vprint_length; | |
123 | ||
124 | /* Maximum depth of list to print in full; noninteger means | |
125 | effectively infinity. */ | |
126 | ||
127 | Lisp_Object Vprint_level; | |
128 | ||
129 | /* Nonzero means print newlines in strings as \n. */ | |
130 | ||
131 | int print_escape_newlines; | |
132 | ||
38940e93 RS |
133 | /* Nonzero means to print single-byte non-ascii characters in strings as |
134 | octal escapes. */ | |
135 | ||
136 | int print_escape_nonascii; | |
137 | ||
835d0be6 RS |
138 | /* Nonzero means to print multibyte characters in strings as hex escapes. */ |
139 | ||
140 | int print_escape_multibyte; | |
141 | ||
142 | Lisp_Object Qprint_escape_newlines; | |
143 | Lisp_Object Qprint_escape_multibyte, Qprint_escape_nonascii; | |
144 | ||
2f100b5c EN |
145 | /* Nonzero means print (quote foo) forms as 'foo, etc. */ |
146 | ||
147 | int print_quoted; | |
148 | ||
e0f69431 RS |
149 | /* Non-nil means print #: before uninterned symbols. |
150 | Neither t nor nil means so that and don't clear Vprint_gensym_alist | |
151 | on entry to and exit from print functions. */ | |
081e0581 | 152 | |
e0f69431 | 153 | Lisp_Object Vprint_gensym; |
081e0581 EN |
154 | |
155 | /* Association list of certain objects that are `eq' in the form being | |
156 | printed and which should be `eq' when read back in, using the #n=object | |
157 | and #n# reader forms. Each element has the form (object . n). */ | |
158 | ||
e0f69431 | 159 | Lisp_Object Vprint_gensym_alist; |
2f100b5c | 160 | |
5259c737 | 161 | /* Nonzero means print newline to stdout before next minibuffer message. |
38010d50 JB |
162 | Defined in xdisp.c */ |
163 | ||
164 | extern int noninteractive_need_newline; | |
5259c737 | 165 | |
aec2b95b RS |
166 | extern int minibuffer_auto_raise; |
167 | ||
38010d50 JB |
168 | #ifdef MAX_PRINT_CHARS |
169 | static int print_chars; | |
170 | static int max_print; | |
171 | #endif /* MAX_PRINT_CHARS */ | |
7651e1f5 RS |
172 | |
173 | void print_interval (); | |
38010d50 JB |
174 | \f |
175 | #if 0 | |
176 | /* Convert between chars and GLYPHs */ | |
177 | ||
178 | int | |
179 | glyphlen (glyphs) | |
180 | register GLYPH *glyphs; | |
181 | { | |
182 | register int i = 0; | |
183 | ||
184 | while (glyphs[i]) | |
185 | i++; | |
186 | return i; | |
187 | } | |
188 | ||
189 | void | |
190 | str_to_glyph_cpy (str, glyphs) | |
191 | char *str; | |
192 | GLYPH *glyphs; | |
193 | { | |
194 | register GLYPH *gp = glyphs; | |
195 | register char *cp = str; | |
196 | ||
197 | while (*cp) | |
198 | *gp++ = *cp++; | |
199 | } | |
200 | ||
201 | void | |
202 | str_to_glyph_ncpy (str, glyphs, n) | |
203 | char *str; | |
204 | GLYPH *glyphs; | |
205 | register int n; | |
206 | { | |
207 | register GLYPH *gp = glyphs; | |
208 | register char *cp = str; | |
209 | ||
210 | while (n-- > 0) | |
211 | *gp++ = *cp++; | |
212 | } | |
213 | ||
214 | void | |
215 | glyph_to_str_cpy (glyphs, str) | |
216 | GLYPH *glyphs; | |
217 | char *str; | |
218 | { | |
219 | register GLYPH *gp = glyphs; | |
220 | register char *cp = str; | |
221 | ||
222 | while (*gp) | |
223 | *str++ = *gp++ & 0377; | |
224 | } | |
225 | #endif | |
226 | \f | |
eb8c3be9 | 227 | /* Low level output routines for characters and strings */ |
38010d50 JB |
228 | |
229 | /* Lisp functions to do output using a stream | |
081e0581 EN |
230 | must have the stream in a variable called printcharfun |
231 | and must start with PRINTPREPARE, end with PRINTFINISH, | |
232 | and use PRINTDECLARE to declare common variables. | |
233 | Use PRINTCHAR to output one character, | |
234 | or call strout to output a block of characters. | |
38010d50 JB |
235 | */ |
236 | ||
081e0581 EN |
237 | #define PRINTDECLARE \ |
238 | struct buffer *old = current_buffer; \ | |
239 | int old_point = -1, start_point; \ | |
6ddd6eee | 240 | int old_point_byte, start_point_byte; \ |
08e8d297 RS |
241 | int specpdl_count = specpdl_ptr - specpdl; \ |
242 | int free_print_buffer = 0; \ | |
081e0581 EN |
243 | Lisp_Object original |
244 | ||
cdaa87fd RS |
245 | #define PRINTPREPARE \ |
246 | original = printcharfun; \ | |
247 | if (NILP (printcharfun)) printcharfun = Qt; \ | |
d4ae1f7e | 248 | if (BUFFERP (printcharfun)) \ |
08e8d297 RS |
249 | { \ |
250 | if (XBUFFER (printcharfun) != current_buffer) \ | |
cdaa87fd | 251 | Fset_buffer (printcharfun); \ |
08e8d297 RS |
252 | printcharfun = Qnil; \ |
253 | } \ | |
d4ae1f7e | 254 | if (MARKERP (printcharfun)) \ |
08e8d297 RS |
255 | { \ |
256 | if (!(XMARKER (original)->buffer)) \ | |
cdaa87fd RS |
257 | error ("Marker does not point anywhere"); \ |
258 | if (XMARKER (original)->buffer != current_buffer) \ | |
259 | set_buffer_internal (XMARKER (original)->buffer); \ | |
6ec8bbd2 | 260 | old_point = PT; \ |
6ddd6eee RS |
261 | old_point_byte = PT_BYTE; \ |
262 | SET_PT_BOTH (marker_position (printcharfun), \ | |
263 | marker_byte_position (printcharfun)); \ | |
6ec8bbd2 | 264 | start_point = PT; \ |
6ddd6eee | 265 | start_point_byte = PT_BYTE; \ |
08e8d297 RS |
266 | printcharfun = Qnil; \ |
267 | } \ | |
6fec5601 RS |
268 | if (NILP (printcharfun)) \ |
269 | { \ | |
dc2a0b79 | 270 | Lisp_Object string; \ |
835d0be6 RS |
271 | if (NILP (current_buffer->enable_multibyte_characters) \ |
272 | && ! print_escape_multibyte) \ | |
273 | specbind (Qprint_escape_multibyte, Qt); \ | |
274 | if (! NILP (current_buffer->enable_multibyte_characters) \ | |
275 | && ! print_escape_nonascii) \ | |
276 | specbind (Qprint_escape_nonascii, Qt); \ | |
08e8d297 | 277 | if (print_buffer != 0) \ |
dc2a0b79 | 278 | { \ |
9dffd511 RS |
279 | string = make_string_from_bytes (print_buffer, \ |
280 | print_buffer_pos, \ | |
281 | print_buffer_pos_byte); \ | |
dc2a0b79 RS |
282 | record_unwind_protect (print_unwind, string); \ |
283 | } \ | |
08e8d297 RS |
284 | else \ |
285 | { \ | |
286 | print_buffer_size = 1000; \ | |
287 | print_buffer = (char *) xmalloc (print_buffer_size); \ | |
b3da2c73 | 288 | free_print_buffer = 1; \ |
08e8d297 | 289 | } \ |
6fec5601 | 290 | print_buffer_pos = 0; \ |
dc2a0b79 | 291 | print_buffer_pos_byte = 0; \ |
6fec5601 | 292 | } \ |
e0f69431 RS |
293 | if (!CONSP (Vprint_gensym)) \ |
294 | Vprint_gensym_alist = Qnil | |
38010d50 | 295 | |
8a2ab0c6 RS |
296 | #define PRINTFINISH \ |
297 | if (NILP (printcharfun)) \ | |
298 | { \ | |
299 | if (print_buffer_pos != print_buffer_pos_byte \ | |
300 | && NILP (current_buffer->enable_multibyte_characters)) \ | |
301 | { \ | |
302 | unsigned char *temp \ | |
303 | = (unsigned char *) alloca (print_buffer_pos + 1); \ | |
304 | copy_text (print_buffer, temp, print_buffer_pos_byte, \ | |
305 | 1, 0); \ | |
306 | insert_1_both (temp, print_buffer_pos, \ | |
307 | print_buffer_pos, 0, 1, 0); \ | |
308 | } \ | |
309 | else \ | |
310 | insert_1_both (print_buffer, print_buffer_pos, \ | |
311 | print_buffer_pos_byte, 0, 1, 0); \ | |
312 | } \ | |
313 | if (free_print_buffer) \ | |
314 | { \ | |
315 | xfree (print_buffer); \ | |
316 | print_buffer = 0; \ | |
317 | } \ | |
318 | unbind_to (specpdl_count, Qnil); \ | |
319 | if (MARKERP (original)) \ | |
320 | set_marker_both (original, Qnil, PT, PT_BYTE); \ | |
321 | if (old_point >= 0) \ | |
322 | SET_PT_BOTH (old_point + (old_point >= start_point \ | |
323 | ? PT - start_point : 0), \ | |
6ddd6eee RS |
324 | old_point_byte + (old_point_byte >= start_point_byte \ |
325 | ? PT_BYTE - start_point_byte : 0)); \ | |
8a2ab0c6 RS |
326 | if (old != current_buffer) \ |
327 | set_buffer_internal (old); \ | |
328 | if (!CONSP (Vprint_gensym)) \ | |
e0f69431 | 329 | Vprint_gensym_alist = Qnil |
38010d50 JB |
330 | |
331 | #define PRINTCHAR(ch) printchar (ch, printcharfun) | |
332 | ||
09eddb56 RS |
333 | /* Nonzero if there is no room to print any more characters |
334 | so print might as well return right away. */ | |
335 | ||
336 | #define PRINTFULLP() \ | |
337 | (EQ (printcharfun, Qt) && !noninteractive \ | |
338 | && printbufidx >= FRAME_WIDTH (XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))))) | |
339 | ||
08e8d297 RS |
340 | /* This is used to restore the saved contents of print_buffer |
341 | when there is a recursive call to print. */ | |
342 | static Lisp_Object | |
343 | print_unwind (saved_text) | |
344 | Lisp_Object saved_text; | |
345 | { | |
346 | bcopy (XSTRING (saved_text)->data, print_buffer, XSTRING (saved_text)->size); | |
347 | } | |
348 | ||
09eddb56 | 349 | /* Index of first unused element of FRAME_MESSAGE_BUF (mini_frame). */ |
38010d50 JB |
350 | static int printbufidx; |
351 | ||
352 | static void | |
353 | printchar (ch, fun) | |
087e3c46 | 354 | unsigned int ch; |
38010d50 JB |
355 | Lisp_Object fun; |
356 | { | |
357 | Lisp_Object ch1; | |
358 | ||
359 | #ifdef MAX_PRINT_CHARS | |
360 | if (max_print) | |
361 | print_chars++; | |
362 | #endif /* MAX_PRINT_CHARS */ | |
363 | #ifndef standalone | |
364 | if (EQ (fun, Qnil)) | |
365 | { | |
087e3c46 | 366 | int len; |
dc22f25e | 367 | unsigned char work[4], *str; |
087e3c46 | 368 | |
38010d50 | 369 | QUIT; |
087e3c46 | 370 | len = CHAR_STRING (ch, work, str); |
dc2a0b79 | 371 | if (print_buffer_pos_byte + len >= print_buffer_size) |
6fec5601 RS |
372 | print_buffer = (char *) xrealloc (print_buffer, |
373 | print_buffer_size *= 2); | |
dc2a0b79 RS |
374 | bcopy (str, print_buffer + print_buffer_pos_byte, len); |
375 | print_buffer_pos += 1; | |
376 | print_buffer_pos_byte += len; | |
38010d50 JB |
377 | return; |
378 | } | |
379 | ||
380 | if (EQ (fun, Qt)) | |
381 | { | |
c217b048 | 382 | FRAME_PTR mini_frame |
b8b1b8fd | 383 | = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); |
087e3c46 KH |
384 | unsigned char work[4], *str; |
385 | int len = CHAR_STRING (ch, work, str); | |
b8b1b8fd | 386 | |
09eddb56 RS |
387 | QUIT; |
388 | ||
38010d50 JB |
389 | if (noninteractive) |
390 | { | |
087e3c46 KH |
391 | while (len--) |
392 | putchar (*str), str++; | |
38010d50 JB |
393 | noninteractive_need_newline = 1; |
394 | return; | |
395 | } | |
396 | ||
b8b1b8fd | 397 | if (echo_area_glyphs != FRAME_MESSAGE_BUF (mini_frame) |
38010d50 JB |
398 | || !message_buf_print) |
399 | { | |
aee72e4f | 400 | message_log_maybe_newline (); |
b8b1b8fd | 401 | echo_area_glyphs = FRAME_MESSAGE_BUF (mini_frame); |
38010d50 | 402 | printbufidx = 0; |
708d172a | 403 | echo_area_glyphs_length = 0; |
38010d50 | 404 | message_buf_print = 1; |
aec2b95b RS |
405 | |
406 | if (minibuffer_auto_raise) | |
407 | { | |
408 | Lisp_Object mini_window; | |
409 | ||
410 | /* Get the frame containing the minibuffer | |
411 | that the selected frame is using. */ | |
412 | mini_window = FRAME_MINIBUF_WINDOW (selected_frame); | |
413 | ||
414 | Fraise_frame (WINDOW_FRAME (XWINDOW (mini_window))); | |
415 | } | |
38010d50 JB |
416 | } |
417 | ||
9a4d01d8 KH |
418 | if (len == 1 |
419 | && ! NILP (current_buffer->enable_multibyte_characters) | |
420 | && ! CHAR_HEAD_P (*str)) | |
421 | { | |
422 | /* Convert the unibyte character to multibyte. */ | |
423 | unsigned char c = *str; | |
424 | ||
425 | len = count_size_as_multibyte (&c, 1); | |
426 | copy_text (&c, work, 1, 0, 1); | |
427 | str = work; | |
428 | } | |
429 | ||
dc2a0b79 | 430 | message_dolog (str, len, 0, len > 1); |
1134b854 | 431 | |
1134b854 | 432 | if (! NILP (current_buffer->enable_multibyte_characters) |
9a4d01d8 | 433 | && ! message_enable_multibyte) |
1134b854 | 434 | { |
9a4d01d8 KH |
435 | /* Record that the message buffer is multibyte. */ |
436 | message_enable_multibyte = 1; | |
437 | ||
438 | /* If we have already had some message text in the messsage | |
439 | buffer, we convert it to multibyte. */ | |
440 | if (printbufidx > 0) | |
4ad8bb20 | 441 | { |
9a4d01d8 KH |
442 | int size |
443 | = count_size_as_multibyte (FRAME_MESSAGE_BUF (mini_frame), | |
444 | printbufidx); | |
445 | unsigned char *tembuf = (unsigned char *) alloca (size + 1); | |
446 | copy_text (FRAME_MESSAGE_BUF (mini_frame), tembuf, printbufidx, | |
447 | 0, 1); | |
448 | printbufidx = size; | |
449 | if (printbufidx > FRAME_MESSAGE_BUF_SIZE (mini_frame)) | |
450 | { | |
451 | printbufidx = FRAME_MESSAGE_BUF_SIZE (mini_frame); | |
452 | /* Rewind incomplete multi-byte form. */ | |
453 | while (printbufidx > 0 && tembuf[printbufidx] >= 0xA0) | |
454 | printbufidx--; | |
455 | } | |
456 | bcopy (tembuf, FRAME_MESSAGE_BUF (mini_frame), printbufidx); | |
4ad8bb20 | 457 | } |
1134b854 | 458 | } |
1134b854 | 459 | |
087e3c46 | 460 | if (printbufidx < FRAME_MESSAGE_BUF_SIZE (mini_frame) - len) |
d366d2e4 KH |
461 | { |
462 | bcopy (str, &FRAME_MESSAGE_BUF (mini_frame)[printbufidx], len); | |
463 | printbufidx += len; | |
464 | } | |
b8b1b8fd | 465 | FRAME_MESSAGE_BUF (mini_frame)[printbufidx] = 0; |
708d172a | 466 | echo_area_glyphs_length = printbufidx; |
38010d50 JB |
467 | |
468 | return; | |
469 | } | |
470 | #endif /* not standalone */ | |
471 | ||
b5d25c37 | 472 | XSETFASTINT (ch1, ch); |
38010d50 JB |
473 | call1 (fun, ch1); |
474 | } | |
475 | ||
476 | static void | |
dc2a0b79 | 477 | strout (ptr, size, size_byte, printcharfun, multibyte) |
38010d50 | 478 | char *ptr; |
dc2a0b79 | 479 | int size, size_byte; |
38010d50 | 480 | Lisp_Object printcharfun; |
dc2a0b79 | 481 | int multibyte; |
38010d50 JB |
482 | { |
483 | int i = 0; | |
484 | ||
087e3c46 | 485 | if (size < 0) |
dc2a0b79 | 486 | size_byte = size = strlen (ptr); |
087e3c46 | 487 | |
38010d50 JB |
488 | if (EQ (printcharfun, Qnil)) |
489 | { | |
dc2a0b79 | 490 | if (print_buffer_pos_byte + size_byte > print_buffer_size) |
6fec5601 | 491 | { |
dc2a0b79 | 492 | print_buffer_size = print_buffer_size * 2 + size_byte; |
6fec5601 RS |
493 | print_buffer = (char *) xrealloc (print_buffer, |
494 | print_buffer_size); | |
495 | } | |
dc2a0b79 | 496 | bcopy (ptr, print_buffer + print_buffer_pos_byte, size_byte); |
6fec5601 | 497 | print_buffer_pos += size; |
dc2a0b79 | 498 | print_buffer_pos_byte += size_byte; |
6fec5601 | 499 | |
38010d50 JB |
500 | #ifdef MAX_PRINT_CHARS |
501 | if (max_print) | |
6fec5601 | 502 | print_chars += size; |
38010d50 JB |
503 | #endif /* MAX_PRINT_CHARS */ |
504 | return; | |
505 | } | |
506 | if (EQ (printcharfun, Qt)) | |
507 | { | |
c217b048 | 508 | FRAME_PTR mini_frame |
b8b1b8fd RS |
509 | = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); |
510 | ||
09eddb56 RS |
511 | QUIT; |
512 | ||
38010d50 JB |
513 | #ifdef MAX_PRINT_CHARS |
514 | if (max_print) | |
087e3c46 | 515 | print_chars += size; |
38010d50 JB |
516 | #endif /* MAX_PRINT_CHARS */ |
517 | ||
518 | if (noninteractive) | |
519 | { | |
dc2a0b79 | 520 | fwrite (ptr, 1, size_byte, stdout); |
38010d50 JB |
521 | noninteractive_need_newline = 1; |
522 | return; | |
523 | } | |
524 | ||
b8b1b8fd | 525 | if (echo_area_glyphs != FRAME_MESSAGE_BUF (mini_frame) |
38010d50 JB |
526 | || !message_buf_print) |
527 | { | |
aee72e4f | 528 | message_log_maybe_newline (); |
b8b1b8fd | 529 | echo_area_glyphs = FRAME_MESSAGE_BUF (mini_frame); |
38010d50 | 530 | printbufidx = 0; |
708d172a | 531 | echo_area_glyphs_length = 0; |
38010d50 | 532 | message_buf_print = 1; |
aec2b95b RS |
533 | |
534 | if (minibuffer_auto_raise) | |
535 | { | |
536 | Lisp_Object mini_window; | |
537 | ||
538 | /* Get the frame containing the minibuffer | |
539 | that the selected frame is using. */ | |
540 | mini_window = FRAME_MINIBUF_WINDOW (selected_frame); | |
541 | ||
542 | Fraise_frame (WINDOW_FRAME (XWINDOW (mini_window))); | |
543 | } | |
38010d50 JB |
544 | } |
545 | ||
dc2a0b79 | 546 | message_dolog (ptr, size_byte, 0, multibyte); |
4ad8bb20 KH |
547 | |
548 | /* Convert message to multibyte if we are now adding multibyte text. */ | |
549 | if (multibyte | |
550 | && ! message_enable_multibyte | |
551 | && printbufidx > 0) | |
552 | { | |
553 | int size = count_size_as_multibyte (FRAME_MESSAGE_BUF (mini_frame), | |
554 | printbufidx); | |
555 | unsigned char *tembuf = (unsigned char *) alloca (size + 1); | |
556 | copy_text (FRAME_MESSAGE_BUF (mini_frame), tembuf, printbufidx, | |
557 | 0, 1); | |
558 | printbufidx = size; | |
559 | if (printbufidx > FRAME_MESSAGE_BUF_SIZE (mini_frame)) | |
560 | { | |
561 | printbufidx = FRAME_MESSAGE_BUF_SIZE (mini_frame); | |
562 | /* Rewind incomplete multi-byte form. */ | |
563 | while (printbufidx > 0 && tembuf[printbufidx] >= 0xA0) | |
564 | printbufidx--; | |
565 | } | |
566 | ||
567 | bcopy (tembuf, FRAME_MESSAGE_BUF (mini_frame), printbufidx); | |
4ad8bb20 KH |
568 | } |
569 | ||
799fdb04 KH |
570 | if (multibyte) |
571 | message_enable_multibyte = 1; | |
572 | ||
4ad8bb20 | 573 | /* Compute how much of the new text will fit there. */ |
dc2a0b79 | 574 | if (size_byte > FRAME_MESSAGE_BUF_SIZE (mini_frame) - printbufidx - 1) |
087e3c46 | 575 | { |
dc2a0b79 | 576 | size_byte = FRAME_MESSAGE_BUF_SIZE (mini_frame) - printbufidx - 1; |
087e3c46 | 577 | /* Rewind incomplete multi-byte form. */ |
4ad8bb20 KH |
578 | while (size_byte && (unsigned char) ptr[size_byte] >= 0xA0) |
579 | size_byte--; | |
087e3c46 | 580 | } |
4ad8bb20 KH |
581 | |
582 | /* Put that part of the new text in. */ | |
dc2a0b79 RS |
583 | bcopy (ptr, &FRAME_MESSAGE_BUF (mini_frame) [printbufidx], size_byte); |
584 | printbufidx += size_byte; | |
b8b1b8fd | 585 | FRAME_MESSAGE_BUF (mini_frame) [printbufidx] = 0; |
4ad8bb20 | 586 | echo_area_glyphs_length = printbufidx; |
38010d50 JB |
587 | |
588 | return; | |
589 | } | |
590 | ||
087e3c46 | 591 | i = 0; |
dc2a0b79 RS |
592 | if (size == size_byte) |
593 | while (i < size_byte) | |
594 | { | |
595 | int ch = ptr[i++]; | |
087e3c46 | 596 | |
dc2a0b79 RS |
597 | PRINTCHAR (ch); |
598 | } | |
599 | else | |
600 | while (i < size_byte) | |
601 | { | |
602 | /* Here, we must convert each multi-byte form to the | |
603 | corresponding character code before handing it to PRINTCHAR. */ | |
604 | int len; | |
605 | int ch = STRING_CHAR_AND_LENGTH (ptr + i, size_byte - i, len); | |
606 | ||
607 | PRINTCHAR (ch); | |
608 | i += len; | |
609 | } | |
38010d50 JB |
610 | } |
611 | ||
612 | /* Print the contents of a string STRING using PRINTCHARFUN. | |
ed2c35ef RS |
613 | It isn't safe to use strout in many cases, |
614 | because printing one char can relocate. */ | |
38010d50 | 615 | |
dc2a0b79 | 616 | static void |
38010d50 JB |
617 | print_string (string, printcharfun) |
618 | Lisp_Object string; | |
619 | Lisp_Object printcharfun; | |
620 | { | |
6fec5601 | 621 | if (EQ (printcharfun, Qt) || NILP (printcharfun)) |
375fcc09 KH |
622 | { |
623 | int chars; | |
624 | ||
625 | if (STRING_MULTIBYTE (string)) | |
626 | chars = XSTRING (string)->size; | |
627 | else if (EQ (printcharfun, Qt) | |
628 | ? ! NILP (buffer_defaults.enable_multibyte_characters) | |
629 | : ! NILP (current_buffer->enable_multibyte_characters)) | |
630 | chars = multibyte_chars_in_text (XSTRING (string)->data, | |
631 | STRING_BYTES (XSTRING (string))); | |
632 | else | |
633 | chars = STRING_BYTES (XSTRING (string)); | |
634 | ||
635 | /* strout is safe for output to a frame (echo area) or to print_buffer. */ | |
636 | strout (XSTRING (string)->data, | |
637 | chars, STRING_BYTES (XSTRING (string)), | |
638 | printcharfun, STRING_MULTIBYTE (string)); | |
639 | } | |
38010d50 JB |
640 | else |
641 | { | |
dc2a0b79 RS |
642 | /* Otherwise, string may be relocated by printing one char. |
643 | So re-fetch the string address for each character. */ | |
38010d50 JB |
644 | int i; |
645 | int size = XSTRING (string)->size; | |
fc932ac6 | 646 | int size_byte = STRING_BYTES (XSTRING (string)); |
38010d50 JB |
647 | struct gcpro gcpro1; |
648 | GCPRO1 (string); | |
dc2a0b79 RS |
649 | if (size == size_byte) |
650 | for (i = 0; i < size; i++) | |
651 | PRINTCHAR (XSTRING (string)->data[i]); | |
652 | else | |
653 | for (i = 0; i < size_byte; i++) | |
654 | { | |
655 | /* Here, we must convert each multi-byte form to the | |
656 | corresponding character code before handing it to PRINTCHAR. */ | |
657 | int len; | |
872a36d2 KH |
658 | int ch = STRING_CHAR_AND_CHAR_LENGTH (XSTRING (string)->data + i, |
659 | size_byte - i, len); | |
da1ad4e7 KH |
660 | if (!CHAR_VALID_P (ch, 0)) |
661 | { | |
662 | ch = XSTRING (string)->data[i]; | |
663 | len = 1; | |
664 | } | |
dc2a0b79 RS |
665 | PRINTCHAR (ch); |
666 | i += len; | |
667 | } | |
38010d50 JB |
668 | UNGCPRO; |
669 | } | |
670 | } | |
671 | \f | |
672 | DEFUN ("write-char", Fwrite_char, Swrite_char, 1, 2, 0, | |
3738a371 | 673 | "Output character CHARACTER to stream PRINTCHARFUN.\n\ |
57c9eb68 | 674 | PRINTCHARFUN defaults to the value of `standard-output' (which see).") |
3738a371 EN |
675 | (character, printcharfun) |
676 | Lisp_Object character, printcharfun; | |
38010d50 | 677 | { |
081e0581 | 678 | PRINTDECLARE; |
38010d50 | 679 | |
10eebdbb | 680 | if (NILP (printcharfun)) |
38010d50 | 681 | printcharfun = Vstandard_output; |
3738a371 | 682 | CHECK_NUMBER (character, 0); |
38010d50 | 683 | PRINTPREPARE; |
3738a371 | 684 | PRINTCHAR (XINT (character)); |
38010d50 | 685 | PRINTFINISH; |
3738a371 | 686 | return character; |
38010d50 JB |
687 | } |
688 | ||
dc2a0b79 RS |
689 | /* Used from outside of print.c to print a block of SIZE |
690 | single-byte chars at DATA on the default output stream. | |
38010d50 JB |
691 | Do not use this on the contents of a Lisp string. */ |
692 | ||
dc22f25e | 693 | void |
38010d50 JB |
694 | write_string (data, size) |
695 | char *data; | |
696 | int size; | |
697 | { | |
081e0581 | 698 | PRINTDECLARE; |
38010d50 | 699 | Lisp_Object printcharfun; |
38010d50 JB |
700 | |
701 | printcharfun = Vstandard_output; | |
702 | ||
703 | PRINTPREPARE; | |
dc2a0b79 | 704 | strout (data, size, size, printcharfun, 0); |
38010d50 JB |
705 | PRINTFINISH; |
706 | } | |
707 | ||
dc2a0b79 RS |
708 | /* Used from outside of print.c to print a block of SIZE |
709 | single-byte chars at DATA on a specified stream PRINTCHARFUN. | |
38010d50 JB |
710 | Do not use this on the contents of a Lisp string. */ |
711 | ||
dc22f25e | 712 | void |
38010d50 JB |
713 | write_string_1 (data, size, printcharfun) |
714 | char *data; | |
715 | int size; | |
716 | Lisp_Object printcharfun; | |
717 | { | |
081e0581 | 718 | PRINTDECLARE; |
38010d50 JB |
719 | |
720 | PRINTPREPARE; | |
dc2a0b79 | 721 | strout (data, size, size, printcharfun, 0); |
38010d50 JB |
722 | PRINTFINISH; |
723 | } | |
724 | ||
725 | ||
726 | #ifndef standalone | |
727 | ||
728 | void | |
729 | temp_output_buffer_setup (bufname) | |
730 | char *bufname; | |
731 | { | |
d9c21094 | 732 | int count = specpdl_ptr - specpdl; |
38010d50 JB |
733 | register struct buffer *old = current_buffer; |
734 | register Lisp_Object buf; | |
735 | ||
d9c21094 RS |
736 | record_unwind_protect (set_buffer_if_live, Fcurrent_buffer ()); |
737 | ||
38010d50 JB |
738 | Fset_buffer (Fget_buffer_create (build_string (bufname))); |
739 | ||
2a1c968a | 740 | current_buffer->directory = old->directory; |
38010d50 | 741 | current_buffer->read_only = Qnil; |
c5c6d57c KH |
742 | current_buffer->filename = Qnil; |
743 | current_buffer->undo_list = Qt; | |
744 | current_buffer->overlays_before = Qnil; | |
745 | current_buffer->overlays_after = Qnil; | |
746 | current_buffer->enable_multibyte_characters | |
747 | = buffer_defaults.enable_multibyte_characters; | |
38010d50 | 748 | Ferase_buffer (); |
633307b5 | 749 | XSETBUFFER (buf, current_buffer); |
38010d50 | 750 | |
d9c21094 RS |
751 | call1 (Vrun_hooks, Qtemp_buffer_setup_hook); |
752 | ||
753 | unbind_to (count, Qnil); | |
754 | ||
755 | specbind (Qstandard_output, buf); | |
38010d50 JB |
756 | } |
757 | ||
758 | Lisp_Object | |
759 | internal_with_output_to_temp_buffer (bufname, function, args) | |
760 | char *bufname; | |
dfcf069d | 761 | Lisp_Object (*function) P_ ((Lisp_Object)); |
38010d50 JB |
762 | Lisp_Object args; |
763 | { | |
764 | int count = specpdl_ptr - specpdl; | |
765 | Lisp_Object buf, val; | |
0ab39c81 | 766 | struct gcpro gcpro1; |
38010d50 | 767 | |
0ab39c81 | 768 | GCPRO1 (args); |
38010d50 JB |
769 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
770 | temp_output_buffer_setup (bufname); | |
771 | buf = Vstandard_output; | |
0ab39c81 | 772 | UNGCPRO; |
38010d50 JB |
773 | |
774 | val = (*function) (args); | |
775 | ||
0ab39c81 | 776 | GCPRO1 (val); |
38010d50 | 777 | temp_output_buffer_show (buf); |
0ab39c81 | 778 | UNGCPRO; |
38010d50 JB |
779 | |
780 | return unbind_to (count, val); | |
781 | } | |
782 | ||
783 | DEFUN ("with-output-to-temp-buffer", Fwith_output_to_temp_buffer, Swith_output_to_temp_buffer, | |
784 | 1, UNEVALLED, 0, | |
785 | "Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer.\n\ | |
786 | The buffer is cleared out initially, and marked as unmodified when done.\n\ | |
787 | All output done by BODY is inserted in that buffer by default.\n\ | |
788 | The buffer is displayed in another window, but not selected.\n\ | |
789 | The value of the last form in BODY is returned.\n\ | |
d9c21094 RS |
790 | If BODY does not finish normally, the buffer BUFNAME is not displayed.\n\ |
791 | \n\ | |
792 | The hook `temp-buffer-setup-hook' is run before BODY,\n\ | |
793 | with the buffer BUFNAME temporarily current.\n\ | |
794 | The hook `temp-buffer-show-hook' is run after the buffer is displayed,\n\ | |
795 | with the buffer temporarily current, and the window that was used\n\ | |
796 | to display it temporarily selected.\n\ | |
797 | \n\ | |
483288d7 | 798 | If variable `temp-buffer-show-function' is non-nil, call it at the end\n\ |
451f7df8 DL |
799 | to get the buffer displayed instead of just displaying the non-selected\n\ |
800 | buffer and calling the hook. It gets one argument, the buffer to display.") | |
38010d50 JB |
801 | (args) |
802 | Lisp_Object args; | |
803 | { | |
804 | struct gcpro gcpro1; | |
805 | Lisp_Object name; | |
806 | int count = specpdl_ptr - specpdl; | |
807 | Lisp_Object buf, val; | |
808 | ||
809 | GCPRO1(args); | |
810 | name = Feval (Fcar (args)); | |
811 | UNGCPRO; | |
812 | ||
813 | CHECK_STRING (name, 0); | |
814 | temp_output_buffer_setup (XSTRING (name)->data); | |
815 | buf = Vstandard_output; | |
816 | ||
817 | val = Fprogn (Fcdr (args)); | |
818 | ||
819 | temp_output_buffer_show (buf); | |
820 | ||
821 | return unbind_to (count, val); | |
822 | } | |
823 | #endif /* not standalone */ | |
824 | \f | |
825 | static void print (); | |
826 | ||
827 | DEFUN ("terpri", Fterpri, Sterpri, 0, 1, 0, | |
57c9eb68 KH |
828 | "Output a newline to stream PRINTCHARFUN.\n\ |
829 | If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used.") | |
38010d50 JB |
830 | (printcharfun) |
831 | Lisp_Object printcharfun; | |
832 | { | |
081e0581 | 833 | PRINTDECLARE; |
38010d50 | 834 | |
10eebdbb | 835 | if (NILP (printcharfun)) |
38010d50 JB |
836 | printcharfun = Vstandard_output; |
837 | PRINTPREPARE; | |
838 | PRINTCHAR ('\n'); | |
839 | PRINTFINISH; | |
840 | return Qt; | |
841 | } | |
842 | ||
843 | DEFUN ("prin1", Fprin1, Sprin1, 1, 2, 0, | |
844 | "Output the printed representation of OBJECT, any Lisp object.\n\ | |
845 | Quoting characters are printed when needed to make output that `read'\n\ | |
846 | can handle, whenever this is possible.\n\ | |
57c9eb68 | 847 | Output stream is PRINTCHARFUN, or value of `standard-output' (which see).") |
3738a371 EN |
848 | (object, printcharfun) |
849 | Lisp_Object object, printcharfun; | |
38010d50 | 850 | { |
081e0581 | 851 | PRINTDECLARE; |
38010d50 JB |
852 | |
853 | #ifdef MAX_PRINT_CHARS | |
854 | max_print = 0; | |
855 | #endif /* MAX_PRINT_CHARS */ | |
10eebdbb | 856 | if (NILP (printcharfun)) |
38010d50 JB |
857 | printcharfun = Vstandard_output; |
858 | PRINTPREPARE; | |
859 | print_depth = 0; | |
3738a371 | 860 | print (object, printcharfun, 1); |
38010d50 | 861 | PRINTFINISH; |
3738a371 | 862 | return object; |
38010d50 JB |
863 | } |
864 | ||
865 | /* a buffer which is used to hold output being built by prin1-to-string */ | |
866 | Lisp_Object Vprin1_to_string_buffer; | |
867 | ||
868 | DEFUN ("prin1-to-string", Fprin1_to_string, Sprin1_to_string, 1, 2, 0, | |
869 | "Return a string containing the printed representation of OBJECT,\n\ | |
870 | any Lisp object. Quoting characters are used when needed to make output\n\ | |
871 | that `read' can handle, whenever this is possible, unless the optional\n\ | |
872 | second argument NOESCAPE is non-nil.") | |
3738a371 EN |
873 | (object, noescape) |
874 | Lisp_Object object, noescape; | |
38010d50 | 875 | { |
081e0581 EN |
876 | PRINTDECLARE; |
877 | Lisp_Object printcharfun; | |
2a42e8f6 KH |
878 | struct gcpro gcpro1, gcpro2; |
879 | Lisp_Object tem; | |
880 | ||
881 | /* Save and restore this--we are altering a buffer | |
882 | but we don't want to deactivate the mark just for that. | |
883 | No need for specbind, since errors deactivate the mark. */ | |
884 | tem = Vdeactivate_mark; | |
885 | GCPRO2 (object, tem); | |
38010d50 JB |
886 | |
887 | printcharfun = Vprin1_to_string_buffer; | |
888 | PRINTPREPARE; | |
889 | print_depth = 0; | |
3738a371 | 890 | print (object, printcharfun, NILP (noescape)); |
38010d50 JB |
891 | /* Make Vprin1_to_string_buffer be the default buffer after PRINTFINSH */ |
892 | PRINTFINISH; | |
893 | set_buffer_internal (XBUFFER (Vprin1_to_string_buffer)); | |
3738a371 | 894 | object = Fbuffer_string (); |
38010d50 | 895 | |
38010d50 JB |
896 | Ferase_buffer (); |
897 | set_buffer_internal (old); | |
2a42e8f6 KH |
898 | |
899 | Vdeactivate_mark = tem; | |
38010d50 JB |
900 | UNGCPRO; |
901 | ||
3738a371 | 902 | return object; |
38010d50 JB |
903 | } |
904 | ||
905 | DEFUN ("princ", Fprinc, Sprinc, 1, 2, 0, | |
906 | "Output the printed representation of OBJECT, any Lisp object.\n\ | |
907 | No quoting characters are used; no delimiters are printed around\n\ | |
908 | the contents of strings.\n\ | |
57c9eb68 | 909 | Output stream is PRINTCHARFUN, or value of standard-output (which see).") |
3738a371 EN |
910 | (object, printcharfun) |
911 | Lisp_Object object, printcharfun; | |
38010d50 | 912 | { |
081e0581 | 913 | PRINTDECLARE; |
38010d50 | 914 | |
10eebdbb | 915 | if (NILP (printcharfun)) |
38010d50 JB |
916 | printcharfun = Vstandard_output; |
917 | PRINTPREPARE; | |
918 | print_depth = 0; | |
3738a371 | 919 | print (object, printcharfun, 0); |
38010d50 | 920 | PRINTFINISH; |
3738a371 | 921 | return object; |
38010d50 JB |
922 | } |
923 | ||
924 | DEFUN ("print", Fprint, Sprint, 1, 2, 0, | |
925 | "Output the printed representation of OBJECT, with newlines around it.\n\ | |
926 | Quoting characters are printed when needed to make output that `read'\n\ | |
927 | can handle, whenever this is possible.\n\ | |
57c9eb68 | 928 | Output stream is PRINTCHARFUN, or value of `standard-output' (which see).") |
3738a371 EN |
929 | (object, printcharfun) |
930 | Lisp_Object object, printcharfun; | |
38010d50 | 931 | { |
081e0581 | 932 | PRINTDECLARE; |
38010d50 JB |
933 | struct gcpro gcpro1; |
934 | ||
935 | #ifdef MAX_PRINT_CHARS | |
936 | print_chars = 0; | |
937 | max_print = MAX_PRINT_CHARS; | |
938 | #endif /* MAX_PRINT_CHARS */ | |
10eebdbb | 939 | if (NILP (printcharfun)) |
38010d50 | 940 | printcharfun = Vstandard_output; |
3738a371 | 941 | GCPRO1 (object); |
38010d50 JB |
942 | PRINTPREPARE; |
943 | print_depth = 0; | |
944 | PRINTCHAR ('\n'); | |
3738a371 | 945 | print (object, printcharfun, 1); |
38010d50 JB |
946 | PRINTCHAR ('\n'); |
947 | PRINTFINISH; | |
948 | #ifdef MAX_PRINT_CHARS | |
949 | max_print = 0; | |
950 | print_chars = 0; | |
951 | #endif /* MAX_PRINT_CHARS */ | |
952 | UNGCPRO; | |
3738a371 | 953 | return object; |
38010d50 JB |
954 | } |
955 | ||
956 | /* The subroutine object for external-debugging-output is kept here | |
957 | for the convenience of the debugger. */ | |
958 | Lisp_Object Qexternal_debugging_output; | |
959 | ||
4746118a JB |
960 | DEFUN ("external-debugging-output", Fexternal_debugging_output, Sexternal_debugging_output, 1, 1, 0, |
961 | "Write CHARACTER to stderr.\n\ | |
38010d50 JB |
962 | You can call print while debugging emacs, and pass it this function\n\ |
963 | to make it write to the debugging output.\n") | |
4746118a JB |
964 | (character) |
965 | Lisp_Object character; | |
38010d50 JB |
966 | { |
967 | CHECK_NUMBER (character, 0); | |
968 | putc (XINT (character), stderr); | |
cd22039d RS |
969 | |
970 | #ifdef WINDOWSNT | |
971 | /* Send the output to a debugger (nothing happens if there isn't one). */ | |
972 | { | |
973 | char buf[2] = {(char) XINT (character), '\0'}; | |
974 | OutputDebugString (buf); | |
975 | } | |
976 | #endif | |
977 | ||
38010d50 JB |
978 | return character; |
979 | } | |
cf1bb91b RS |
980 | |
981 | /* This is the interface for debugging printing. */ | |
982 | ||
983 | void | |
984 | debug_print (arg) | |
985 | Lisp_Object arg; | |
986 | { | |
987 | Fprin1 (arg, Qexternal_debugging_output); | |
3684eb78 | 988 | fprintf (stderr, "\r\n"); |
cf1bb91b | 989 | } |
38010d50 | 990 | \f |
113620cc KH |
991 | DEFUN ("error-message-string", Ferror_message_string, Serror_message_string, |
992 | 1, 1, 0, | |
993 | "Convert an error value (ERROR-SYMBOL . DATA) to an error message.") | |
994 | (obj) | |
995 | Lisp_Object obj; | |
996 | { | |
997 | struct buffer *old = current_buffer; | |
998 | Lisp_Object original, printcharfun, value; | |
999 | struct gcpro gcpro1; | |
1000 | ||
0872e11f RS |
1001 | /* If OBJ is (error STRING), just return STRING. |
1002 | That is not only faster, it also avoids the need to allocate | |
1003 | space here when the error is due to memory full. */ | |
1004 | if (CONSP (obj) && EQ (XCONS (obj)->car, Qerror) | |
1005 | && CONSP (XCONS (obj)->cdr) | |
1006 | && STRINGP (XCONS (XCONS (obj)->cdr)->car) | |
1007 | && NILP (XCONS (XCONS (obj)->cdr)->cdr)) | |
1008 | return XCONS (XCONS (obj)->cdr)->car; | |
1009 | ||
dc22f25e | 1010 | print_error_message (obj, Vprin1_to_string_buffer); |
113620cc KH |
1011 | |
1012 | set_buffer_internal (XBUFFER (Vprin1_to_string_buffer)); | |
1013 | value = Fbuffer_string (); | |
1014 | ||
1015 | GCPRO1 (value); | |
1016 | Ferase_buffer (); | |
1017 | set_buffer_internal (old); | |
1018 | UNGCPRO; | |
1019 | ||
1020 | return value; | |
1021 | } | |
1022 | ||
1023 | /* Print an error message for the error DATA | |
1024 | onto Lisp output stream STREAM (suitable for the print functions). */ | |
1025 | ||
dc22f25e | 1026 | void |
113620cc KH |
1027 | print_error_message (data, stream) |
1028 | Lisp_Object data, stream; | |
1029 | { | |
1030 | Lisp_Object errname, errmsg, file_error, tail; | |
1031 | struct gcpro gcpro1; | |
1032 | int i; | |
1033 | ||
1034 | errname = Fcar (data); | |
1035 | ||
1036 | if (EQ (errname, Qerror)) | |
1037 | { | |
1038 | data = Fcdr (data); | |
1039 | if (!CONSP (data)) data = Qnil; | |
1040 | errmsg = Fcar (data); | |
1041 | file_error = Qnil; | |
1042 | } | |
1043 | else | |
1044 | { | |
1045 | errmsg = Fget (errname, Qerror_message); | |
1046 | file_error = Fmemq (Qfile_error, | |
1047 | Fget (errname, Qerror_conditions)); | |
1048 | } | |
1049 | ||
1050 | /* Print an error message including the data items. */ | |
1051 | ||
1052 | tail = Fcdr_safe (data); | |
1053 | GCPRO1 (tail); | |
1054 | ||
1055 | /* For file-error, make error message by concatenating | |
1056 | all the data items. They are all strings. */ | |
1057 | if (!NILP (file_error) && !NILP (tail)) | |
1058 | errmsg = XCONS (tail)->car, tail = XCONS (tail)->cdr; | |
1059 | ||
1060 | if (STRINGP (errmsg)) | |
1061 | Fprinc (errmsg, stream); | |
1062 | else | |
1063 | write_string_1 ("peculiar error", -1, stream); | |
1064 | ||
1065 | for (i = 0; CONSP (tail); tail = Fcdr (tail), i++) | |
1066 | { | |
1067 | write_string_1 (i ? ", " : ": ", 2, stream); | |
1068 | if (!NILP (file_error)) | |
1069 | Fprinc (Fcar (tail), stream); | |
1070 | else | |
1071 | Fprin1 (Fcar (tail), stream); | |
1072 | } | |
1073 | UNGCPRO; | |
1074 | } | |
1075 | \f | |
38010d50 JB |
1076 | #ifdef LISP_FLOAT_TYPE |
1077 | ||
38010d50 | 1078 | /* |
edb2a707 | 1079 | * The buffer should be at least as large as the max string size of the |
8e6208c5 | 1080 | * largest float, printed in the biggest notation. This is undoubtedly |
38010d50 JB |
1081 | * 20d float_output_format, with the negative of the C-constant "HUGE" |
1082 | * from <math.h>. | |
1083 | * | |
1084 | * On the vax the worst case is -1e38 in 20d format which takes 61 bytes. | |
1085 | * | |
1086 | * I assume that IEEE-754 format numbers can take 329 bytes for the worst | |
1087 | * case of -1e307 in 20d float_output_format. What is one to do (short of | |
1088 | * re-writing _doprnt to be more sane)? | |
1089 | * -wsr | |
1090 | */ | |
edb2a707 RS |
1091 | |
1092 | void | |
1093 | float_to_string (buf, data) | |
8b24d146 | 1094 | unsigned char *buf; |
38010d50 JB |
1095 | double data; |
1096 | { | |
c7b14277 | 1097 | unsigned char *cp; |
322890c4 | 1098 | int width; |
38010d50 | 1099 | |
7f45de2d RS |
1100 | /* Check for plus infinity in a way that won't lose |
1101 | if there is no plus infinity. */ | |
1102 | if (data == data / 2 && data > 1.0) | |
1103 | { | |
1104 | strcpy (buf, "1.0e+INF"); | |
1105 | return; | |
1106 | } | |
1107 | /* Likewise for minus infinity. */ | |
1108 | if (data == data / 2 && data < -1.0) | |
1109 | { | |
1110 | strcpy (buf, "-1.0e+INF"); | |
1111 | return; | |
1112 | } | |
1113 | /* Check for NaN in a way that won't fail if there are no NaNs. */ | |
1114 | if (! (data * 0.0 >= 0.0)) | |
1115 | { | |
1116 | strcpy (buf, "0.0e+NaN"); | |
1117 | return; | |
1118 | } | |
1119 | ||
10eebdbb | 1120 | if (NILP (Vfloat_output_format) |
d4ae1f7e | 1121 | || !STRINGP (Vfloat_output_format)) |
38010d50 | 1122 | lose: |
322890c4 | 1123 | { |
f356c3fb PE |
1124 | /* Generate the fewest number of digits that represent the |
1125 | floating point value without losing information. | |
1126 | The following method is simple but a bit slow. | |
1127 | For ideas about speeding things up, please see: | |
1128 | ||
1129 | Guy L Steele Jr & Jon L White, How to print floating-point numbers | |
1130 | accurately. SIGPLAN notices 25, 6 (June 1990), 112-126. | |
1131 | ||
1132 | Robert G Burger & R Kent Dybvig, Printing floating point numbers | |
1133 | quickly and accurately, SIGPLAN notices 31, 5 (May 1996), 108-116. */ | |
1134 | ||
1135 | width = fabs (data) < DBL_MIN ? 1 : DBL_DIG; | |
1136 | do | |
1137 | sprintf (buf, "%.*g", width, data); | |
1138 | while (width++ < DOUBLE_DIGITS_BOUND && atof (buf) != data); | |
322890c4 | 1139 | } |
38010d50 JB |
1140 | else /* oink oink */ |
1141 | { | |
1142 | /* Check that the spec we have is fully valid. | |
1143 | This means not only valid for printf, | |
1144 | but meant for floats, and reasonable. */ | |
1145 | cp = XSTRING (Vfloat_output_format)->data; | |
1146 | ||
1147 | if (cp[0] != '%') | |
1148 | goto lose; | |
1149 | if (cp[1] != '.') | |
1150 | goto lose; | |
1151 | ||
1152 | cp += 2; | |
c7b14277 JB |
1153 | |
1154 | /* Check the width specification. */ | |
322890c4 | 1155 | width = -1; |
c7b14277 | 1156 | if ('0' <= *cp && *cp <= '9') |
381cd4bb KH |
1157 | { |
1158 | width = 0; | |
1159 | do | |
1160 | width = (width * 10) + (*cp++ - '0'); | |
1161 | while (*cp >= '0' && *cp <= '9'); | |
1162 | ||
1163 | /* A precision of zero is valid only for %f. */ | |
1164 | if (width > DBL_DIG | |
1165 | || (width == 0 && *cp != 'f')) | |
1166 | goto lose; | |
1167 | } | |
38010d50 JB |
1168 | |
1169 | if (*cp != 'e' && *cp != 'f' && *cp != 'g') | |
1170 | goto lose; | |
1171 | ||
38010d50 JB |
1172 | if (cp[1] != 0) |
1173 | goto lose; | |
1174 | ||
1175 | sprintf (buf, XSTRING (Vfloat_output_format)->data, data); | |
1176 | } | |
edb2a707 | 1177 | |
c7b14277 JB |
1178 | /* Make sure there is a decimal point with digit after, or an |
1179 | exponent, so that the value is readable as a float. But don't do | |
322890c4 RS |
1180 | this with "%.0f"; it's valid for that not to produce a decimal |
1181 | point. Note that width can be 0 only for %.0f. */ | |
1182 | if (width != 0) | |
0601fd3d | 1183 | { |
c7b14277 JB |
1184 | for (cp = buf; *cp; cp++) |
1185 | if ((*cp < '0' || *cp > '9') && *cp != '-') | |
1186 | break; | |
0601fd3d | 1187 | |
c7b14277 JB |
1188 | if (*cp == '.' && cp[1] == 0) |
1189 | { | |
1190 | cp[1] = '0'; | |
1191 | cp[2] = 0; | |
1192 | } | |
1193 | ||
1194 | if (*cp == 0) | |
1195 | { | |
1196 | *cp++ = '.'; | |
1197 | *cp++ = '0'; | |
1198 | *cp++ = 0; | |
1199 | } | |
edb2a707 | 1200 | } |
38010d50 JB |
1201 | } |
1202 | #endif /* LISP_FLOAT_TYPE */ | |
1203 | \f | |
1204 | static void | |
1205 | print (obj, printcharfun, escapeflag) | |
38010d50 | 1206 | Lisp_Object obj; |
38010d50 JB |
1207 | register Lisp_Object printcharfun; |
1208 | int escapeflag; | |
1209 | { | |
1210 | char buf[30]; | |
1211 | ||
1212 | QUIT; | |
1213 | ||
ec838c39 RS |
1214 | #if 1 /* I'm not sure this is really worth doing. */ |
1215 | /* Detect circularities and truncate them. | |
1216 | No need to offer any alternative--this is better than an error. */ | |
d4ae1f7e | 1217 | if (CONSP (obj) || VECTORP (obj) || COMPILEDP (obj)) |
ec838c39 RS |
1218 | { |
1219 | int i; | |
1220 | for (i = 0; i < print_depth; i++) | |
1221 | if (EQ (obj, being_printed[i])) | |
1222 | { | |
1223 | sprintf (buf, "#%d", i); | |
dc2a0b79 | 1224 | strout (buf, -1, -1, printcharfun, 0); |
ec838c39 RS |
1225 | return; |
1226 | } | |
1227 | } | |
1228 | #endif | |
1229 | ||
1230 | being_printed[print_depth] = obj; | |
38010d50 JB |
1231 | print_depth++; |
1232 | ||
ec838c39 | 1233 | if (print_depth > PRINT_CIRCLE) |
38010d50 JB |
1234 | error ("Apparently circular structure being printed"); |
1235 | #ifdef MAX_PRINT_CHARS | |
1236 | if (max_print && print_chars > max_print) | |
1237 | { | |
1238 | PRINTCHAR ('\n'); | |
1239 | print_chars = 0; | |
1240 | } | |
1241 | #endif /* MAX_PRINT_CHARS */ | |
1242 | ||
ca0569ad | 1243 | switch (XGCTYPE (obj)) |
38010d50 | 1244 | { |
ca0569ad | 1245 | case Lisp_Int: |
b8180922 RS |
1246 | if (sizeof (int) == sizeof (EMACS_INT)) |
1247 | sprintf (buf, "%d", XINT (obj)); | |
1248 | else if (sizeof (long) == sizeof (EMACS_INT)) | |
1249 | sprintf (buf, "%ld", XINT (obj)); | |
1250 | else | |
1251 | abort (); | |
dc2a0b79 | 1252 | strout (buf, -1, -1, printcharfun, 0); |
ca0569ad RS |
1253 | break; |
1254 | ||
e0f93814 | 1255 | #ifdef LISP_FLOAT_TYPE |
ca0569ad RS |
1256 | case Lisp_Float: |
1257 | { | |
1258 | char pigbuf[350]; /* see comments in float_to_string */ | |
38010d50 | 1259 | |
ca0569ad | 1260 | float_to_string (pigbuf, XFLOAT(obj)->data); |
dc2a0b79 | 1261 | strout (pigbuf, -1, -1, printcharfun, 0); |
ca0569ad RS |
1262 | } |
1263 | break; | |
e0f93814 | 1264 | #endif |
ca0569ad RS |
1265 | |
1266 | case Lisp_String: | |
38010d50 JB |
1267 | if (!escapeflag) |
1268 | print_string (obj, printcharfun); | |
1269 | else | |
1270 | { | |
dc2a0b79 | 1271 | register int i, i_byte; |
38010d50 | 1272 | register unsigned char c; |
38010d50 | 1273 | struct gcpro gcpro1; |
872a36d2 | 1274 | unsigned char *str; |
dc2a0b79 | 1275 | int size_byte; |
453fa987 RS |
1276 | /* 1 means we must ensure that the next character we output |
1277 | cannot be taken as part of a hex character escape. */ | |
1278 | int need_nonhex = 0; | |
38010d50 | 1279 | |
7651e1f5 RS |
1280 | GCPRO1 (obj); |
1281 | ||
1282 | #ifdef USE_TEXT_PROPERTIES | |
1283 | if (!NULL_INTERVAL_P (XSTRING (obj)->intervals)) | |
1284 | { | |
1285 | PRINTCHAR ('#'); | |
1286 | PRINTCHAR ('('); | |
1287 | } | |
1288 | #endif | |
38010d50 JB |
1289 | |
1290 | PRINTCHAR ('\"'); | |
872a36d2 | 1291 | str = XSTRING (obj)->data; |
fc932ac6 | 1292 | size_byte = STRING_BYTES (XSTRING (obj)); |
dc2a0b79 RS |
1293 | |
1294 | for (i = 0, i_byte = 0; i_byte < size_byte;) | |
38010d50 | 1295 | { |
6ddd6eee RS |
1296 | /* Here, we must convert each multi-byte form to the |
1297 | corresponding character code before handing it to PRINTCHAR. */ | |
1298 | int len; | |
dc2a0b79 RS |
1299 | int c; |
1300 | ||
1301 | if (STRING_MULTIBYTE (obj)) | |
872a36d2 KH |
1302 | { |
1303 | c = STRING_CHAR_AND_CHAR_LENGTH (str + i_byte, | |
1304 | size_byte - i_byte, len); | |
da1ad4e7 KH |
1305 | if (CHAR_VALID_P (c, 0)) |
1306 | i_byte += len; | |
1307 | else | |
1308 | c = str[i_byte++]; | |
872a36d2 | 1309 | } |
dc2a0b79 | 1310 | else |
872a36d2 | 1311 | c = str[i_byte++]; |
dc2a0b79 | 1312 | |
38010d50 | 1313 | QUIT; |
6ddd6eee | 1314 | |
38010d50 JB |
1315 | if (c == '\n' && print_escape_newlines) |
1316 | { | |
1317 | PRINTCHAR ('\\'); | |
1318 | PRINTCHAR ('n'); | |
1319 | } | |
c6f7982f RM |
1320 | else if (c == '\f' && print_escape_newlines) |
1321 | { | |
1322 | PRINTCHAR ('\\'); | |
1323 | PRINTCHAR ('f'); | |
1324 | } | |
835d0be6 | 1325 | else if (! SINGLE_BYTE_CHAR_P (c) && print_escape_multibyte) |
dc2a0b79 RS |
1326 | { |
1327 | /* When multibyte is disabled, | |
1328 | print multibyte string chars using hex escapes. */ | |
1329 | unsigned char outbuf[50]; | |
1330 | sprintf (outbuf, "\\x%x", c); | |
1331 | strout (outbuf, -1, -1, printcharfun, 0); | |
453fa987 | 1332 | need_nonhex = 1; |
dc2a0b79 | 1333 | } |
835d0be6 RS |
1334 | else if (SINGLE_BYTE_CHAR_P (c) && ! ASCII_BYTE_P (c) |
1335 | && print_escape_nonascii) | |
974a6ff5 | 1336 | { |
835d0be6 RS |
1337 | /* When printing in a multibyte buffer |
1338 | or when explicitly requested, | |
974a6ff5 KH |
1339 | print single-byte non-ASCII string chars |
1340 | using octal escapes. */ | |
1341 | unsigned char outbuf[5]; | |
1342 | sprintf (outbuf, "\\%03o", c); | |
1343 | strout (outbuf, -1, -1, printcharfun, 0); | |
1344 | } | |
38010d50 JB |
1345 | else |
1346 | { | |
453fa987 RS |
1347 | /* If we just had a hex escape, and this character |
1348 | could be taken as part of it, | |
1349 | output `\ ' to prevent that. */ | |
1b62edd6 KH |
1350 | if (need_nonhex) |
1351 | { | |
1352 | need_nonhex = 0; | |
1353 | if ((c >= 'a' && c <= 'f') | |
453fa987 | 1354 | || (c >= 'A' && c <= 'F') |
1b62edd6 KH |
1355 | || (c >= '0' && c <= '9')) |
1356 | strout ("\\ ", -1, -1, printcharfun, 0); | |
1357 | } | |
453fa987 | 1358 | |
38010d50 JB |
1359 | if (c == '\"' || c == '\\') |
1360 | PRINTCHAR ('\\'); | |
1361 | PRINTCHAR (c); | |
1362 | } | |
1363 | } | |
1364 | PRINTCHAR ('\"'); | |
7651e1f5 RS |
1365 | |
1366 | #ifdef USE_TEXT_PROPERTIES | |
1367 | if (!NULL_INTERVAL_P (XSTRING (obj)->intervals)) | |
1368 | { | |
7651e1f5 RS |
1369 | traverse_intervals (XSTRING (obj)->intervals, |
1370 | 0, 0, print_interval, printcharfun); | |
1371 | PRINTCHAR (')'); | |
1372 | } | |
1373 | #endif | |
1374 | ||
38010d50 JB |
1375 | UNGCPRO; |
1376 | } | |
ca0569ad | 1377 | break; |
38010d50 | 1378 | |
ca0569ad RS |
1379 | case Lisp_Symbol: |
1380 | { | |
1381 | register int confusing; | |
1382 | register unsigned char *p = XSYMBOL (obj)->name->data; | |
fc932ac6 | 1383 | register unsigned char *end = p + STRING_BYTES (XSYMBOL (obj)->name); |
2190a05e | 1384 | register int c; |
dc2a0b79 RS |
1385 | int i, i_byte, size_byte; |
1386 | Lisp_Object name; | |
1387 | ||
1388 | XSETSTRING (name, XSYMBOL (obj)->name); | |
ca0569ad RS |
1389 | |
1390 | if (p != end && (*p == '-' || *p == '+')) p++; | |
1391 | if (p == end) | |
1392 | confusing = 0; | |
d27497e3 RS |
1393 | /* If symbol name begins with a digit, and ends with a digit, |
1394 | and contains nothing but digits and `e', it could be treated | |
1395 | as a number. So set CONFUSING. | |
1396 | ||
1397 | Symbols that contain periods could also be taken as numbers, | |
1398 | but periods are always escaped, so we don't have to worry | |
1399 | about them here. */ | |
1400 | else if (*p >= '0' && *p <= '9' | |
1401 | && end[-1] >= '0' && end[-1] <= '9') | |
ca0569ad | 1402 | { |
e837058b RS |
1403 | while (p != end && ((*p >= '0' && *p <= '9') |
1404 | /* Needed for \2e10. */ | |
1405 | || *p == 'e')) | |
ca0569ad RS |
1406 | p++; |
1407 | confusing = (end == p); | |
1408 | } | |
d27497e3 RS |
1409 | else |
1410 | confusing = 0; | |
ca0569ad | 1411 | |
081e0581 EN |
1412 | /* If we print an uninterned symbol as part of a complex object and |
1413 | the flag print-gensym is non-nil, prefix it with #n= to read the | |
1414 | object back with the #n# reader syntax later if needed. */ | |
e0f69431 | 1415 | if (! NILP (Vprint_gensym) && NILP (XSYMBOL (obj)->obarray)) |
081e0581 EN |
1416 | { |
1417 | if (print_depth > 1) | |
1418 | { | |
1419 | Lisp_Object tem; | |
e0f69431 | 1420 | tem = Fassq (obj, Vprint_gensym_alist); |
081e0581 EN |
1421 | if (CONSP (tem)) |
1422 | { | |
1423 | PRINTCHAR ('#'); | |
1424 | print (XCDR (tem), printcharfun, escapeflag); | |
1425 | PRINTCHAR ('#'); | |
1426 | break; | |
1427 | } | |
1428 | else | |
1429 | { | |
e0f69431 RS |
1430 | if (CONSP (Vprint_gensym_alist)) |
1431 | XSETFASTINT (tem, XFASTINT (XCDR (XCAR (Vprint_gensym_alist))) + 1); | |
081e0581 EN |
1432 | else |
1433 | XSETFASTINT (tem, 1); | |
e0f69431 | 1434 | Vprint_gensym_alist = Fcons (Fcons (obj, tem), Vprint_gensym_alist); |
081e0581 EN |
1435 | |
1436 | PRINTCHAR ('#'); | |
1437 | print (tem, printcharfun, escapeflag); | |
1438 | PRINTCHAR ('='); | |
1439 | } | |
1440 | } | |
1441 | PRINTCHAR ('#'); | |
1442 | PRINTCHAR (':'); | |
1443 | } | |
1444 | ||
fc932ac6 | 1445 | size_byte = STRING_BYTES (XSTRING (name)); |
dc2a0b79 RS |
1446 | |
1447 | for (i = 0, i_byte = 0; i_byte < size_byte;) | |
ca0569ad | 1448 | { |
6ddd6eee RS |
1449 | /* Here, we must convert each multi-byte form to the |
1450 | corresponding character code before handing it to PRINTCHAR. */ | |
dc2a0b79 RS |
1451 | |
1452 | if (STRING_MULTIBYTE (name)) | |
1453 | FETCH_STRING_CHAR_ADVANCE (c, name, i, i_byte); | |
1454 | else | |
1455 | c = XSTRING (name)->data[i_byte++]; | |
1456 | ||
ca0569ad | 1457 | QUIT; |
09eddb56 | 1458 | |
ca0569ad RS |
1459 | if (escapeflag) |
1460 | { | |
09eddb56 RS |
1461 | if (c == '\"' || c == '\\' || c == '\'' |
1462 | || c == ';' || c == '#' || c == '(' || c == ')' | |
1463 | || c == ',' || c =='.' || c == '`' | |
1464 | || c == '[' || c == ']' || c == '?' || c <= 040 | |
1465 | || confusing) | |
ca0569ad RS |
1466 | PRINTCHAR ('\\'), confusing = 0; |
1467 | } | |
1468 | PRINTCHAR (c); | |
1469 | } | |
1470 | } | |
1471 | break; | |
1472 | ||
1473 | case Lisp_Cons: | |
38010d50 | 1474 | /* If deeper than spec'd depth, print placeholder. */ |
d4ae1f7e | 1475 | if (INTEGERP (Vprint_level) |
38010d50 | 1476 | && print_depth > XINT (Vprint_level)) |
dc2a0b79 | 1477 | strout ("...", -1, -1, printcharfun, 0); |
2f100b5c EN |
1478 | else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj))) |
1479 | && (EQ (XCAR (obj), Qquote))) | |
1480 | { | |
1481 | PRINTCHAR ('\''); | |
1482 | print (XCAR (XCDR (obj)), printcharfun, escapeflag); | |
1483 | } | |
1484 | else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj))) | |
1485 | && (EQ (XCAR (obj), Qfunction))) | |
1486 | { | |
1487 | PRINTCHAR ('#'); | |
1488 | PRINTCHAR ('\''); | |
1489 | print (XCAR (XCDR (obj)), printcharfun, escapeflag); | |
1490 | } | |
1491 | else if (print_quoted && CONSP (XCDR (obj)) && NILP (XCDR (XCDR (obj))) | |
1492 | && ((EQ (XCAR (obj), Qbackquote) | |
1493 | || EQ (XCAR (obj), Qcomma) | |
1494 | || EQ (XCAR (obj), Qcomma_at) | |
1495 | || EQ (XCAR (obj), Qcomma_dot)))) | |
1496 | { | |
1497 | print (XCAR (obj), printcharfun, 0); | |
1498 | print (XCAR (XCDR (obj)), printcharfun, escapeflag); | |
1499 | } | |
e0f93814 | 1500 | else |
38010d50 | 1501 | { |
e0f93814 | 1502 | PRINTCHAR ('('); |
38010d50 | 1503 | { |
e0f93814 | 1504 | register int i = 0; |
f4fe72d5 | 1505 | register int print_length = 0; |
1eab22b5 | 1506 | Lisp_Object halftail = obj; |
e0f93814 KH |
1507 | |
1508 | if (INTEGERP (Vprint_length)) | |
f4fe72d5 | 1509 | print_length = XINT (Vprint_length); |
e0f93814 | 1510 | while (CONSP (obj)) |
38010d50 | 1511 | { |
1eab22b5 RS |
1512 | /* Detect circular list. */ |
1513 | if (i != 0 && EQ (obj, halftail)) | |
1514 | { | |
1515 | sprintf (buf, " . #%d", i / 2); | |
1516 | strout (buf, -1, -1, printcharfun, 0); | |
1517 | obj = Qnil; | |
1518 | break; | |
1519 | } | |
e0f93814 KH |
1520 | if (i++) |
1521 | PRINTCHAR (' '); | |
f4fe72d5 | 1522 | if (print_length && i > print_length) |
e0f93814 | 1523 | { |
dc2a0b79 | 1524 | strout ("...", 3, 3, printcharfun, 0); |
e0f93814 KH |
1525 | break; |
1526 | } | |
2f100b5c EN |
1527 | print (XCAR (obj), printcharfun, escapeflag); |
1528 | obj = XCDR (obj); | |
1eab22b5 RS |
1529 | if (!(i & 1)) |
1530 | halftail = XCDR (halftail); | |
38010d50 | 1531 | } |
38010d50 | 1532 | } |
2f100b5c | 1533 | if (!NILP (obj)) |
e0f93814 | 1534 | { |
dc2a0b79 | 1535 | strout (" . ", 3, 3, printcharfun, 0); |
e0f93814 KH |
1536 | print (obj, printcharfun, escapeflag); |
1537 | } | |
1538 | PRINTCHAR (')'); | |
38010d50 | 1539 | } |
ca0569ad RS |
1540 | break; |
1541 | ||
1542 | case Lisp_Vectorlike: | |
1543 | if (PROCESSP (obj)) | |
1544 | { | |
1545 | if (escapeflag) | |
1546 | { | |
dc2a0b79 | 1547 | strout ("#<process ", -1, -1, printcharfun, 0); |
ca0569ad RS |
1548 | print_string (XPROCESS (obj)->name, printcharfun); |
1549 | PRINTCHAR ('>'); | |
1550 | } | |
1551 | else | |
1552 | print_string (XPROCESS (obj)->name, printcharfun); | |
1553 | } | |
ed2c35ef RS |
1554 | else if (BOOL_VECTOR_P (obj)) |
1555 | { | |
1556 | register int i; | |
1557 | register unsigned char c; | |
1558 | struct gcpro gcpro1; | |
ed2c35ef | 1559 | int size_in_chars |
1bad7c59 | 1560 | = (XBOOL_VECTOR (obj)->size + BITS_PER_CHAR - 1) / BITS_PER_CHAR; |
ed2c35ef RS |
1561 | |
1562 | GCPRO1 (obj); | |
1563 | ||
1564 | PRINTCHAR ('#'); | |
1565 | PRINTCHAR ('&'); | |
1566 | sprintf (buf, "%d", XBOOL_VECTOR (obj)->size); | |
dc2a0b79 | 1567 | strout (buf, -1, -1, printcharfun, 0); |
ed2c35ef | 1568 | PRINTCHAR ('\"'); |
a40384bc RS |
1569 | |
1570 | /* Don't print more characters than the specified maximum. */ | |
1571 | if (INTEGERP (Vprint_length) | |
1572 | && XINT (Vprint_length) < size_in_chars) | |
1573 | size_in_chars = XINT (Vprint_length); | |
1574 | ||
ed2c35ef RS |
1575 | for (i = 0; i < size_in_chars; i++) |
1576 | { | |
1577 | QUIT; | |
1578 | c = XBOOL_VECTOR (obj)->data[i]; | |
1579 | if (c == '\n' && print_escape_newlines) | |
1580 | { | |
1581 | PRINTCHAR ('\\'); | |
1582 | PRINTCHAR ('n'); | |
1583 | } | |
1584 | else if (c == '\f' && print_escape_newlines) | |
1585 | { | |
1586 | PRINTCHAR ('\\'); | |
1587 | PRINTCHAR ('f'); | |
1588 | } | |
1589 | else | |
1590 | { | |
1591 | if (c == '\"' || c == '\\') | |
1592 | PRINTCHAR ('\\'); | |
1593 | PRINTCHAR (c); | |
1594 | } | |
1595 | } | |
1596 | PRINTCHAR ('\"'); | |
1597 | ||
1598 | UNGCPRO; | |
1599 | } | |
ca0569ad RS |
1600 | else if (SUBRP (obj)) |
1601 | { | |
dc2a0b79 RS |
1602 | strout ("#<subr ", -1, -1, printcharfun, 0); |
1603 | strout (XSUBR (obj)->symbol_name, -1, -1, printcharfun, 0); | |
ca0569ad RS |
1604 | PRINTCHAR ('>'); |
1605 | } | |
1606 | #ifndef standalone | |
1607 | else if (WINDOWP (obj)) | |
1608 | { | |
dc2a0b79 | 1609 | strout ("#<window ", -1, -1, printcharfun, 0); |
ca0569ad | 1610 | sprintf (buf, "%d", XFASTINT (XWINDOW (obj)->sequence_number)); |
dc2a0b79 | 1611 | strout (buf, -1, -1, printcharfun, 0); |
ca0569ad RS |
1612 | if (!NILP (XWINDOW (obj)->buffer)) |
1613 | { | |
dc2a0b79 | 1614 | strout (" on ", -1, -1, printcharfun, 0); |
ca0569ad RS |
1615 | print_string (XBUFFER (XWINDOW (obj)->buffer)->name, printcharfun); |
1616 | } | |
1617 | PRINTCHAR ('>'); | |
1618 | } | |
908b0ae5 RS |
1619 | else if (BUFFERP (obj)) |
1620 | { | |
1621 | if (NILP (XBUFFER (obj)->name)) | |
dc2a0b79 | 1622 | strout ("#<killed buffer>", -1, -1, printcharfun, 0); |
908b0ae5 RS |
1623 | else if (escapeflag) |
1624 | { | |
dc2a0b79 | 1625 | strout ("#<buffer ", -1, -1, printcharfun, 0); |
908b0ae5 RS |
1626 | print_string (XBUFFER (obj)->name, printcharfun); |
1627 | PRINTCHAR ('>'); | |
1628 | } | |
1629 | else | |
1630 | print_string (XBUFFER (obj)->name, printcharfun); | |
1631 | } | |
ca0569ad RS |
1632 | else if (WINDOW_CONFIGURATIONP (obj)) |
1633 | { | |
dc2a0b79 | 1634 | strout ("#<window-configuration>", -1, -1, printcharfun, 0); |
ca0569ad | 1635 | } |
ca0569ad RS |
1636 | else if (FRAMEP (obj)) |
1637 | { | |
1638 | strout ((FRAME_LIVE_P (XFRAME (obj)) | |
1639 | ? "#<frame " : "#<dead frame "), | |
dc2a0b79 | 1640 | -1, -1, printcharfun, 0); |
ca0569ad | 1641 | print_string (XFRAME (obj)->name, printcharfun); |
dc2a0b79 RS |
1642 | sprintf (buf, " 0x%lx\\ ", (unsigned long) (XFRAME (obj))); |
1643 | strout (buf, -1, -1, printcharfun, 0); | |
ca0569ad RS |
1644 | PRINTCHAR ('>'); |
1645 | } | |
ca0569ad RS |
1646 | #endif /* not standalone */ |
1647 | else | |
1648 | { | |
1649 | int size = XVECTOR (obj)->size; | |
1650 | if (COMPILEDP (obj)) | |
1651 | { | |
1652 | PRINTCHAR ('#'); | |
1653 | size &= PSEUDOVECTOR_SIZE_MASK; | |
1654 | } | |
ed2c35ef RS |
1655 | if (CHAR_TABLE_P (obj)) |
1656 | { | |
1657 | /* We print a char-table as if it were a vector, | |
1658 | lumping the parent and default slots in with the | |
1659 | character slots. But we add #^ as a prefix. */ | |
1660 | PRINTCHAR ('#'); | |
1661 | PRINTCHAR ('^'); | |
3701b5de KH |
1662 | if (SUB_CHAR_TABLE_P (obj)) |
1663 | PRINTCHAR ('^'); | |
ed2c35ef RS |
1664 | size &= PSEUDOVECTOR_SIZE_MASK; |
1665 | } | |
00d76abc KH |
1666 | if (size & PSEUDOVECTOR_FLAG) |
1667 | goto badtype; | |
ca0569ad RS |
1668 | |
1669 | PRINTCHAR ('['); | |
38010d50 | 1670 | { |
ca0569ad RS |
1671 | register int i; |
1672 | register Lisp_Object tem; | |
a40384bc RS |
1673 | |
1674 | /* Don't print more elements than the specified maximum. */ | |
1675 | if (INTEGERP (Vprint_length) | |
1676 | && XINT (Vprint_length) < size) | |
1677 | size = XINT (Vprint_length); | |
1678 | ||
ca0569ad RS |
1679 | for (i = 0; i < size; i++) |
1680 | { | |
1681 | if (i) PRINTCHAR (' '); | |
1682 | tem = XVECTOR (obj)->contents[i]; | |
1683 | print (tem, printcharfun, escapeflag); | |
1684 | } | |
38010d50 | 1685 | } |
ca0569ad RS |
1686 | PRINTCHAR (']'); |
1687 | } | |
1688 | break; | |
1689 | ||
38010d50 | 1690 | #ifndef standalone |
ca0569ad | 1691 | case Lisp_Misc: |
5db20f08 | 1692 | switch (XMISCTYPE (obj)) |
38010d50 | 1693 | { |
00d76abc | 1694 | case Lisp_Misc_Marker: |
dc2a0b79 | 1695 | strout ("#<marker ", -1, -1, printcharfun, 0); |
087e3c46 KH |
1696 | /* Do you think this is necessary? */ |
1697 | if (XMARKER (obj)->insertion_type != 0) | |
dc2a0b79 | 1698 | strout ("(before-insertion) ", -1, -1, printcharfun, 0); |
ca0569ad | 1699 | if (!(XMARKER (obj)->buffer)) |
dc2a0b79 | 1700 | strout ("in no buffer", -1, -1, printcharfun, 0); |
ca0569ad RS |
1701 | else |
1702 | { | |
1703 | sprintf (buf, "at %d", marker_position (obj)); | |
dc2a0b79 RS |
1704 | strout (buf, -1, -1, printcharfun, 0); |
1705 | strout (" in ", -1, -1, printcharfun, 0); | |
ca0569ad RS |
1706 | print_string (XMARKER (obj)->buffer->name, printcharfun); |
1707 | } | |
38010d50 | 1708 | PRINTCHAR ('>'); |
908b0ae5 | 1709 | break; |
00d76abc KH |
1710 | |
1711 | case Lisp_Misc_Overlay: | |
dc2a0b79 | 1712 | strout ("#<overlay ", -1, -1, printcharfun, 0); |
ca0569ad | 1713 | if (!(XMARKER (OVERLAY_START (obj))->buffer)) |
dc2a0b79 | 1714 | strout ("in no buffer", -1, -1, printcharfun, 0); |
ca0569ad RS |
1715 | else |
1716 | { | |
1717 | sprintf (buf, "from %d to %d in ", | |
1718 | marker_position (OVERLAY_START (obj)), | |
1719 | marker_position (OVERLAY_END (obj))); | |
dc2a0b79 | 1720 | strout (buf, -1, -1, printcharfun, 0); |
ca0569ad RS |
1721 | print_string (XMARKER (OVERLAY_START (obj))->buffer->name, |
1722 | printcharfun); | |
1723 | } | |
1724 | PRINTCHAR ('>'); | |
908b0ae5 | 1725 | break; |
00d76abc KH |
1726 | |
1727 | /* Remaining cases shouldn't happen in normal usage, but let's print | |
1728 | them anyway for the benefit of the debugger. */ | |
1729 | case Lisp_Misc_Free: | |
dc2a0b79 | 1730 | strout ("#<misc free cell>", -1, -1, printcharfun, 0); |
00d76abc KH |
1731 | break; |
1732 | ||
1733 | case Lisp_Misc_Intfwd: | |
1734 | sprintf (buf, "#<intfwd to %d>", *XINTFWD (obj)->intvar); | |
dc2a0b79 | 1735 | strout (buf, -1, -1, printcharfun, 0); |
00d76abc KH |
1736 | break; |
1737 | ||
1738 | case Lisp_Misc_Boolfwd: | |
1739 | sprintf (buf, "#<boolfwd to %s>", | |
1740 | (*XBOOLFWD (obj)->boolvar ? "t" : "nil")); | |
dc2a0b79 | 1741 | strout (buf, -1, -1, printcharfun, 0); |
00d76abc KH |
1742 | break; |
1743 | ||
1744 | case Lisp_Misc_Objfwd: | |
dc2a0b79 | 1745 | strout ("#<objfwd to ", -1, -1, printcharfun, 0); |
00d76abc KH |
1746 | print (*XOBJFWD (obj)->objvar, printcharfun, escapeflag); |
1747 | PRINTCHAR ('>'); | |
1748 | break; | |
1749 | ||
1750 | case Lisp_Misc_Buffer_Objfwd: | |
dc2a0b79 | 1751 | strout ("#<buffer_objfwd to ", -1, -1, printcharfun, 0); |
3ac613c1 KH |
1752 | print (*(Lisp_Object *)((char *)current_buffer |
1753 | + XBUFFER_OBJFWD (obj)->offset), | |
1754 | printcharfun, escapeflag); | |
1755 | PRINTCHAR ('>'); | |
1756 | break; | |
1757 | ||
fb917148 | 1758 | case Lisp_Misc_Kboard_Objfwd: |
dc2a0b79 | 1759 | strout ("#<kboard_objfwd to ", -1, -1, printcharfun, 0); |
fb917148 KH |
1760 | print (*(Lisp_Object *)((char *) current_kboard |
1761 | + XKBOARD_OBJFWD (obj)->offset), | |
7ae137a9 | 1762 | printcharfun, escapeflag); |
00d76abc KH |
1763 | PRINTCHAR ('>'); |
1764 | break; | |
1765 | ||
1766 | case Lisp_Misc_Buffer_Local_Value: | |
dc2a0b79 | 1767 | strout ("#<buffer_local_value ", -1, -1, printcharfun, 0); |
00d76abc KH |
1768 | goto do_buffer_local; |
1769 | case Lisp_Misc_Some_Buffer_Local_Value: | |
dc2a0b79 | 1770 | strout ("#<some_buffer_local_value ", -1, -1, printcharfun, 0); |
00d76abc | 1771 | do_buffer_local: |
dc2a0b79 | 1772 | strout ("[realvalue] ", -1, -1, printcharfun, 0); |
03153771 RS |
1773 | print (XBUFFER_LOCAL_VALUE (obj)->realvalue, printcharfun, escapeflag); |
1774 | if (XBUFFER_LOCAL_VALUE (obj)->found_for_buffer) | |
1775 | strout ("[local in buffer] ", -1, -1, printcharfun, 0); | |
1776 | else | |
1777 | strout ("[buffer] ", -1, -1, printcharfun, 0); | |
1778 | print (XBUFFER_LOCAL_VALUE (obj)->buffer, | |
00d76abc | 1779 | printcharfun, escapeflag); |
03153771 RS |
1780 | if (XBUFFER_LOCAL_VALUE (obj)->check_frame) |
1781 | { | |
1782 | if (XBUFFER_LOCAL_VALUE (obj)->found_for_frame) | |
1783 | strout ("[local in frame] ", -1, -1, printcharfun, 0); | |
1784 | else | |
1785 | strout ("[frame] ", -1, -1, printcharfun, 0); | |
1786 | print (XBUFFER_LOCAL_VALUE (obj)->frame, | |
1787 | printcharfun, escapeflag); | |
1788 | } | |
dc2a0b79 | 1789 | strout ("[alist-elt] ", -1, -1, printcharfun, 0); |
03153771 | 1790 | print (XCONS (XBUFFER_LOCAL_VALUE (obj)->cdr)->car, |
00d76abc | 1791 | printcharfun, escapeflag); |
dc2a0b79 | 1792 | strout ("[default-value] ", -1, -1, printcharfun, 0); |
03153771 | 1793 | print (XCONS (XBUFFER_LOCAL_VALUE (obj)->cdr)->cdr, |
00d76abc KH |
1794 | printcharfun, escapeflag); |
1795 | PRINTCHAR ('>'); | |
1796 | break; | |
1797 | ||
1798 | default: | |
1799 | goto badtype; | |
e0f93814 | 1800 | } |
00d76abc | 1801 | break; |
38010d50 | 1802 | #endif /* standalone */ |
ca0569ad RS |
1803 | |
1804 | default: | |
00d76abc | 1805 | badtype: |
ca0569ad RS |
1806 | { |
1807 | /* We're in trouble if this happens! | |
1808 | Probably should just abort () */ | |
dc2a0b79 | 1809 | strout ("#<EMACS BUG: INVALID DATATYPE ", -1, -1, printcharfun, 0); |
00d76abc | 1810 | if (MISCP (obj)) |
5db20f08 | 1811 | sprintf (buf, "(MISC 0x%04x)", (int) XMISCTYPE (obj)); |
00d76abc KH |
1812 | else if (VECTORLIKEP (obj)) |
1813 | sprintf (buf, "(PVEC 0x%08x)", (int) XVECTOR (obj)->size); | |
1814 | else | |
1815 | sprintf (buf, "(0x%02x)", (int) XTYPE (obj)); | |
dc2a0b79 | 1816 | strout (buf, -1, -1, printcharfun, 0); |
ca0569ad | 1817 | strout (" Save your buffers immediately and please report this bug>", |
dc2a0b79 | 1818 | -1, -1, printcharfun, 0); |
ca0569ad | 1819 | } |
38010d50 JB |
1820 | } |
1821 | ||
1822 | print_depth--; | |
1823 | } | |
1824 | \f | |
7651e1f5 RS |
1825 | #ifdef USE_TEXT_PROPERTIES |
1826 | ||
1827 | /* Print a description of INTERVAL using PRINTCHARFUN. | |
1828 | This is part of printing a string that has text properties. */ | |
1829 | ||
1830 | void | |
1831 | print_interval (interval, printcharfun) | |
1832 | INTERVAL interval; | |
1833 | Lisp_Object printcharfun; | |
1834 | { | |
30503c0b | 1835 | PRINTCHAR (' '); |
7651e1f5 RS |
1836 | print (make_number (interval->position), printcharfun, 1); |
1837 | PRINTCHAR (' '); | |
1838 | print (make_number (interval->position + LENGTH (interval)), | |
1839 | printcharfun, 1); | |
1840 | PRINTCHAR (' '); | |
1841 | print (interval->plist, printcharfun, 1); | |
7651e1f5 RS |
1842 | } |
1843 | ||
1844 | #endif /* USE_TEXT_PROPERTIES */ | |
1845 | \f | |
38010d50 JB |
1846 | void |
1847 | syms_of_print () | |
1848 | { | |
d9c21094 RS |
1849 | Qtemp_buffer_setup_hook = intern ("temp-buffer-setup-hook"); |
1850 | staticpro (&Qtemp_buffer_setup_hook); | |
1851 | ||
38010d50 JB |
1852 | DEFVAR_LISP ("standard-output", &Vstandard_output, |
1853 | "Output stream `print' uses by default for outputting a character.\n\ | |
1854 | This may be any function of one argument.\n\ | |
1855 | It may also be a buffer (output is inserted before point)\n\ | |
1856 | or a marker (output is inserted and the marker is advanced)\n\ | |
113620cc | 1857 | or the symbol t (output appears in the echo area)."); |
38010d50 JB |
1858 | Vstandard_output = Qt; |
1859 | Qstandard_output = intern ("standard-output"); | |
1860 | staticpro (&Qstandard_output); | |
1861 | ||
1862 | #ifdef LISP_FLOAT_TYPE | |
1863 | DEFVAR_LISP ("float-output-format", &Vfloat_output_format, | |
06ef7355 | 1864 | "The format descriptor string used to print floats.\n\ |
38010d50 JB |
1865 | This is a %-spec like those accepted by `printf' in C,\n\ |
1866 | but with some restrictions. It must start with the two characters `%.'.\n\ | |
1867 | After that comes an integer precision specification,\n\ | |
1868 | and then a letter which controls the format.\n\ | |
1869 | The letters allowed are `e', `f' and `g'.\n\ | |
1870 | Use `e' for exponential notation \"DIG.DIGITSeEXPT\"\n\ | |
1871 | Use `f' for decimal point notation \"DIGITS.DIGITS\".\n\ | |
1872 | Use `g' to choose the shorter of those two formats for the number at hand.\n\ | |
1873 | The precision in any of these cases is the number of digits following\n\ | |
1874 | the decimal point. With `f', a precision of 0 means to omit the\n\ | |
c7b14277 | 1875 | decimal point. 0 is not allowed with `e' or `g'.\n\n\ |
f356c3fb PE |
1876 | A value of nil means to use the shortest notation\n\ |
1877 | that represents the number without losing information."); | |
38010d50 JB |
1878 | Vfloat_output_format = Qnil; |
1879 | Qfloat_output_format = intern ("float-output-format"); | |
1880 | staticpro (&Qfloat_output_format); | |
1881 | #endif /* LISP_FLOAT_TYPE */ | |
1882 | ||
1883 | DEFVAR_LISP ("print-length", &Vprint_length, | |
aa734e17 | 1884 | "Maximum length of list to print before abbreviating.\n\ |
38010d50 JB |
1885 | A value of nil means no limit."); |
1886 | Vprint_length = Qnil; | |
1887 | ||
1888 | DEFVAR_LISP ("print-level", &Vprint_level, | |
aa734e17 | 1889 | "Maximum depth of list nesting to print before abbreviating.\n\ |
38010d50 JB |
1890 | A value of nil means no limit."); |
1891 | Vprint_level = Qnil; | |
1892 | ||
1893 | DEFVAR_BOOL ("print-escape-newlines", &print_escape_newlines, | |
a8920a17 | 1894 | "Non-nil means print newlines in strings as backslash-n.\n\ |
c6f7982f | 1895 | Also print formfeeds as backslash-f."); |
38010d50 JB |
1896 | print_escape_newlines = 0; |
1897 | ||
38940e93 | 1898 | DEFVAR_BOOL ("print-escape-nonascii", &print_escape_nonascii, |
835d0be6 RS |
1899 | "Non-nil means print unibyte non-ASCII chars in strings as \\OOO.\n\ |
1900 | \(OOO is the octal representation of the character code.)\n\ | |
96aab770 | 1901 | Only single-byte characters are affected, and only in `prin1'."); |
38940e93 RS |
1902 | print_escape_nonascii = 0; |
1903 | ||
835d0be6 RS |
1904 | DEFVAR_BOOL ("print-escape-multibyte", &print_escape_multibyte, |
1905 | "Non-nil means print multibyte characters in strings as \\xXXXX.\n\ | |
1906 | \(XXX is the hex representation of the character code.)\n\ | |
1907 | This affects only `prin1'."); | |
1908 | print_escape_multibyte = 0; | |
1909 | ||
2f100b5c EN |
1910 | DEFVAR_BOOL ("print-quoted", &print_quoted, |
1911 | "Non-nil means print quoted forms with reader syntax.\n\ | |
1912 | I.e., (quote foo) prints as 'foo, (function foo) as #'foo, and, backquoted\n\ | |
1913 | forms print in the new syntax."); | |
1914 | print_quoted = 0; | |
1915 | ||
e0f69431 | 1916 | DEFVAR_LISP ("print-gensym", &Vprint_gensym, |
081e0581 | 1917 | "Non-nil means print uninterned symbols so they will read as uninterned.\n\ |
265375e7 | 1918 | I.e., the value of (make-symbol \"foobar\") prints as #:foobar.\n\ |
e0f69431 RS |
1919 | When the uninterned symbol appears within a larger data structure,\n\ |
1920 | in addition use the #...# and #...= constructs as needed,\n\ | |
1921 | so that multiple references to the same symbol are shared once again\n\ | |
1922 | when the text is read back.\n\ | |
1923 | \n\ | |
1924 | If the value of `print-gensym' is a cons cell, then in addition refrain from\n\ | |
1925 | clearing `print-gensym-alist' on entry to and exit from printing functions,\n\ | |
1926 | so that the use of #...# and #...= can carry over for several separately\n\ | |
1927 | printed objects."); | |
1928 | Vprint_gensym = Qnil; | |
1929 | ||
1930 | DEFVAR_LISP ("print-gensym-alist", &Vprint_gensym_alist, | |
1931 | "Association list of elements (GENSYM . N) to guide use of #N# and #N=.\n\ | |
1932 | In each element, GENSYM is an uninterned symbol that has been associated\n\ | |
1933 | with #N= for the specified value of N."); | |
1934 | Vprint_gensym_alist = Qnil; | |
081e0581 | 1935 | |
38010d50 JB |
1936 | /* prin1_to_string_buffer initialized in init_buffer_once in buffer.c */ |
1937 | staticpro (&Vprin1_to_string_buffer); | |
1938 | ||
1939 | defsubr (&Sprin1); | |
1940 | defsubr (&Sprin1_to_string); | |
113620cc | 1941 | defsubr (&Serror_message_string); |
38010d50 JB |
1942 | defsubr (&Sprinc); |
1943 | defsubr (&Sprint); | |
1944 | defsubr (&Sterpri); | |
1945 | defsubr (&Swrite_char); | |
1946 | defsubr (&Sexternal_debugging_output); | |
1947 | ||
1948 | Qexternal_debugging_output = intern ("external-debugging-output"); | |
1949 | staticpro (&Qexternal_debugging_output); | |
1950 | ||
2f100b5c EN |
1951 | Qprint_escape_newlines = intern ("print-escape-newlines"); |
1952 | staticpro (&Qprint_escape_newlines); | |
1953 | ||
835d0be6 RS |
1954 | Qprint_escape_multibyte = intern ("print-escape-multibyte"); |
1955 | staticpro (&Qprint_escape_multibyte); | |
1956 | ||
1957 | Qprint_escape_nonascii = intern ("print-escape-nonascii"); | |
1958 | staticpro (&Qprint_escape_nonascii); | |
1959 | ||
38010d50 JB |
1960 | #ifndef standalone |
1961 | defsubr (&Swith_output_to_temp_buffer); | |
1962 | #endif /* not standalone */ | |
1963 | } |