0
|
1 /* Lisp object printing and output streams.
|
|
2 Copyright (C) 1985, 1986, 1988, 1992-1995 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995, 1996 Ben Wing.
|
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not synched with FSF. */
|
|
23
|
|
24 /* This file has been Mule-ized. */
|
|
25
|
|
26 /* Seriously hacked on by Ben Wing for Mule. */
|
|
27
|
|
28 #include <config.h>
|
|
29 #include "lisp.h"
|
|
30
|
|
31 #ifndef standalone
|
|
32 #include "backtrace.h"
|
|
33 #include "buffer.h"
|
|
34 #include "bytecode.h"
|
|
35 #include "console-tty.h"
|
|
36 #include "console-stream.h"
|
|
37 #include "extents.h"
|
|
38 #include "frame.h"
|
|
39 #include "emacsfns.h"
|
|
40 #include "insdel.h"
|
|
41 #include "lstream.h"
|
|
42
|
|
43 #endif /* not standalone */
|
|
44
|
149
|
45 static void print_error_message (Lisp_Object data, Lisp_Object stream);
|
|
46
|
0
|
47 Lisp_Object Vstandard_output, Qstandard_output;
|
|
48
|
|
49 /* The subroutine object for external-debugging-output is kept here
|
|
50 for the convenience of the debugger. */
|
|
51 Lisp_Object Qexternal_debugging_output;
|
|
52 Lisp_Object Qalternate_debugging_output;
|
173
|
53
|
0
|
54 /* Avoid actual stack overflow in print. */
|
|
55 static int print_depth;
|
|
56
|
177
|
57 /* Detect most circularities to print finite output. */
|
|
58 #define PRINT_CIRCLE 200
|
|
59 Lisp_Object being_printed[PRINT_CIRCLE];
|
|
60
|
0
|
61 /* Maximum length of list or vector to print in full; noninteger means
|
|
62 effectively infinity */
|
|
63
|
|
64 Lisp_Object Vprint_length;
|
|
65 Lisp_Object Qprint_length;
|
|
66
|
|
67 /* Maximum length of string to print in full; noninteger means
|
|
68 effectively infinity */
|
|
69
|
|
70 Lisp_Object Vprint_string_length;
|
|
71 Lisp_Object Qprint_string_length;
|
|
72
|
|
73 /* Maximum depth of list to print in full; noninteger means
|
|
74 effectively infinity. */
|
|
75
|
|
76 Lisp_Object Vprint_level;
|
|
77
|
|
78 /* Label to use when making echo-area messages. */
|
|
79
|
|
80 Lisp_Object Vprint_message_label;
|
|
81
|
|
82 /* Nonzero means print newlines in strings as \n. */
|
|
83
|
|
84 int print_escape_newlines;
|
|
85 int print_readably;
|
|
86 int print_gensym;
|
|
87
|
|
88 Lisp_Object Qprint_escape_newlines;
|
|
89 Lisp_Object Qprint_readably;
|
|
90
|
171
|
91 Lisp_Object Qdisplay_error;
|
|
92 Lisp_Object Qprint_message_label;
|
|
93
|
0
|
94 /* Force immediate output of all printed data. Used for debugging. */
|
|
95 int print_unbuffered;
|
|
96
|
|
97 FILE *termscript; /* Stdio stream being used for copy of all output. */
|
|
98
|
|
99
|
|
100
|
|
101 int stdout_needs_newline;
|
|
102
|
|
103 /* Write a string (in internal format) to stdio stream STREAM. */
|
173
|
104
|
0
|
105 void
|
|
106 write_string_to_stdio_stream (FILE *stream, struct console *con,
|
|
107 CONST Bufbyte *str,
|
|
108 Bytecount offset, Bytecount len,
|
|
109 enum external_data_format fmt)
|
|
110 {
|
|
111 int extlen;
|
|
112 CONST Extbyte *extptr;
|
|
113
|
|
114 GET_CHARPTR_EXT_DATA_ALLOCA (str + offset, len, fmt, extptr, extlen);
|
|
115 if (stream)
|
|
116 fwrite (extptr, 1, extlen, stream);
|
|
117 else
|
|
118 {
|
|
119 assert (CONSOLE_TTY_P (con));
|
|
120 Lstream_write (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream),
|
|
121 extptr, extlen);
|
|
122 }
|
|
123 if (stream == stdout || stream == stderr ||
|
|
124 (!stream && CONSOLE_TTY_DATA (con)->is_stdio))
|
|
125 {
|
|
126 if (termscript)
|
|
127 {
|
|
128 fwrite (extptr, 1, extlen, termscript);
|
|
129 fflush (termscript);
|
|
130 }
|
|
131 stdout_needs_newline = (extptr[extlen - 1] != '\n');
|
|
132 }
|
|
133 }
|
|
134
|
|
135 /* Write a string to the output location specified in FUNCTION.
|
|
136 Arguments NONRELOC, RELOC, OFFSET, and LEN are as in
|
|
137 buffer_insert_string_1() in insdel.c. */
|
|
138
|
|
139 static void
|
|
140 output_string (Lisp_Object function, CONST Bufbyte *nonreloc,
|
|
141 Lisp_Object reloc, Bytecount offset, Bytecount len)
|
|
142 {
|
|
143 /* This function can GC */
|
|
144 Charcount ccoff, cclen;
|
|
145 /* We change the value of nonreloc (fetching it from reloc as
|
|
146 necessary), but we don't want to pass this changed value on to
|
|
147 other functions that take both a nonreloc and a reloc, or things
|
|
148 may get confused and an assertion failure in
|
|
149 fixup_internal_substring() may get triggered. */
|
|
150 CONST Bufbyte *newnonreloc = nonreloc;
|
|
151 struct gcpro gcpro1, gcpro2;
|
|
152
|
|
153 /* Emacs won't print whilst GCing, but an external debugger might */
|
|
154 if (gc_in_progress) return;
|
|
155
|
|
156 /* Perhaps not necessary but probably safer. */
|
|
157 GCPRO2 (function, reloc);
|
|
158
|
|
159 fixup_internal_substring (newnonreloc, reloc, offset, &len);
|
|
160
|
|
161 if (STRINGP (reloc))
|
16
|
162 newnonreloc = XSTRING_DATA (reloc);
|
0
|
163
|
|
164 ccoff = bytecount_to_charcount (newnonreloc, offset);
|
|
165 cclen = bytecount_to_charcount (newnonreloc + offset, len);
|
|
166
|
|
167 if (LSTREAMP (function))
|
|
168 {
|
|
169 /* Lstream_write() could easily cause GC inside of it, if the
|
|
170 stream is a print-stream. (It will call output_string()
|
|
171 recursively.) This is probably the fastest way to fix this
|
|
172 problem. (alloca() is very fast on machines that have it
|
|
173 built-in, and you avoid some nasty problems with recursion
|
|
174 that could result from using a static buffer somewhere.)
|
|
175
|
|
176 The other possibility is to inhibit GC, but that of course
|
|
177 would require an unwind-protect, which is usually a lot
|
|
178 slower than the small amount of memcpy()ing that happens
|
|
179 here. */
|
|
180 if (STRINGP (reloc))
|
|
181 {
|
|
182 Bufbyte *copied = (Bufbyte *) alloca (len);
|
|
183 memcpy (copied, newnonreloc + offset, len);
|
|
184 Lstream_write (XLSTREAM (function), copied, len);
|
|
185 }
|
|
186 else
|
|
187 Lstream_write (XLSTREAM (function), newnonreloc + offset, len);
|
|
188
|
|
189 if (print_unbuffered)
|
|
190 Lstream_flush (XLSTREAM (function));
|
|
191 }
|
|
192
|
|
193 #ifndef standalone
|
|
194 else if (BUFFERP (function))
|
|
195 {
|
|
196 CHECK_LIVE_BUFFER (function);
|
|
197 buffer_insert_string (XBUFFER (function), nonreloc, reloc, offset, len);
|
|
198 }
|
|
199 else if (MARKERP (function))
|
|
200 {
|
|
201 /* marker_position will err if marker doesn't point anywhere */
|
|
202 Bufpos spoint = marker_position (function);
|
|
203
|
|
204 buffer_insert_string_1 (XBUFFER (Fmarker_buffer (function)),
|
|
205 spoint, nonreloc, reloc, offset, len,
|
|
206 0);
|
|
207 Fset_marker (function, make_int (spoint + cclen),
|
|
208 Fmarker_buffer (function));
|
|
209 }
|
|
210 else if (FRAMEP (function))
|
|
211 {
|
|
212 struct frame *f = XFRAME (function);
|
|
213 if (!EQ (Vprint_message_label, echo_area_status (f)))
|
|
214 clear_echo_area_from_print (f, Qnil, 1);
|
|
215 echo_area_append (f, nonreloc, reloc, offset, len, Vprint_message_label);
|
|
216 }
|
|
217 #endif /* not standalone */
|
|
218 else if (EQ (function, Qt) || EQ (function, Qnil))
|
|
219 {
|
|
220 write_string_to_stdio_stream (stdout, 0, newnonreloc, offset, len,
|
16
|
221 FORMAT_TERMINAL);
|
0
|
222 }
|
|
223 else
|
|
224 {
|
|
225 Charcount iii;
|
|
226
|
|
227 for (iii = ccoff; iii < cclen + ccoff; iii++)
|
|
228 {
|
|
229 call1 (function,
|
|
230 make_char (charptr_emchar_n (newnonreloc, iii)));
|
|
231 if (STRINGP (reloc))
|
16
|
232 newnonreloc = XSTRING_DATA (reloc);
|
0
|
233 }
|
|
234 }
|
|
235
|
|
236 UNGCPRO;
|
|
237 }
|
|
238
|
|
239 struct print_stream
|
|
240 {
|
|
241 FILE *file;
|
|
242 Lisp_Object fun;
|
|
243 };
|
|
244
|
|
245 #define get_print_stream(stream) \
|
|
246 ((struct print_stream *) Lstream_data (stream))
|
|
247
|
|
248 DEFINE_LSTREAM_IMPLEMENTATION ("print", lstream_print,
|
|
249 sizeof (struct print_stream));
|
|
250
|
|
251 static Lisp_Object
|
|
252 make_print_output_stream (FILE *file, Lisp_Object fun)
|
|
253 {
|
|
254 Lstream *str = Lstream_new (lstream_print, "w");
|
|
255 struct print_stream *ps = get_print_stream (str);
|
|
256 Lisp_Object val = Qnil;
|
|
257
|
|
258 Lstream_set_character_mode (str);
|
|
259 ps->file = file;
|
|
260 ps->fun = fun;
|
|
261 XSETLSTREAM (val, str);
|
|
262 return val;
|
|
263 }
|
|
264
|
|
265 /* #### This isn't being used anywhere at the moment. Is it supposed
|
|
266 to be? */
|
|
267 #if 0
|
|
268 static void
|
|
269 reset_print_stream (Lstream *str, FILE *file, Lisp_Object fun)
|
|
270 {
|
|
271 struct print_stream *ps = get_print_stream (str);
|
|
272
|
|
273 Lstream_reopen (str);
|
|
274 ps->file = file;
|
|
275 ps->fun = fun;
|
|
276 }
|
|
277 #endif
|
|
278
|
|
279 static Lisp_Object
|
|
280 print_marker (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
281 {
|
|
282 return get_print_stream (XLSTREAM (obj))->fun;
|
|
283 }
|
|
284
|
|
285 static int
|
|
286 print_writer (Lstream *stream, CONST unsigned char *data, int size)
|
|
287 {
|
|
288 struct print_stream *ps = get_print_stream (stream);
|
|
289
|
|
290 if (ps->file)
|
|
291 {
|
|
292 write_string_to_stdio_stream (ps->file, 0, data, 0, size,
|
16
|
293 FORMAT_TERMINAL);
|
0
|
294 /* Make sure it really gets written now. */
|
|
295 if (print_unbuffered)
|
|
296 fflush (ps->file);
|
|
297 }
|
|
298 else
|
|
299 output_string (ps->fun, data, Qnil, 0, size);
|
|
300 return size;
|
|
301 }
|
|
302
|
|
303 static Lisp_Object
|
|
304 canonicalize_printcharfun (Lisp_Object printcharfun)
|
|
305 {
|
|
306 if (NILP (printcharfun))
|
|
307 printcharfun = Vstandard_output;
|
|
308
|
|
309 if (EQ (printcharfun, Qt) || NILP (printcharfun))
|
|
310 {
|
|
311 #ifndef standalone
|
|
312 printcharfun = Fselected_frame (Qnil); /* print to minibuffer */
|
|
313 #endif
|
|
314 }
|
173
|
315 return printcharfun;
|
0
|
316 }
|
|
317
|
|
318
|
|
319 static Lisp_Object
|
|
320 print_prepare (Lisp_Object printcharfun)
|
|
321 {
|
|
322 FILE *stdio_stream = 0;
|
|
323
|
|
324 /* Emacs won't print whilst GCing, but an external debugger might */
|
|
325 if (gc_in_progress)
|
173
|
326 return Qnil;
|
0
|
327
|
|
328 printcharfun = canonicalize_printcharfun (printcharfun);
|
|
329 if (EQ (printcharfun, Qnil))
|
|
330 {
|
|
331 stdio_stream = stdout;
|
|
332 }
|
|
333 #if 0 /* Don't bother */
|
|
334 else if (SUBRP (indirect_function (printcharfun, 0))
|
173
|
335 && (XSUBR (indirect_function (printcharfun, 0))
|
0
|
336 == Sexternal_debugging_output))
|
|
337 {
|
|
338 stdio_stream = stderr;
|
|
339 }
|
|
340 #endif
|
173
|
341
|
0
|
342 return make_print_output_stream (stdio_stream, printcharfun);
|
|
343 }
|
|
344
|
|
345 static void
|
|
346 print_finish (Lisp_Object stream)
|
|
347 {
|
|
348 /* Emacs won't print whilst GCing, but an external debugger might */
|
|
349 if (gc_in_progress)
|
|
350 return;
|
|
351
|
|
352 Lstream_delete (XLSTREAM (stream));
|
|
353 }
|
|
354
|
|
355 #if 1 /* Prefer space over "speed" */
|
|
356 #define write_char_internal(string_of_length_1, stream) \
|
|
357 write_string_1 ((CONST Bufbyte *) (string_of_length_1), 1, (stream))
|
|
358 #else
|
|
359 #define write_char_internal(string_of_length_1, stream) \
|
|
360 output_string ((stream), (CONST Bufbyte *) (string_of_length_1), Qnil, 0, 1)
|
|
361 #endif
|
|
362
|
|
363 /* NOTE: Do not call this with the data of a Lisp_String,
|
|
364 * as printcharfun might cause a GC, which might cause
|
|
365 * the string's data to be relocated.
|
|
366 * Use print_object_internal (string, printcharfun, 0)
|
|
367 * to princ a Lisp_String
|
|
368 * Note: "stream" should be the result of "canonicalize_printcharfun"
|
|
369 * (ie Qnil means stdout, not Vstandard_output, etc)
|
|
370 */
|
|
371 void
|
|
372 write_string_1 (CONST Bufbyte *str, Bytecount size, Lisp_Object stream)
|
|
373 {
|
|
374 /* This function can GC */
|
|
375 assert (size >= 0);
|
|
376 output_string (stream, str, Qnil, 0, size);
|
|
377 }
|
|
378
|
|
379 void
|
|
380 write_c_string (CONST char *str, Lisp_Object stream)
|
|
381 {
|
|
382 /* This function can GC */
|
|
383 write_string_1 ((CONST Bufbyte *) str, strlen (str), stream);
|
|
384 }
|
|
385
|
|
386
|
20
|
387 DEFUN ("write-char", Fwrite_char, 1, 2, 0, /*
|
0
|
388 Output character CH to stream STREAM.
|
|
389 STREAM defaults to the value of `standard-output' (which see).
|
20
|
390 */
|
|
391 (ch, stream))
|
0
|
392 {
|
|
393 /* This function can GC */
|
|
394 Bufbyte str[MAX_EMCHAR_LEN];
|
|
395 Bytecount len;
|
|
396
|
|
397 CHECK_CHAR_COERCE_INT (ch);
|
|
398 len = set_charptr_emchar (str, XCHAR (ch));
|
|
399 output_string (canonicalize_printcharfun (stream), str, Qnil, 0, len);
|
|
400 return ch;
|
|
401 }
|
|
402
|
|
403 #ifndef standalone
|
|
404
|
|
405 void
|
|
406 temp_output_buffer_setup (CONST char *bufname)
|
|
407 {
|
|
408 /* This function can GC */
|
|
409 struct buffer *old = current_buffer;
|
|
410 Lisp_Object buf;
|
|
411
|
|
412 #ifdef I18N3
|
|
413 /* #### This function should accept a Lisp_Object instead of a char *,
|
|
414 so that proper translation on the buffer name can occur. */
|
|
415 #endif
|
|
416
|
|
417 Fset_buffer (Fget_buffer_create (build_string (bufname)));
|
|
418
|
|
419 current_buffer->read_only = Qnil;
|
|
420 Ferase_buffer (Fcurrent_buffer ());
|
|
421
|
|
422 XSETBUFFER (buf, current_buffer);
|
|
423 specbind (Qstandard_output, buf);
|
|
424
|
|
425 set_buffer_internal (old);
|
|
426 }
|
|
427
|
|
428 Lisp_Object
|
173
|
429 internal_with_output_to_temp_buffer (CONST char *bufname,
|
0
|
430 Lisp_Object (*function) (Lisp_Object arg),
|
173
|
431 Lisp_Object arg,
|
0
|
432 Lisp_Object same_frame)
|
|
433 {
|
|
434 int speccount = specpdl_depth ();
|
|
435 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
436 Lisp_Object buf = Qnil;
|
|
437
|
|
438 GCPRO3 (buf, arg, same_frame);
|
|
439
|
|
440 temp_output_buffer_setup (GETTEXT (bufname));
|
|
441 buf = Vstandard_output;
|
|
442
|
|
443 arg = (*function) (arg);
|
|
444
|
|
445 temp_output_buffer_show (buf, same_frame);
|
|
446 UNGCPRO;
|
|
447
|
|
448 return unbind_to (speccount, arg);
|
|
449 }
|
|
450
|
20
|
451 DEFUN ("with-output-to-temp-buffer", Fwith_output_to_temp_buffer, 1, UNEVALLED, 0, /*
|
0
|
452 Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer.
|
|
453 The buffer is cleared out initially, and marked as unmodified when done.
|
|
454 All output done by BODY is inserted in that buffer by default.
|
|
455 The buffer is displayed in another window, but not selected.
|
|
456 The value of the last form in BODY is returned.
|
|
457 If BODY does not finish normally, the buffer BUFNAME is not displayed.
|
|
458
|
|
459 If variable `temp-buffer-show-function' is non-nil, call it at the end
|
|
460 to get the buffer displayed. It gets one argument, the buffer to display.
|
20
|
461 */
|
|
462 (args))
|
0
|
463 {
|
|
464 /* This function can GC */
|
|
465 struct gcpro gcpro1;
|
|
466 Lisp_Object name;
|
|
467 int speccount = specpdl_depth ();
|
|
468 Lisp_Object buf, val;
|
|
469
|
|
470 #ifdef I18N3
|
|
471 /* #### should set the buffer to be translating. See print_internal(). */
|
|
472 #endif
|
|
473
|
|
474 GCPRO1 (args);
|
|
475 name = Feval (Fcar (args));
|
|
476 UNGCPRO;
|
|
477
|
|
478 CHECK_STRING (name);
|
16
|
479 temp_output_buffer_setup ((char *) XSTRING_DATA (name));
|
0
|
480 buf = Vstandard_output;
|
|
481
|
|
482 val = Fprogn (Fcdr (args));
|
|
483
|
|
484 temp_output_buffer_show (buf, Qnil);
|
|
485
|
|
486 return unbind_to (speccount, val);
|
|
487 }
|
|
488 #endif /* not standalone */
|
|
489
|
20
|
490 DEFUN ("terpri", Fterpri, 0, 1, 0, /*
|
0
|
491 Output a newline to STREAM.
|
|
492 If STREAM is omitted or nil, the value of `standard-output' is used.
|
20
|
493 */
|
|
494 (stream))
|
0
|
495 {
|
|
496 /* This function can GC */
|
|
497 Bufbyte str[1];
|
|
498 str[0] = '\n';
|
|
499 output_string (canonicalize_printcharfun (stream), str, Qnil, 0, 1);
|
|
500 return Qt;
|
|
501 }
|
|
502
|
20
|
503 DEFUN ("prin1", Fprin1, 1, 2, 0, /*
|
0
|
504 Output the printed representation of OBJECT, any Lisp object.
|
|
505 Quoting characters are printed when needed to make output that `read'
|
|
506 can handle, whenever this is possible.
|
|
507 Output stream is STREAM, or value of `standard-output' (which see).
|
20
|
508 */
|
|
509 (object, stream))
|
0
|
510 {
|
|
511 /* This function can GC */
|
|
512 Lisp_Object the_stream = Qnil;
|
|
513 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
514
|
|
515 GCPRO3 (object, stream, the_stream);
|
|
516 print_depth = 0;
|
|
517 the_stream = print_prepare (stream);
|
|
518 print_internal (object, the_stream, 1);
|
|
519 print_finish (the_stream);
|
|
520 UNGCPRO;
|
|
521 return object;
|
|
522 }
|
|
523
|
|
524 /* a buffer which is used to hold output being built by prin1-to-string */
|
|
525 Lisp_Object Vprin1_to_string_buffer;
|
|
526
|
20
|
527 DEFUN ("prin1-to-string", Fprin1_to_string, 1, 2, 0, /*
|
0
|
528 Return a string containing the printed representation of OBJECT,
|
|
529 any Lisp object. Quoting characters are used when needed to make output
|
|
530 that `read' can handle, whenever this is possible, unless the optional
|
|
531 second argument NOESCAPE is non-nil.
|
20
|
532 */
|
|
533 (object, noescape))
|
0
|
534 {
|
|
535 /* This function can GC */
|
|
536 Lisp_Object old = Fcurrent_buffer ();
|
|
537 struct buffer *out = XBUFFER (Vprin1_to_string_buffer);
|
|
538 Lisp_Object stream = Qnil;
|
|
539 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
540
|
|
541 GCPRO3 (object, old, stream);
|
|
542 stream = print_prepare (Vprin1_to_string_buffer);
|
|
543 set_buffer_internal (out);
|
|
544 Ferase_buffer (Fcurrent_buffer ());
|
|
545 print_depth = 0;
|
|
546 print_internal (object, stream, NILP (noescape));
|
|
547 print_finish (stream);
|
|
548 stream = Qnil; /* No GC surprises! */
|
173
|
549 object = make_string_from_buffer (out,
|
0
|
550 BUF_BEG (out),
|
|
551 BUF_Z (out) - 1);
|
|
552 Ferase_buffer (Fcurrent_buffer ());
|
|
553 Fset_buffer (old);
|
|
554 UNGCPRO;
|
173
|
555 return object;
|
0
|
556 }
|
|
557
|
20
|
558 DEFUN ("princ", Fprinc, 1, 2, 0, /*
|
0
|
559 Output the printed representation of OBJECT, any Lisp object.
|
|
560 No quoting characters are used; no delimiters are printed around
|
|
561 the contents of strings.
|
|
562 Output stream is STREAM, or value of standard-output (which see).
|
20
|
563 */
|
|
564 (obj, stream))
|
0
|
565 {
|
|
566 /* This function can GC */
|
|
567 Lisp_Object the_stream = Qnil;
|
|
568 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
569
|
|
570 GCPRO3 (obj, stream, the_stream);
|
|
571 the_stream = print_prepare (stream);
|
|
572 print_depth = 0;
|
|
573 print_internal (obj, the_stream, 0);
|
|
574 print_finish (the_stream);
|
|
575 UNGCPRO;
|
173
|
576 return obj;
|
0
|
577 }
|
|
578
|
20
|
579 DEFUN ("print", Fprint, 1, 2, 0, /*
|
0
|
580 Output the printed representation of OBJECT, with newlines around it.
|
|
581 Quoting characters are printed when needed to make output that `read'
|
|
582 can handle, whenever this is possible.
|
|
583 Output stream is STREAM, or value of `standard-output' (which see).
|
20
|
584 */
|
|
585 (obj, stream))
|
0
|
586 {
|
|
587 /* This function can GC */
|
|
588 Lisp_Object the_stream = Qnil;
|
|
589 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
590
|
|
591 GCPRO3 (obj, stream, the_stream);
|
|
592 the_stream = print_prepare (stream);
|
|
593 print_depth = 0;
|
|
594 write_char_internal ("\n", the_stream);
|
|
595 print_internal (obj, the_stream, 1);
|
|
596 write_char_internal ("\n", the_stream);
|
|
597 print_finish (the_stream);
|
|
598 UNGCPRO;
|
|
599 return obj;
|
|
600 }
|
|
601
|
100
|
602 #include "emacsfns.h"
|
171
|
603
|
|
604 /* Synched with Emacs 19.34 -- underlying implementation (incarnated
|
|
605 in print_error_message) is completely divergent, though. */
|
100
|
606 DEFUN ("error-message-string", Ferror_message_string, 1, 1, 0, /*
|
|
607 Convert an error value (ERROR-SYMBOL . DATA) to an error message.
|
|
608 */
|
167
|
609 (data))
|
100
|
610 {
|
171
|
611 /* This function can GC */
|
167
|
612 struct buffer *pbuf;
|
171
|
613 Lisp_Object value;
|
100
|
614 struct gcpro gcpro1;
|
|
615
|
167
|
616 print_error_message (data, Vprin1_to_string_buffer);
|
100
|
617
|
167
|
618 pbuf = XBUFFER (Vprin1_to_string_buffer);
|
|
619 value = make_string_from_buffer (pbuf,
|
|
620 BUF_BEGV (pbuf),
|
|
621 BUF_ZV (pbuf) - BUF_BEGV (pbuf));
|
100
|
622 GCPRO1 (value);
|
167
|
623 Ferase_buffer (Vprin1_to_string_buffer);
|
100
|
624 UNGCPRO;
|
|
625
|
|
626 return value;
|
|
627 }
|
|
628
|
171
|
629 /* Print an error message for the error DATA onto Lisp output stream
|
|
630 STREAM (suitable for the print functions).
|
100
|
631
|
171
|
632 This is a complete implementation of `display-error', which used to
|
|
633 be in Lisp (see prim/cmdloop.el). It was ported to C so we can use
|
|
634 it in Ferror_message_string. Fdisplay_error and
|
|
635 Ferror_message_string are trivial wrappers to this function. */
|
|
636 static void
|
|
637 print_error_message (Lisp_Object error_object, Lisp_Object stream)
|
100
|
638 {
|
171
|
639 /* This function can GC */
|
|
640 Lisp_Object type;
|
|
641 Lisp_Object method = Qnil;
|
|
642 Lisp_Object tail = Qnil;
|
100
|
643 struct gcpro gcpro1;
|
171
|
644
|
|
645 GCPRO1 (tail);
|
|
646
|
|
647 type = Fcar_safe (error_object);
|
|
648
|
|
649 if (! (CONSP (error_object) && SYMBOLP (type)
|
|
650 && CONSP (Fget (type, Qerror_conditions, Qnil))))
|
|
651 goto error_throw;
|
100
|
652
|
171
|
653 tail = XCDR (error_object);
|
|
654 while (!NILP (tail))
|
|
655 {
|
|
656 if (CONSP (tail))
|
|
657 tail = XCDR (tail);
|
|
658 else
|
|
659 goto error_throw;
|
|
660 }
|
|
661 tail = Fget (type, Qerror_conditions, Qnil);
|
|
662 while (!NILP (tail))
|
100
|
663 {
|
171
|
664 if (!(CONSP (tail) && SYMBOLP (XCAR (tail))))
|
|
665 goto error_throw;
|
|
666 else if (!NILP (Fget (XCAR (tail), Qdisplay_error, Qnil)))
|
|
667 {
|
|
668 method = Fget (XCAR (tail), Qdisplay_error, Qnil);
|
|
669 goto error_throw;
|
|
670 }
|
|
671 else
|
|
672 tail = XCDR (tail);
|
|
673 }
|
|
674 /* Default method */
|
|
675 {
|
|
676 int first = 1;
|
|
677 Lisp_Object printcharfun = canonicalize_printcharfun (stream);
|
|
678 int speccount = specpdl_depth ();
|
|
679
|
|
680 specbind (Qprint_message_label, Qerror);
|
|
681 tail = Fcdr (error_object);
|
|
682 if (EQ (type, Qerror))
|
|
683 {
|
|
684 Fprinc (Fcar (tail), stream);
|
|
685 tail = Fcdr (tail);
|
|
686 }
|
|
687 else
|
|
688 {
|
|
689 Lisp_Object errmsg = Fget (type, Qerror_message, Qnil);
|
|
690 if (NILP (errmsg))
|
|
691 Fprinc (type, stream);
|
|
692 else
|
|
693 Fprinc (errmsg, stream);
|
|
694 }
|
|
695 while (!NILP (tail))
|
|
696 {
|
|
697 write_c_string (first ? ": " : ", ", printcharfun);
|
|
698 Fprin1 (Fcar (tail), stream);
|
|
699 tail = Fcdr (tail);
|
|
700 first = 0;
|
|
701 }
|
|
702 unbind_to (speccount, Qnil);
|
|
703 UNGCPRO;
|
|
704 return;
|
|
705 /* Unreached */
|
|
706 }
|
|
707
|
|
708 error_throw:
|
|
709 UNGCPRO;
|
|
710 if (NILP (method))
|
|
711 {
|
|
712 write_c_string ("Peculiar error ",
|
|
713 canonicalize_printcharfun (stream));
|
|
714 Fprin1 (error_object, stream);
|
|
715 return;
|
100
|
716 }
|
|
717 else
|
|
718 {
|
171
|
719 call2 (method, error_object, stream);
|
100
|
720 }
|
171
|
721 }
|
100
|
722
|
171
|
723 DEFUN ("display-error", Fdisplay_error, 2, 2, 0, /*
|
|
724 Display an error message for ERROR-OBJECT to STREAM.
|
|
725 */
|
|
726 (error_object, stream))
|
|
727 {
|
|
728 /* This function can GC */
|
|
729 print_error_message (error_object, stream);
|
|
730 return Qnil;
|
|
731 }
|
100
|
732
|
|
733
|
0
|
734 #ifdef LISP_FLOAT_TYPE
|
|
735
|
|
736 Lisp_Object Vfloat_output_format;
|
|
737 Lisp_Object Qfloat_output_format;
|
|
738
|
|
739 void
|
|
740 float_to_string (char *buf, double data)
|
|
741 /*
|
|
742 * This buffer should be at least as large as the max string size of the
|
|
743 * largest float, printed in the biggest notation. This is undoubtably
|
|
744 * 20d float_output_format, with the negative of the C-constant "HUGE"
|
|
745 * from <math.h>.
|
173
|
746 *
|
0
|
747 * On the vax the worst case is -1e38 in 20d format which takes 61 bytes.
|
173
|
748 *
|
0
|
749 * I assume that IEEE-754 format numbers can take 329 bytes for the worst
|
|
750 * case of -1e307 in 20d float_output_format. What is one to do (short of
|
|
751 * re-writing _doprnt to be more sane)?
|
|
752 * -wsr
|
|
753 */
|
|
754 {
|
|
755 Bufbyte *cp, c;
|
|
756 int width;
|
173
|
757
|
0
|
758 if (NILP (Vfloat_output_format)
|
|
759 || !STRINGP (Vfloat_output_format))
|
|
760 lose:
|
|
761 sprintf (buf, "%.16g", data);
|
|
762 else /* oink oink */
|
|
763 {
|
|
764 /* Check that the spec we have is fully valid.
|
|
765 This means not only valid for printf,
|
|
766 but meant for floats, and reasonable. */
|
16
|
767 cp = XSTRING_DATA (Vfloat_output_format);
|
0
|
768
|
|
769 if (cp[0] != '%')
|
|
770 goto lose;
|
|
771 if (cp[1] != '.')
|
|
772 goto lose;
|
|
773
|
|
774 cp += 2;
|
|
775 for (width = 0; (c = *cp, isdigit (c)); cp++)
|
|
776 {
|
|
777 width *= 10;
|
|
778 width += c - '0';
|
|
779 }
|
|
780
|
173
|
781 if (*cp != 'e' && *cp != 'f' && *cp != 'g' && *cp != 'E' && *cp != 'G')
|
0
|
782 goto lose;
|
|
783
|
|
784 if (width < (int) (*cp != 'e' && *cp != 'E') || width > DBL_DIG)
|
|
785 goto lose;
|
|
786
|
|
787 if (cp[1] != 0)
|
|
788 goto lose;
|
|
789
|
16
|
790 sprintf (buf, (char *) XSTRING_DATA (Vfloat_output_format),
|
0
|
791 data);
|
|
792 }
|
|
793
|
|
794 /* added by jwz: don't allow "1.0" to print as "1"; that destroys
|
|
795 the read-equivalence of lisp objects. (* x 1) and (* x 1.0) do
|
|
796 not do the same thing, so it's important that the printed
|
|
797 representation of that form not be corrupted by the printer.
|
|
798 */
|
|
799 {
|
|
800 Bufbyte *s = (Bufbyte *) buf; /* don't use signed chars here!
|
|
801 isdigit() can't hack them! */
|
|
802 if (*s == '-') s++;
|
|
803 for (; *s; s++)
|
|
804 /* if there's a non-digit, then there is a decimal point, or
|
|
805 it's in exponential notation, both of which are ok. */
|
|
806 if (!isdigit (*s))
|
|
807 goto DONE_LABEL;
|
|
808 /* otherwise, we need to hack it. */
|
|
809 *s++ = '.';
|
|
810 *s++ = '0';
|
|
811 *s = 0;
|
|
812 }
|
|
813 DONE_LABEL:
|
|
814
|
|
815 /* Some machines print "0.4" as ".4". I don't like that. */
|
|
816 if (buf [0] == '.' || (buf [0] == '-' && buf [1] == '.'))
|
|
817 {
|
|
818 int i;
|
|
819 for (i = strlen (buf) + 1; i >= 0; i--)
|
|
820 buf [i+1] = buf [i];
|
|
821 buf [(buf [0] == '-' ? 1 : 0)] = '0';
|
|
822 }
|
|
823 }
|
|
824 #endif /* LISP_FLOAT_TYPE */
|
|
825
|
|
826 static void
|
|
827 print_vector_internal (CONST char *start, CONST char *end,
|
173
|
828 Lisp_Object obj,
|
0
|
829 Lisp_Object printcharfun, int escapeflag)
|
|
830 {
|
|
831 /* This function can GC */
|
|
832 int i;
|
173
|
833 int len = XVECTOR_LENGTH (obj);
|
0
|
834 int last = len;
|
|
835 struct gcpro gcpro1, gcpro2;
|
|
836 GCPRO2 (obj, printcharfun);
|
|
837
|
|
838 if (INTP (Vprint_length))
|
|
839 {
|
|
840 int max = XINT (Vprint_length);
|
|
841 if (max < len) last = max;
|
|
842 }
|
|
843
|
|
844 write_c_string (start, printcharfun);
|
|
845 for (i = 0; i < last; i++)
|
|
846 {
|
173
|
847 Lisp_Object elt = XVECTOR_DATA (obj)[i];
|
0
|
848 if (i != 0) write_char_internal (" ", printcharfun);
|
|
849 print_internal (elt, printcharfun, escapeflag);
|
|
850 }
|
|
851 UNGCPRO;
|
|
852 if (last != len)
|
|
853 write_c_string (" ...", printcharfun);
|
|
854 write_c_string (end, printcharfun);
|
|
855 }
|
|
856
|
|
857 static void
|
|
858 default_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
|
|
859 int escapeflag)
|
|
860 {
|
|
861 struct lcrecord_header *header =
|
|
862 (struct lcrecord_header *) XPNTR (obj);
|
|
863 char buf[200];
|
|
864
|
|
865 if (print_readably)
|
|
866 error ("printing unreadable object #<%s 0x%x>",
|
|
867 header->lheader.implementation->name, header->uid);
|
|
868
|
|
869 sprintf (buf, "#<%s 0x%x>", header->lheader.implementation->name,
|
|
870 header->uid);
|
|
871 write_c_string (buf, printcharfun);
|
|
872 }
|
|
873
|
|
874 void
|
|
875 internal_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
|
|
876 int escapeflag)
|
|
877 {
|
|
878 char buf[200];
|
173
|
879 sprintf (buf, "#<INTERNAL OBJECT (XEmacs bug?) (%s) 0x%p>",
|
183
|
880 XRECORD_LHEADER (obj)->implementation->name,
|
173
|
881 (void *) XPNTR (obj));
|
0
|
882 write_c_string (buf, printcharfun);
|
|
883 }
|
|
884
|
|
885 void
|
|
886 print_internal (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
887 {
|
|
888 /* This function can GC */
|
|
889 char buf[256];
|
|
890
|
|
891 QUIT;
|
|
892
|
|
893 /* Emacs won't print whilst GCing, but an external debugger might */
|
|
894 if (gc_in_progress) return;
|
|
895
|
|
896 #ifdef I18N3
|
|
897 /* #### Both input and output streams should have a flag associated
|
|
898 with them indicating whether output to that stream, or strings
|
|
899 read from the stream, get translated using Fgettext(). Such a
|
|
900 stream is called a "translating stream". For the minibuffer and
|
|
901 external-debugging-output this is always true on output, and
|
|
902 with-output-to-temp-buffer sets the flag to true for the buffer
|
|
903 it creates. This flag should also be user-settable. Perhaps it
|
|
904 should be split up into two flags, one for input and one for
|
|
905 output. */
|
|
906 #endif
|
|
907
|
177
|
908 /* Detect circularities and truncate them.
|
|
909 No need to offer any alternative--this is better than an error. */
|
|
910 if (CONSP (obj) || VECTORP (obj) || COMPILED_FUNCTIONP (obj))
|
|
911 {
|
|
912 int i;
|
|
913 for (i = 0; i < print_depth; i++)
|
|
914 if (EQ (obj, being_printed[i]))
|
|
915 {
|
|
916 sprintf (buf, "#%d", i);
|
|
917 write_c_string (buf, printcharfun);
|
|
918 return;
|
|
919 }
|
|
920 }
|
|
921
|
|
922
|
|
923 being_printed[print_depth] = obj;
|
0
|
924 print_depth++;
|
|
925
|
177
|
926 if (print_depth > PRINT_CIRCLE)
|
0
|
927 error ("Apparently circular structure being printed");
|
|
928
|
|
929 switch (XTYPE (obj))
|
|
930 {
|
185
|
931 case Lisp_Type_Int:
|
0
|
932 {
|
173
|
933 sprintf (buf, "%ld", (long) XINT (obj));
|
0
|
934 write_c_string (buf, printcharfun);
|
|
935 break;
|
|
936 }
|
|
937
|
185
|
938 case Lisp_Type_Char:
|
70
|
939 {
|
|
940 /* God intended that this be #\..., you know. */
|
|
941 Emchar ch = XCHAR (obj);
|
|
942 write_c_string ("?", printcharfun);
|
|
943 if (ch == '\n')
|
|
944 strcpy (buf, "\\n");
|
|
945 else if (ch == '\r')
|
|
946 strcpy (buf, "\\r");
|
|
947 else if (ch == '\t')
|
|
948 strcpy (buf, "\\t");
|
187
|
949 else if (ch < 32) {
|
70
|
950 sprintf (buf, "\\^%c", ch + 64);
|
187
|
951 if ((ch + 64) == '\\') {
|
|
952 strcat(buf, "\\");
|
|
953 }
|
|
954 } else if (ch == 127)
|
70
|
955 strcpy (buf, "\\^?");
|
|
956 else if (ch >= 128 && ch < 160)
|
|
957 {
|
|
958 Bytecount i;
|
|
959 strcpy (buf, "\\^");
|
|
960 i = set_charptr_emchar ((unsigned char *) (buf + 2), ch + 64);
|
|
961 buf[2+i] = '\0';
|
|
962 }
|
|
963 else if (ch < 127
|
|
964 && !isdigit (ch)
|
|
965 && !isalpha (ch)
|
|
966 && ch != '^') /* must not backslash this or it will
|
|
967 be interpreted as the start of a
|
|
968 control char */
|
|
969 sprintf (buf, "\\%c", ch);
|
|
970 else
|
|
971 {
|
|
972 Bytecount i;
|
|
973 i = set_charptr_emchar ((unsigned char *) buf, ch);
|
|
974 buf[i] = '\0';
|
|
975 }
|
|
976 write_c_string (buf, printcharfun);
|
|
977 break;
|
|
978 }
|
|
979
|
185
|
980 case Lisp_Type_String:
|
0
|
981 {
|
16
|
982 Bytecount size = XSTRING_LENGTH (obj);
|
0
|
983 struct gcpro gcpro1, gcpro2;
|
|
984 int max = size;
|
|
985 GCPRO2 (obj, printcharfun);
|
|
986
|
|
987 if (INTP (Vprint_string_length) &&
|
|
988 XINT (Vprint_string_length) < max)
|
|
989 max = XINT (Vprint_string_length);
|
|
990 if (max < 0)
|
|
991 max = 0;
|
|
992
|
|
993 /* !!#### This handles MAX incorrectly for Mule. */
|
|
994 if (!escapeflag)
|
|
995 {
|
|
996 /* This deals with GC-relocation */
|
|
997 output_string (printcharfun, 0, obj, 0, max);
|
|
998 if (max < size)
|
|
999 write_c_string (" ...", printcharfun);
|
|
1000 }
|
|
1001 else
|
|
1002 {
|
|
1003 Bytecount i;
|
|
1004 struct Lisp_String *s = XSTRING (obj);
|
|
1005 Bytecount last = 0;
|
|
1006
|
|
1007 write_char_internal ("\"", printcharfun);
|
|
1008 for (i = 0; i < max; i++)
|
|
1009 {
|
|
1010 Bufbyte ch = string_byte (s, i);
|
173
|
1011 if (ch == '\"' || ch == '\\'
|
0
|
1012 || (ch == '\n' && print_escape_newlines))
|
|
1013 {
|
|
1014 if (i > last)
|
|
1015 {
|
|
1016 output_string (printcharfun, 0, obj, last,
|
|
1017 i - last);
|
|
1018 }
|
|
1019 if (ch == '\n')
|
|
1020 {
|
|
1021 write_c_string ("\\n", printcharfun);
|
|
1022 }
|
|
1023 else
|
|
1024 {
|
|
1025 write_char_internal ("\\", printcharfun);
|
|
1026 /* This is correct for Mule because the
|
|
1027 character is either \ or " */
|
|
1028 write_char_internal ((char *) (string_data (s) + i),
|
|
1029 printcharfun);
|
|
1030 }
|
|
1031 last = i + 1;
|
|
1032 }
|
|
1033 }
|
|
1034 if (max > last)
|
|
1035 {
|
|
1036 output_string (printcharfun, 0, obj, last,
|
|
1037 max - last);
|
|
1038 }
|
|
1039 if (max < size)
|
|
1040 write_c_string (" ...", printcharfun);
|
|
1041 write_char_internal ("\"", printcharfun);
|
|
1042 }
|
|
1043 UNGCPRO;
|
|
1044 break;
|
|
1045 }
|
|
1046
|
185
|
1047 case Lisp_Type_Cons:
|
0
|
1048 {
|
|
1049 struct gcpro gcpro1, gcpro2;
|
|
1050
|
|
1051 /* If deeper than spec'd depth, print placeholder. */
|
|
1052 if (INTP (Vprint_level)
|
|
1053 && print_depth > XINT (Vprint_level))
|
|
1054 {
|
|
1055 write_c_string ("...", printcharfun);
|
|
1056 break;
|
|
1057 }
|
|
1058
|
|
1059 /* If print_readably is on, print (quote -foo-) as '-foo-
|
|
1060 (Yeah, this should really be what print-pretty does, but we
|
|
1061 don't have the rest of a pretty printer, and this actually
|
|
1062 has non-negligible impact on size/speed of .elc files.)
|
|
1063 */
|
|
1064 if (print_readably &&
|
|
1065 EQ (XCAR (obj), Qquote) &&
|
|
1066 CONSP (XCDR (obj)) &&
|
|
1067 NILP (XCDR (XCDR (obj))))
|
|
1068 {
|
|
1069 obj = XCAR (XCDR (obj));
|
|
1070 GCPRO2 (obj, printcharfun);
|
|
1071 write_char_internal ("'", printcharfun);
|
|
1072 UNGCPRO;
|
|
1073 print_internal (obj, printcharfun, escapeflag);
|
|
1074 break;
|
|
1075 }
|
|
1076
|
|
1077 GCPRO2 (obj, printcharfun);
|
|
1078 write_char_internal ("(", printcharfun);
|
|
1079 {
|
|
1080 int i = 0;
|
|
1081 int max = 0;
|
|
1082
|
|
1083 if (INTP (Vprint_length))
|
|
1084 max = XINT (Vprint_length);
|
|
1085 while (CONSP (obj))
|
|
1086 {
|
|
1087 if (i++)
|
|
1088 write_char_internal (" ", printcharfun);
|
|
1089 if (max && i > max)
|
|
1090 {
|
|
1091 write_c_string ("...", printcharfun);
|
|
1092 break;
|
|
1093 }
|
|
1094 print_internal (Fcar (obj), printcharfun,
|
|
1095 escapeflag);
|
|
1096 obj = Fcdr (obj);
|
|
1097 }
|
|
1098 }
|
|
1099 if (!NILP (obj) && !CONSP (obj))
|
|
1100 {
|
|
1101 write_c_string (" . ", printcharfun);
|
|
1102 print_internal (obj, printcharfun, escapeflag);
|
|
1103 }
|
|
1104 UNGCPRO;
|
|
1105 write_char_internal (")", printcharfun);
|
|
1106 break;
|
|
1107 }
|
|
1108
|
|
1109 #ifndef LRECORD_VECTOR
|
185
|
1110 case Lisp_Type_Vector:
|
0
|
1111 {
|
|
1112 /* If deeper than spec'd depth, print placeholder. */
|
|
1113 if (INTP (Vprint_level)
|
|
1114 && print_depth > XINT (Vprint_level))
|
|
1115 {
|
|
1116 write_c_string ("...", printcharfun);
|
|
1117 break;
|
|
1118 }
|
|
1119
|
|
1120 /* God intended that this be #(...), you know. */
|
|
1121 print_vector_internal ("[", "]", obj, printcharfun, escapeflag);
|
|
1122 break;
|
|
1123 }
|
|
1124 #endif /* !LRECORD_VECTOR */
|
|
1125
|
|
1126 #ifndef LRECORD_SYMBOL
|
185
|
1127 case Lisp_Type_Symbol:
|
0
|
1128 {
|
|
1129 print_symbol (obj, printcharfun, escapeflag);
|
|
1130 break;
|
|
1131 }
|
|
1132 #endif /* !LRECORD_SYMBOL */
|
|
1133
|
185
|
1134 case Lisp_Type_Record:
|
0
|
1135 {
|
|
1136 struct lrecord_header *lheader = XRECORD_LHEADER (obj);
|
|
1137 struct gcpro gcpro1, gcpro2;
|
|
1138
|
|
1139 GCPRO2 (obj, printcharfun);
|
|
1140 if (lheader->implementation->printer)
|
|
1141 ((lheader->implementation->printer)
|
|
1142 (obj, printcharfun, escapeflag));
|
|
1143 else
|
|
1144 default_object_printer (obj, printcharfun, escapeflag);
|
|
1145 UNGCPRO;
|
|
1146 break;
|
|
1147 }
|
|
1148
|
|
1149 default:
|
|
1150 {
|
|
1151 /* We're in trouble if this happens!
|
|
1152 Probably should just abort () */
|
|
1153 if (print_readably)
|
|
1154 error ("printing illegal data type #o%03o",
|
|
1155 (int) XTYPE (obj));
|
|
1156 write_c_string ("#<EMACS BUG: ILLEGAL DATATYPE ",
|
|
1157 printcharfun);
|
|
1158 sprintf (buf, "(#o%3o)", (int) XTYPE (obj));
|
|
1159 write_c_string (buf, printcharfun);
|
|
1160 write_c_string
|
|
1161 (" Save your buffers immediately and please report this bug>",
|
|
1162 printcharfun);
|
|
1163 break;
|
|
1164 }
|
|
1165 }
|
|
1166
|
|
1167 print_depth--;
|
|
1168 }
|
|
1169
|
|
1170 static void
|
|
1171 print_compiled_function_internal (CONST char *start, CONST char *end,
|
173
|
1172 Lisp_Object obj,
|
0
|
1173 Lisp_Object printcharfun, int escapeflag)
|
|
1174 {
|
|
1175 /* This function can GC */
|
|
1176 struct Lisp_Compiled_Function *b =
|
|
1177 XCOMPILED_FUNCTION (obj); /* GC doesn't relocate */
|
|
1178 int docp = b->flags.documentationp;
|
|
1179 int intp = b->flags.interactivep;
|
|
1180 struct gcpro gcpro1, gcpro2;
|
|
1181 char buf[100];
|
|
1182 GCPRO2 (obj, printcharfun);
|
|
1183
|
|
1184 write_c_string (start, printcharfun);
|
|
1185 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
|
|
1186 if (!print_readably)
|
|
1187 {
|
|
1188 Lisp_Object ann = compiled_function_annotation (b);
|
|
1189 if (!NILP (ann))
|
|
1190 {
|
|
1191 write_c_string ("(from ", printcharfun);
|
|
1192 print_internal (ann, printcharfun, 1);
|
|
1193 write_c_string (") ", printcharfun);
|
|
1194 }
|
|
1195 }
|
|
1196 #endif /* COMPILED_FUNCTION_ANNOTATION_HACK */
|
|
1197 /* COMPILED_ARGLIST = 0 */
|
|
1198 print_internal (b->arglist, printcharfun, escapeflag);
|
|
1199 /* COMPILED_BYTECODE = 1 */
|
|
1200 write_char_internal (" ", printcharfun);
|
|
1201 /* we don't really want to see that junk in the bytecode instructions. */
|
|
1202 if (STRINGP (b->bytecodes) && !print_readably)
|
|
1203 {
|
16
|
1204 sprintf (buf, "\"...(%ld)\"", (long) XSTRING_LENGTH (b->bytecodes));
|
0
|
1205 write_c_string (buf, printcharfun);
|
|
1206 }
|
|
1207 else
|
|
1208 print_internal (b->bytecodes, printcharfun, escapeflag);
|
|
1209 /* COMPILED_CONSTANTS = 2 */
|
|
1210 write_char_internal (" ", printcharfun);
|
|
1211 print_internal (b->constants, printcharfun, escapeflag);
|
|
1212 /* COMPILED_STACK_DEPTH = 3 */
|
|
1213 sprintf (buf, " %d", b->maxdepth);
|
|
1214 write_c_string (buf, printcharfun);
|
|
1215 /* COMPILED_DOC_STRING = 4 */
|
|
1216 if (docp || intp)
|
|
1217 {
|
|
1218 write_char_internal (" ", printcharfun);
|
|
1219 print_internal (compiled_function_documentation (b), printcharfun,
|
|
1220 escapeflag);
|
|
1221 }
|
|
1222 /* COMPILED_INTERACTIVE = 5 */
|
|
1223 if (intp)
|
|
1224 {
|
|
1225 write_char_internal (" ", printcharfun);
|
|
1226 print_internal (compiled_function_interactive (b), printcharfun,
|
|
1227 escapeflag);
|
|
1228 }
|
|
1229 UNGCPRO;
|
|
1230 write_c_string (end, printcharfun);
|
|
1231 }
|
|
1232
|
|
1233 void
|
|
1234 print_compiled_function (Lisp_Object obj, Lisp_Object printcharfun,
|
|
1235 int escapeflag)
|
|
1236 {
|
|
1237 /* This function can GC */
|
|
1238 print_compiled_function_internal (((print_readably) ? "#[" :
|
|
1239 "#<compiled-function "),
|
|
1240 ((print_readably) ? "]" : ">"),
|
|
1241 obj, printcharfun, escapeflag);
|
|
1242 }
|
|
1243
|
|
1244 #ifdef LISP_FLOAT_TYPE
|
|
1245 void
|
|
1246 print_float (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1247 {
|
|
1248 char pigbuf[350]; /* see comments in float_to_string */
|
|
1249
|
|
1250 float_to_string (pigbuf, float_data (XFLOAT (obj)));
|
|
1251 write_c_string (pigbuf, printcharfun);
|
|
1252 }
|
|
1253 #endif /* LISP_FLOAT_TYPE */
|
|
1254
|
|
1255 void
|
|
1256 print_symbol (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1257 {
|
|
1258 /* This function can GC */
|
|
1259 /* #### Bug!! (intern "") isn't printed in some distinguished way */
|
|
1260 /* #### (the reader also loses on it) */
|
|
1261 struct Lisp_String *name = XSYMBOL (obj)->name;
|
|
1262 Bytecount size = string_length (name);
|
|
1263 struct gcpro gcpro1, gcpro2;
|
|
1264
|
|
1265 if (!escapeflag)
|
|
1266 {
|
|
1267 /* This deals with GC-relocation */
|
|
1268 Lisp_Object nameobj;
|
|
1269 XSETSTRING (nameobj, name);
|
|
1270 output_string (printcharfun, 0, nameobj, 0, size);
|
|
1271 return;
|
|
1272 }
|
|
1273 GCPRO2 (obj, printcharfun);
|
|
1274
|
173
|
1275 if (print_gensym)
|
0
|
1276 {
|
|
1277 Lisp_Object tem = oblookup (Vobarray, string_data (name), size);
|
|
1278 if (!EQ (tem, obj))
|
|
1279 /* (read) would return a new symbol with the same name.
|
|
1280 This isn't quite correct, because that symbol might not
|
|
1281 really be uninterned (it might be interned in some other
|
|
1282 obarray) but there's no way to win in that case without
|
|
1283 implementing a real package system.
|
|
1284 */
|
|
1285 write_c_string ("#:", printcharfun);
|
|
1286 }
|
|
1287
|
|
1288 /* Does it look like an integer or a float? */
|
|
1289 {
|
|
1290 Bufbyte *data = string_data (name);
|
|
1291 Bytecount confusing = 0;
|
|
1292
|
|
1293 if (size == 0)
|
|
1294 goto not_yet_confused; /* Really confusing */
|
|
1295 else if (isdigit (data[0]))
|
|
1296 confusing = 0;
|
|
1297 else if (size == 1)
|
|
1298 goto not_yet_confused;
|
|
1299 else if (data[0] == '-' || data[0] == '+')
|
|
1300 confusing = 1;
|
|
1301 else
|
|
1302 goto not_yet_confused;
|
|
1303
|
|
1304 for (; confusing < size; confusing++)
|
173
|
1305 {
|
0
|
1306 if (!isdigit (data[confusing]))
|
|
1307 {
|
|
1308 confusing = 0;
|
|
1309 break;
|
|
1310 }
|
|
1311 }
|
|
1312 not_yet_confused:
|
|
1313
|
|
1314 #ifdef LISP_FLOAT_TYPE
|
|
1315 if (!confusing)
|
|
1316 confusing = isfloat_string ((char *) data);
|
|
1317 #endif
|
|
1318 if (confusing)
|
|
1319 write_char_internal ("\\", printcharfun);
|
|
1320 }
|
|
1321
|
|
1322 {
|
|
1323 Lisp_Object nameobj;
|
|
1324 Bytecount i;
|
|
1325 Bytecount last = 0;
|
173
|
1326
|
0
|
1327 XSETSTRING (nameobj, name);
|
|
1328 for (i = 0; i < size; i++)
|
|
1329 {
|
|
1330 Bufbyte c = string_byte (name, i);
|
|
1331
|
|
1332 if (c == '\"' || c == '\\' || c == '\'' || c == ';' || c == '#' ||
|
|
1333 c == '(' || c == ')' || c == ',' || c =='.' || c == '`' ||
|
|
1334 c == '[' || c == ']' || c == '?' || c <= 040)
|
|
1335 {
|
|
1336 if (i > last)
|
|
1337 {
|
|
1338 output_string (printcharfun, 0, nameobj, last,
|
|
1339 i - last);
|
|
1340 }
|
|
1341 write_char_internal ("\\", printcharfun);
|
|
1342 last = i;
|
|
1343 }
|
|
1344 }
|
|
1345 output_string (printcharfun, 0, nameobj, last, size - last);
|
|
1346 }
|
|
1347 UNGCPRO;
|
|
1348 }
|
|
1349
|
|
1350
|
|
1351 int alternate_do_pointer;
|
|
1352 char alternate_do_string[5000];
|
|
1353
|
20
|
1354 DEFUN ("alternate-debugging-output", Falternate_debugging_output, 1, 1, 0, /*
|
0
|
1355 Append CHARACTER to the array `alternate_do_string'.
|
|
1356 This can be used in place of `external-debugging-output' as a function
|
|
1357 to be passed to `print'. Before calling `print', set `alternate_do_pointer'
|
|
1358 to 0.
|
|
1359
|
20
|
1360 */
|
|
1361 (character))
|
0
|
1362 {
|
|
1363 Bufbyte str[MAX_EMCHAR_LEN];
|
|
1364 Bytecount len;
|
|
1365 int extlen;
|
|
1366 CONST Extbyte *extptr;
|
|
1367
|
|
1368 CHECK_CHAR_COERCE_INT (character);
|
|
1369 len = set_charptr_emchar (str, XCHAR (character));
|
16
|
1370 GET_CHARPTR_EXT_DATA_ALLOCA (str, len, FORMAT_TERMINAL, extptr, extlen);
|
0
|
1371 memcpy (alternate_do_string + alternate_do_pointer, extptr, extlen);
|
|
1372 alternate_do_pointer += extlen;
|
|
1373 alternate_do_string[alternate_do_pointer] = 0;
|
|
1374 return character;
|
|
1375 }
|
|
1376
|
20
|
1377 DEFUN ("external-debugging-output", Fexternal_debugging_output, 1, 3, 0, /*
|
0
|
1378 Write CHAR-OR-STRING to stderr or stdout.
|
|
1379 If optional arg STDOUT-P is non-nil, write to stdout; otherwise, write
|
|
1380 to stderr. You can use this function to write directly to the terminal.
|
|
1381 This function can be used as the STREAM argument of Fprint() or the like.
|
|
1382
|
|
1383 If you have opened a termscript file (using `open-termscript'), then
|
|
1384 the output also will be logged to this file.
|
20
|
1385 */
|
|
1386 (char_or_string, stdout_p, device))
|
0
|
1387 {
|
|
1388 FILE *file = 0;
|
|
1389 struct console *con = 0;
|
|
1390
|
|
1391 if (NILP (device))
|
|
1392 {
|
|
1393 if (!NILP (stdout_p))
|
|
1394 file = stdout;
|
|
1395 else
|
|
1396 file = stderr;
|
|
1397 }
|
|
1398 else
|
|
1399 {
|
|
1400 CHECK_LIVE_DEVICE (device);
|
|
1401 if (!DEVICE_TTY_P (XDEVICE (device)) &&
|
|
1402 !DEVICE_STREAM_P (XDEVICE (device)))
|
|
1403 signal_simple_error ("Must be tty or stream device", device);
|
|
1404 con = XCONSOLE (DEVICE_CONSOLE (XDEVICE (device)));
|
|
1405 if (DEVICE_TTY_P (XDEVICE (device)))
|
|
1406 file = 0;
|
|
1407 else if (!NILP (stdout_p))
|
|
1408 file = CONSOLE_STREAM_DATA (con)->outfd;
|
|
1409 else
|
|
1410 file = CONSOLE_STREAM_DATA (con)->errfd;
|
|
1411 }
|
|
1412
|
|
1413 if (STRINGP (char_or_string))
|
|
1414 write_string_to_stdio_stream (file, con,
|
16
|
1415 XSTRING_DATA (char_or_string),
|
|
1416 0, XSTRING_LENGTH (char_or_string),
|
|
1417 FORMAT_TERMINAL);
|
0
|
1418 else
|
|
1419 {
|
|
1420 Bufbyte str[MAX_EMCHAR_LEN];
|
|
1421 Bytecount len;
|
|
1422
|
|
1423 CHECK_CHAR_COERCE_INT (char_or_string);
|
|
1424 len = set_charptr_emchar (str, XCHAR (char_or_string));
|
16
|
1425 write_string_to_stdio_stream (file, con, str, 0, len, FORMAT_TERMINAL);
|
0
|
1426 }
|
|
1427
|
|
1428 return char_or_string;
|
|
1429 }
|
|
1430
|
20
|
1431 DEFUN ("open-termscript", Fopen_termscript, 1, 1, "FOpen termscript file: ", /*
|
0
|
1432 Start writing all terminal output to FILE as well as the terminal.
|
|
1433 FILE = nil means just close any termscript file currently open.
|
20
|
1434 */
|
|
1435 (file))
|
0
|
1436 {
|
|
1437 /* This function can GC */
|
|
1438 if (termscript != 0)
|
|
1439 fclose (termscript);
|
|
1440 termscript = 0;
|
|
1441
|
|
1442 if (! NILP (file))
|
|
1443 {
|
|
1444 file = Fexpand_file_name (file, Qnil);
|
16
|
1445 termscript = fopen ((char *) XSTRING_DATA (file), "w");
|
183
|
1446 if (termscript == NULL)
|
0
|
1447 report_file_error ("Opening termscript", Fcons (file, Qnil));
|
|
1448 }
|
|
1449 return Qnil;
|
|
1450 }
|
|
1451
|
|
1452 #if 1
|
|
1453 /* Debugging kludge -- unbuffered */
|
|
1454 static int debug_print_length = 50;
|
|
1455 static int debug_print_level = 15;
|
|
1456 Lisp_Object debug_temp;
|
|
1457 void debug_print_no_newline (Lisp_Object debug_print_obj);
|
|
1458 void
|
|
1459 debug_print_no_newline (Lisp_Object debug_print_obj)
|
|
1460 {
|
|
1461 /* This function can GC */
|
|
1462 int old_print_readably = print_readably;
|
|
1463 int old_print_depth = print_depth;
|
|
1464 Lisp_Object old_print_length = Vprint_length;
|
|
1465 Lisp_Object old_print_level = Vprint_level;
|
|
1466 Lisp_Object old_inhibit_quit = Vinhibit_quit;
|
|
1467 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
1468 GCPRO3 (old_print_level, old_print_length, old_inhibit_quit);
|
|
1469
|
|
1470 if (gc_in_progress)
|
|
1471 stderr_out ("** gc-in-progress! Bad idea to print anything! **\n");
|
|
1472
|
|
1473 print_depth = 0;
|
|
1474 print_readably = 0;
|
|
1475 print_unbuffered++;
|
|
1476 /* Could use unwind-protect, but why bother? */
|
|
1477 if (debug_print_length > 0)
|
|
1478 Vprint_length = make_int (debug_print_length);
|
|
1479 if (debug_print_level > 0)
|
|
1480 Vprint_level = make_int (debug_print_level);
|
|
1481 print_internal (debug_print_obj, Qexternal_debugging_output, 1);
|
|
1482 Vinhibit_quit = old_inhibit_quit;
|
|
1483 Vprint_level = old_print_level;
|
|
1484 Vprint_length = old_print_length;
|
|
1485 print_depth = old_print_depth;
|
|
1486 print_readably = old_print_readably;
|
|
1487 print_unbuffered--;
|
|
1488 UNGCPRO;
|
|
1489 }
|
|
1490
|
|
1491 void debug_print (Lisp_Object debug_print_obj);
|
|
1492 void
|
|
1493 debug_print (Lisp_Object debug_print_obj)
|
|
1494 {
|
|
1495 debug_print_no_newline (debug_print_obj);
|
|
1496 stderr_out ("\n");
|
|
1497 fflush (stderr);
|
|
1498 }
|
|
1499
|
|
1500 /* Debugging kludge -- unbuffered */
|
|
1501 void
|
|
1502 debug_backtrace (void)
|
|
1503 {
|
|
1504 /* This function can GC */
|
|
1505 int old_print_readably = print_readably;
|
|
1506 int old_print_depth = print_depth;
|
|
1507 Lisp_Object old_print_length = Vprint_length;
|
|
1508 Lisp_Object old_print_level = Vprint_level;
|
|
1509 Lisp_Object old_inhibit_quit = Vinhibit_quit;
|
|
1510 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
1511 GCPRO3 (old_print_level, old_print_length, old_inhibit_quit);
|
|
1512
|
|
1513 if (gc_in_progress)
|
|
1514 stderr_out ("** gc-in-progress! Bad idea to print anything! **\n");
|
|
1515
|
|
1516 print_depth = 0;
|
|
1517 print_readably = 0;
|
|
1518 print_unbuffered++;
|
|
1519 /* Could use unwind-protect, but why bother? */
|
|
1520 if (debug_print_length > 0)
|
|
1521 Vprint_length = make_int (debug_print_length);
|
|
1522 if (debug_print_level > 0)
|
|
1523 Vprint_level = make_int (debug_print_level);
|
|
1524 Fbacktrace (Qexternal_debugging_output, Qt);
|
|
1525 stderr_out ("\n");
|
|
1526 fflush (stderr);
|
|
1527 Vinhibit_quit = old_inhibit_quit;
|
|
1528 Vprint_level = old_print_level;
|
|
1529 Vprint_length = old_print_length;
|
|
1530 print_depth = old_print_depth;
|
|
1531 print_readably = old_print_readably;
|
|
1532 print_unbuffered--;
|
|
1533 UNGCPRO;
|
|
1534 }
|
|
1535
|
|
1536 void
|
|
1537 debug_short_backtrace (int length)
|
|
1538 {
|
|
1539 int first = 1;
|
|
1540 struct backtrace *bt = backtrace_list;
|
|
1541 stderr_out (" [");
|
|
1542 fflush (stderr);
|
|
1543 while (length > 0 && bt)
|
|
1544 {
|
|
1545 if (!first)
|
|
1546 {
|
|
1547 stderr_out (", ");
|
|
1548 fflush (stderr);
|
|
1549 }
|
|
1550 if (COMPILED_FUNCTIONP (*bt->function))
|
|
1551 {
|
|
1552 Lisp_Object ann = Fcompiled_function_annotation (*bt->function);
|
|
1553 if (!NILP (ann))
|
|
1554 {
|
|
1555 stderr_out ("<compiled-function from ");
|
|
1556 fflush (stderr);
|
|
1557 debug_print_no_newline (ann);
|
|
1558 stderr_out (">");
|
|
1559 fflush (stderr);
|
|
1560 }
|
|
1561 else
|
|
1562 {
|
|
1563 stderr_out ("<compiled-function of unknown origin>");
|
|
1564 fflush (stderr);
|
|
1565 }
|
|
1566 }
|
|
1567 else
|
|
1568 debug_print_no_newline (*bt->function);
|
|
1569 first = 0;
|
|
1570 length--;
|
|
1571 bt = bt->next;
|
|
1572 }
|
|
1573 stderr_out ("]\n");
|
|
1574 fflush (stderr);
|
|
1575 }
|
|
1576
|
|
1577 #endif /* debugging kludge */
|
|
1578
|
|
1579
|
|
1580 void
|
|
1581 syms_of_print (void)
|
|
1582 {
|
|
1583 defsymbol (&Qprint_escape_newlines, "print-escape-newlines");
|
|
1584 defsymbol (&Qprint_readably, "print-readably");
|
|
1585
|
|
1586 defsymbol (&Qstandard_output, "standard-output");
|
|
1587
|
|
1588 #ifdef LISP_FLOAT_TYPE
|
|
1589 defsymbol (&Qfloat_output_format, "float-output-format");
|
|
1590 #endif
|
|
1591
|
|
1592 defsymbol (&Qprint_length, "print-length");
|
|
1593
|
|
1594 defsymbol (&Qprint_string_length, "print-string-length");
|
171
|
1595
|
|
1596 defsymbol (&Qdisplay_error, "display-error");
|
|
1597 defsymbol (&Qprint_message_label, "print-message-label");
|
|
1598
|
20
|
1599 DEFSUBR (Fprin1);
|
|
1600 DEFSUBR (Fprin1_to_string);
|
|
1601 DEFSUBR (Fprinc);
|
|
1602 DEFSUBR (Fprint);
|
100
|
1603 DEFSUBR (Ferror_message_string);
|
171
|
1604 DEFSUBR (Fdisplay_error);
|
20
|
1605 DEFSUBR (Fterpri);
|
|
1606 DEFSUBR (Fwrite_char);
|
|
1607 DEFSUBR (Falternate_debugging_output);
|
0
|
1608 defsymbol (&Qalternate_debugging_output, "alternate-debugging-output");
|
20
|
1609 DEFSUBR (Fexternal_debugging_output);
|
|
1610 DEFSUBR (Fopen_termscript);
|
0
|
1611 defsymbol (&Qexternal_debugging_output, "external-debugging-output");
|
|
1612 #ifndef standalone
|
20
|
1613 DEFSUBR (Fwith_output_to_temp_buffer);
|
0
|
1614 #endif /* not standalone */
|
|
1615 }
|
|
1616
|
|
1617 void
|
|
1618 lstream_type_create_print (void)
|
|
1619 {
|
|
1620 LSTREAM_HAS_METHOD (print, writer);
|
|
1621 LSTREAM_HAS_METHOD (print, marker);
|
|
1622 }
|
|
1623
|
|
1624 void
|
|
1625 vars_of_print (void)
|
|
1626 {
|
|
1627 alternate_do_pointer = 0;
|
|
1628
|
|
1629 DEFVAR_LISP ("standard-output", &Vstandard_output /*
|
|
1630 Output stream `print' uses by default for outputting a character.
|
|
1631 This may be any function of one argument.
|
|
1632 It may also be a buffer (output is inserted before point)
|
|
1633 or a marker (output is inserted and the marker is advanced)
|
|
1634 or the symbol t (output appears in the minibuffer line).
|
|
1635 */ );
|
|
1636 Vstandard_output = Qt;
|
|
1637
|
|
1638 #ifdef LISP_FLOAT_TYPE
|
|
1639 DEFVAR_LISP ("float-output-format", &Vfloat_output_format /*
|
|
1640 The format descriptor string that lisp uses to print floats.
|
|
1641 This is a %-spec like those accepted by `printf' in C,
|
|
1642 but with some restrictions. It must start with the two characters `%.'.
|
|
1643 After that comes an integer precision specification,
|
|
1644 and then a letter which controls the format.
|
|
1645 The letters allowed are `e', `f' and `g'.
|
185
|
1646 Use `e' for exponential notation "DIG.DIGITSeEXPT"
|
|
1647 Use `f' for decimal point notation "DIGITS.DIGITS".
|
0
|
1648 Use `g' to choose the shorter of those two formats for the number at hand.
|
|
1649 The precision in any of these cases is the number of digits following
|
|
1650 the decimal point. With `f', a precision of 0 means to omit the
|
|
1651 decimal point. 0 is not allowed with `f' or `g'.
|
|
1652
|
|
1653 A value of nil means to use `%.16g'.
|
|
1654
|
|
1655 Regardless of the value of `float-output-format', a floating point number
|
|
1656 will never be printed in such a way that it is ambiguous with an integer;
|
|
1657 that is, a floating-point number will always be printed with a decimal
|
|
1658 point and/or an exponent, even if the digits following the decimal point
|
|
1659 are all zero. This is to preserve read-equivalence.
|
|
1660 */ );
|
|
1661 Vfloat_output_format = Qnil;
|
|
1662 #endif /* LISP_FLOAT_TYPE */
|
|
1663
|
|
1664 DEFVAR_LISP ("print-length", &Vprint_length /*
|
|
1665 Maximum length of list or vector to print before abbreviating.
|
|
1666 A value of nil means no limit.
|
|
1667 */ );
|
|
1668 Vprint_length = Qnil;
|
|
1669
|
|
1670 DEFVAR_LISP ("print-string-length", &Vprint_string_length /*
|
|
1671 Maximum length of string to print before abbreviating.
|
|
1672 A value of nil means no limit.
|
|
1673 */ );
|
|
1674 Vprint_string_length = Qnil;
|
|
1675
|
|
1676 DEFVAR_LISP ("print-level", &Vprint_level /*
|
|
1677 Maximum depth of list nesting to print before abbreviating.
|
|
1678 A value of nil means no limit.
|
|
1679 */ );
|
|
1680 Vprint_level = Qnil;
|
|
1681
|
|
1682 DEFVAR_BOOL ("print-escape-newlines", &print_escape_newlines /*
|
|
1683 Non-nil means print newlines in strings as backslash-n.
|
|
1684 */ );
|
|
1685 print_escape_newlines = 0;
|
|
1686
|
|
1687 DEFVAR_BOOL ("print-readably", &print_readably /*
|
|
1688 If non-nil, then all objects will be printed in a readable form.
|
|
1689 If an object has no readable representation, then an error is signalled.
|
|
1690 When print-readably is true, compiled-function objects will be written in
|
|
1691 #[...] form instead of in #<compiled-function [...]> form, and two-element
|
|
1692 lists of the form (quote object) will be written as the equivalent 'object.
|
|
1693 Do not SET this variable; bind it instead.
|
|
1694 */ );
|
|
1695 print_readably = 0;
|
|
1696
|
|
1697 DEFVAR_BOOL ("print-gensym", &print_gensym /*
|
|
1698 If non-nil, then uninterned symbols will be printed specially.
|
|
1699 Uninterned symbols are those which are not present in `obarray', that is,
|
|
1700 those which were made with `make-symbol' or by calling `intern' with a
|
|
1701 second argument.
|
|
1702
|
185
|
1703 When print-gensym is true, such symbols will be preceded by "#:", which
|
0
|
1704 causes the reader to create a new symbol instead of interning and returning
|
|
1705 an existing one. Beware: the #: syntax creates a new symbol each time it is
|
|
1706 seen, so if you print an object which contains two pointers to the same
|
|
1707 uninterned symbol, `read' will not duplicate that structure.
|
|
1708
|
|
1709 Also, since XEmacs has no real notion of packages, there is no way for the
|
|
1710 printer to distinguish between symbols interned in no obarray, and symbols
|
|
1711 interned in an alternate obarray.
|
|
1712 */ );
|
|
1713 print_gensym = 0;
|
|
1714
|
|
1715 DEFVAR_LISP ("print-message-label", &Vprint_message_label /*
|
|
1716 Label for minibuffer messages created with `print'. This should
|
|
1717 generally be bound with `let' rather than set. (See `display-message'.)
|
|
1718 */ );
|
|
1719 Vprint_message_label = Qprint;
|
|
1720
|
|
1721 /* prin1_to_string_buffer initialized in init_buffer_once in buffer.c */
|
|
1722 staticpro (&Vprin1_to_string_buffer);
|
|
1723 }
|