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