428
|
1 /* Lisp object printing and output streams.
|
|
2 Copyright (C) 1985, 1986, 1988, 1992-1995 Free Software Foundation, Inc.
|
771
|
3 Copyright (C) 1995, 1996, 2000, 2001 Ben Wing.
|
428
|
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
|
771
|
26 /* Seriously divergent from FSF by this point.
|
|
27
|
|
28 Seriously hacked on by Ben Wing for Mule. All stdio code also by Ben,
|
|
29 as well as the debugging code (initial version of debug_print(), though,
|
|
30 by Jamie Zawinski) and the _fmt interfaces. Also a fair amount of work
|
|
31 by Hrvoje, e.g. floating-point code and rewriting to avoid O(N^2)
|
|
32 consing when outputting to the echo area. Print-circularity code by
|
|
33 Martin? */
|
428
|
34
|
|
35 #include <config.h>
|
|
36 #include "lisp.h"
|
|
37
|
|
38 #include "backtrace.h"
|
|
39 #include "buffer.h"
|
|
40 #include "bytecode.h"
|
|
41 #include "console-tty.h"
|
|
42 #include "console-stream.h"
|
|
43 #include "extents.h"
|
|
44 #include "frame.h"
|
|
45 #include "insdel.h"
|
|
46 #include "lstream.h"
|
771
|
47 #include "opaque.h"
|
428
|
48 #include "sysfile.h"
|
442
|
49 #ifdef WIN32_NATIVE
|
|
50 #include "console-msw.h"
|
|
51 #endif
|
428
|
52
|
|
53 #include <float.h>
|
|
54 /* Define if not in float.h */
|
|
55 #ifndef DBL_DIG
|
|
56 #define DBL_DIG 16
|
|
57 #endif
|
|
58
|
|
59 Lisp_Object Vstandard_output, Qstandard_output;
|
|
60
|
|
61 /* The subroutine object for external-debugging-output is kept here
|
|
62 for the convenience of the debugger. */
|
442
|
63 Lisp_Object Qexternal_debugging_output, Qalternate_debugging_output;
|
|
64
|
|
65 #ifdef HAVE_MS_WINDOWS
|
|
66 Lisp_Object Qmswindows_debugging_output;
|
|
67 #endif
|
428
|
68
|
|
69 /* Avoid actual stack overflow in print. */
|
|
70 static int print_depth;
|
|
71
|
|
72 /* Detect most circularities to print finite output. */
|
|
73 #define PRINT_CIRCLE 200
|
|
74 static Lisp_Object being_printed[PRINT_CIRCLE];
|
|
75
|
|
76 /* Maximum length of list or vector to print in full; noninteger means
|
|
77 effectively infinity */
|
|
78
|
|
79 Lisp_Object Vprint_length;
|
|
80 Lisp_Object Qprint_length;
|
|
81
|
|
82 /* Maximum length of string to print in full; noninteger means
|
|
83 effectively infinity */
|
|
84
|
|
85 Lisp_Object Vprint_string_length;
|
|
86 Lisp_Object Qprint_string_length;
|
|
87
|
|
88 /* Maximum depth of list to print in full; noninteger means
|
|
89 effectively infinity. */
|
|
90
|
|
91 Lisp_Object Vprint_level;
|
|
92
|
|
93 /* Label to use when making echo-area messages. */
|
|
94
|
|
95 Lisp_Object Vprint_message_label;
|
|
96
|
|
97 /* Nonzero means print newlines in strings as \n. */
|
|
98
|
|
99 int print_escape_newlines;
|
|
100 int print_readably;
|
|
101
|
|
102 /* Non-nil means print #: before uninterned symbols.
|
|
103 Neither t nor nil means so that and don't clear Vprint_gensym_alist
|
|
104 on entry to and exit from print functions. */
|
|
105 Lisp_Object Vprint_gensym;
|
|
106 Lisp_Object Vprint_gensym_alist;
|
|
107
|
|
108 Lisp_Object Qdisplay_error;
|
|
109 Lisp_Object Qprint_message_label;
|
|
110
|
|
111 /* Force immediate output of all printed data. Used for debugging. */
|
|
112 int print_unbuffered;
|
|
113
|
|
114 FILE *termscript; /* Stdio stream being used for copy of all output. */
|
|
115
|
771
|
116 static void write_string_to_alternate_debugging_output (Intbyte *str,
|
|
117 Bytecount len);
|
|
118
|
428
|
119
|
|
120
|
|
121 int stdout_needs_newline;
|
|
122
|
771
|
123 /* Basic function to actually write to a stdio stream or TTY console. */
|
|
124
|
442
|
125 static void
|
771
|
126 write_string_to_stdio_stream (FILE *stream, struct console *con,
|
|
127 const Intbyte *ptr, Bytecount len,
|
|
128 int must_flush)
|
428
|
129 {
|
771
|
130 Extbyte *extptr = 0;
|
|
131 Bytecount extlen = 0;
|
|
132 int output_is_std_handle =
|
|
133 stream ? stream == stdout || stream == stderr :
|
|
134 CONSOLE_TTY_DATA (con)->is_stdio;
|
|
135
|
|
136 if (stream || output_is_std_handle)
|
|
137 {
|
|
138 if (initialized && !inhibit_non_essential_printing_operations)
|
|
139 TO_EXTERNAL_FORMAT (DATA, (ptr, len),
|
|
140 ALLOCA, (extptr, extlen),
|
|
141 Qterminal);
|
|
142 else
|
|
143 {
|
|
144 extptr = (Extbyte *) ptr;
|
|
145 extlen = (Bytecount) len;
|
|
146 }
|
|
147 }
|
|
148
|
428
|
149 if (stream)
|
|
150 {
|
442
|
151 #ifdef WIN32_NATIVE
|
|
152 HANDLE errhand = GetStdHandle (STD_INPUT_HANDLE);
|
|
153 int no_useful_stderr = errhand == 0 || errhand == INVALID_HANDLE_VALUE;
|
|
154
|
|
155 if (!no_useful_stderr)
|
|
156 no_useful_stderr = !PeekNamedPipe (errhand, 0, 0, 0, 0, 0);
|
|
157 /* we typically have no useful stdout/stderr under windows if we're
|
|
158 being invoked graphically. */
|
|
159 if (no_useful_stderr)
|
771
|
160 mswindows_output_console_string (ptr, len);
|
442
|
161 else
|
428
|
162 #endif
|
442
|
163 {
|
771
|
164 retry_fwrite (extptr, 1, extlen, stream);
|
442
|
165 #ifdef WIN32_NATIVE
|
|
166 /* Q122442 says that pipes are "treated as files, not as
|
|
167 devices", and that this is a feature. Before I found that
|
|
168 article, I thought it was a bug. Thanks MS, I feel much
|
|
169 better now. - kkm */
|
|
170 must_flush = 1;
|
|
171 #endif
|
|
172 if (must_flush)
|
|
173 fflush (stream);
|
|
174 }
|
428
|
175 }
|
|
176 else
|
771
|
177 /* The stream itself does conversion to external format */
|
|
178 Lstream_write (XLSTREAM (CONSOLE_TTY_DATA (con)->outstream), ptr, len);
|
442
|
179
|
|
180 if (output_is_std_handle)
|
428
|
181 {
|
|
182 if (termscript)
|
|
183 {
|
771
|
184 retry_fwrite (extptr, 1, extlen, termscript);
|
428
|
185 fflush (termscript);
|
|
186 }
|
771
|
187 stdout_needs_newline = (ptr[extlen - 1] != '\n');
|
428
|
188 }
|
|
189 }
|
|
190
|
442
|
191 /* #### The following function should be replaced a call to the
|
771
|
192 emacs_vsprintf_*() functions. This is the only way to ensure that
|
442
|
193 I18N3 works properly (many implementations of the *printf()
|
|
194 functions, including the ones included in glibc, do not implement
|
|
195 the %###$ argument-positioning syntax).
|
|
196
|
|
197 Note, however, that to do this, we'd have to
|
|
198
|
|
199 1) pre-allocate all the lstreams and do whatever else was necessary
|
|
200 to make sure that no allocation occurs, since these functions may be
|
|
201 called from fatal_error_signal().
|
|
202
|
|
203 2) (to be really correct) make a new lstream that outputs using
|
|
204 mswindows_output_console_string(). */
|
|
205
|
771
|
206 static void
|
|
207 std_handle_out_va (FILE *stream, const CIntbyte *fmt, va_list args,
|
|
208 int debug_output_as_well)
|
442
|
209 {
|
665
|
210 Intbyte kludge[8192];
|
771
|
211 Bytecount kludgelen;
|
|
212
|
|
213 if (initialized && !inhibit_non_essential_printing_operations)
|
|
214 fmt = GETTEXT (fmt);
|
|
215 vsprintf ((CIntbyte *) kludge, fmt, args);
|
|
216 kludgelen = qxestrlen (kludge);
|
442
|
217
|
771
|
218 write_string_to_stdio_stream (stream, 0, kludge, kludgelen, 1);
|
|
219 if (debug_output_as_well)
|
442
|
220 {
|
771
|
221 write_string_to_alternate_debugging_output (kludge, kludgelen);
|
|
222 #ifdef WIN32_NATIVE
|
|
223 write_string_to_mswindows_debugging_output (kludge, kludgelen);
|
|
224 #endif
|
442
|
225 }
|
|
226 }
|
|
227
|
771
|
228 /* Output portably to stderr or its equivalent (i.e. may be a console
|
|
229 window under MS Windows); do external-format conversion and call GETTEXT
|
|
230 on the format string. Automatically flush when done.
|
442
|
231
|
771
|
232 This is safe even when not initialized or when dying -- we don't do
|
|
233 conversion in such cases. */
|
|
234
|
|
235 void
|
|
236 stderr_out (const CIntbyte *fmt, ...)
|
442
|
237 {
|
|
238 va_list args;
|
|
239 va_start (args, fmt);
|
771
|
240 std_handle_out_va (stderr, fmt, args, 0);
|
442
|
241 va_end (args);
|
|
242 }
|
|
243
|
771
|
244 /* Output portably to stdout or its equivalent (i.e. may be a console
|
|
245 window under MS Windows). Works like stderr_out(). */
|
442
|
246
|
771
|
247 void
|
|
248 stdout_out (const CIntbyte *fmt, ...)
|
442
|
249 {
|
|
250 va_list args;
|
|
251 va_start (args, fmt);
|
771
|
252 std_handle_out_va (stdout, fmt, args, 0);
|
442
|
253 va_end (args);
|
771
|
254 }
|
|
255
|
|
256 /* Output portably to stderr or its equivalent (i.e. may be a console
|
|
257 window under MS Windows), as well as alternate-debugging-output and
|
|
258 (under MS Windows) the C debugging output, i.e. OutputDebugString().
|
|
259 Works like stderr_out(). */
|
|
260
|
|
261 void
|
|
262 debug_out (const CIntbyte *fmt, ...)
|
|
263 {
|
|
264 va_list args;
|
|
265 va_start (args, fmt);
|
|
266 std_handle_out_va (stderr, fmt, args, 1);
|
|
267 va_end (args);
|
442
|
268 }
|
|
269
|
|
270 DOESNT_RETURN
|
771
|
271 fatal (const CIntbyte *fmt, ...)
|
442
|
272 {
|
|
273 va_list args;
|
|
274 va_start (args, fmt);
|
|
275
|
771
|
276 stderr_out ("\nXEmacs: fatal error: ");
|
|
277 std_handle_out_va (stderr, fmt, args, 0);
|
442
|
278 stderr_out ("\n");
|
|
279
|
|
280 va_end (args);
|
|
281 exit (1);
|
|
282 }
|
|
283
|
428
|
284 /* Write a string to the output location specified in FUNCTION.
|
|
285 Arguments NONRELOC, RELOC, OFFSET, and LEN are as in
|
771
|
286 buffer_insert_string_1() in insdel.c.
|
|
287
|
|
288 FUNCTION is one of
|
|
289
|
|
290 -- an lstream
|
|
291 -- a buffer (insert at point and advance point)
|
|
292 -- a marker (insert at marker and advance marker)
|
|
293 -- a frame (append to echo area; clear echo area first if
|
|
294 `print-message-label' has changed since the last time)
|
|
295 -- t or nil (send to stdout)
|
|
296 -- a Lisp function of one argument (call to get data output)
|
|
297
|
|
298 Use Qexternal_debugging_output to get output to stderr.
|
|
299 */
|
428
|
300
|
|
301 static void
|
665
|
302 output_string (Lisp_Object function, const Intbyte *nonreloc,
|
428
|
303 Lisp_Object reloc, Bytecount offset, Bytecount len)
|
|
304 {
|
|
305 /* This function can GC */
|
|
306 Charcount cclen;
|
|
307 /* We change the value of nonreloc (fetching it from reloc as
|
|
308 necessary), but we don't want to pass this changed value on to
|
|
309 other functions that take both a nonreloc and a reloc, or things
|
|
310 may get confused and an assertion failure in
|
|
311 fixup_internal_substring() may get triggered. */
|
665
|
312 const Intbyte *newnonreloc = nonreloc;
|
428
|
313 struct gcpro gcpro1, gcpro2;
|
|
314
|
|
315 /* Emacs won't print while GCing, but an external debugger might */
|
771
|
316 #ifdef NO_PRINT_DURING_GC
|
428
|
317 if (gc_in_progress) return;
|
771
|
318 #endif
|
428
|
319
|
|
320 /* Perhaps not necessary but probably safer. */
|
|
321 GCPRO2 (function, reloc);
|
|
322
|
|
323 fixup_internal_substring (newnonreloc, reloc, offset, &len);
|
|
324
|
|
325 if (STRINGP (reloc))
|
771
|
326 {
|
|
327 cclen = XSTRING_OFFSET_BYTE_TO_CHAR_LEN (reloc, offset, len);
|
|
328 newnonreloc = XSTRING_DATA (reloc);
|
|
329 }
|
|
330 else
|
|
331 cclen = bytecount_to_charcount (newnonreloc + offset, len);
|
428
|
332
|
|
333 if (LSTREAMP (function))
|
|
334 {
|
|
335 if (STRINGP (reloc))
|
|
336 {
|
|
337 /* Protect against Lstream_write() causing a GC and
|
|
338 relocating the string. For small strings, we do it by
|
|
339 alloc'ing the string and using a copy; for large strings,
|
|
340 we inhibit GC. */
|
|
341 if (len < 65536)
|
|
342 {
|
665
|
343 Intbyte *copied = alloca_array (Intbyte, len);
|
428
|
344 memcpy (copied, newnonreloc + offset, len);
|
|
345 Lstream_write (XLSTREAM (function), copied, len);
|
|
346 }
|
|
347 else
|
|
348 {
|
771
|
349 int speccount = begin_gc_forbidden ();
|
428
|
350 Lstream_write (XLSTREAM (function), newnonreloc + offset, len);
|
771
|
351 unbind_to (speccount);
|
428
|
352 }
|
|
353 }
|
|
354 else
|
|
355 Lstream_write (XLSTREAM (function), newnonreloc + offset, len);
|
|
356
|
|
357 if (print_unbuffered)
|
|
358 Lstream_flush (XLSTREAM (function));
|
|
359 }
|
|
360 else if (BUFFERP (function))
|
|
361 {
|
|
362 CHECK_LIVE_BUFFER (function);
|
|
363 buffer_insert_string (XBUFFER (function), nonreloc, reloc, offset, len);
|
|
364 }
|
|
365 else if (MARKERP (function))
|
|
366 {
|
|
367 /* marker_position() will err if marker doesn't point anywhere. */
|
665
|
368 Charbpos spoint = marker_position (function);
|
428
|
369
|
|
370 buffer_insert_string_1 (XMARKER (function)->buffer,
|
|
371 spoint, nonreloc, reloc, offset, len,
|
|
372 0);
|
|
373 Fset_marker (function, make_int (spoint + cclen),
|
|
374 Fmarker_buffer (function));
|
|
375 }
|
|
376 else if (FRAMEP (function))
|
|
377 {
|
|
378 /* This gets used by functions not invoking print_prepare(),
|
|
379 such as Fwrite_char, Fterpri, etc.. */
|
|
380 struct frame *f = XFRAME (function);
|
|
381 CHECK_LIVE_FRAME (function);
|
|
382
|
|
383 if (!EQ (Vprint_message_label, echo_area_status (f)))
|
|
384 clear_echo_area_from_print (f, Qnil, 1);
|
|
385 echo_area_append (f, nonreloc, reloc, offset, len, Vprint_message_label);
|
|
386 }
|
|
387 else if (EQ (function, Qt) || EQ (function, Qnil))
|
|
388 {
|
771
|
389 write_string_to_stdio_stream (stdout, 0, newnonreloc + offset, len,
|
|
390 print_unbuffered);
|
|
391 }
|
|
392 else if (EQ (function, Qexternal_debugging_output))
|
|
393 {
|
|
394 /* This is not strictly necessary, and somewhat of a hack, but it
|
|
395 avoids having each character passed separately to
|
|
396 `external-debugging-output'. #### Why do we pass each character
|
|
397 separately, anyway?
|
|
398 */
|
|
399 write_string_to_stdio_stream (stderr, 0, newnonreloc + offset, len,
|
|
400 print_unbuffered);
|
428
|
401 }
|
|
402 else
|
|
403 {
|
771
|
404 Charcount ccoff;
|
428
|
405 Charcount iii;
|
|
406
|
771
|
407 if (STRINGP (reloc))
|
|
408 ccoff = XSTRING_INDEX_BYTE_TO_CHAR (reloc, offset);
|
|
409 else
|
|
410 ccoff = bytecount_to_charcount (newnonreloc, offset);
|
|
411
|
|
412 if (STRINGP (reloc))
|
428
|
413 {
|
771
|
414 for (iii = ccoff; iii < cclen + ccoff; iii++)
|
|
415 {
|
|
416 call1 (function, make_char (XSTRING_CHAR (reloc, iii)));
|
|
417 if (STRINGP (reloc))
|
|
418 newnonreloc = XSTRING_DATA (reloc);
|
|
419 }
|
|
420 }
|
|
421 else
|
|
422 {
|
|
423 for (iii = ccoff; iii < cclen + ccoff; iii++)
|
|
424 {
|
|
425 call1 (function,
|
|
426 make_char (charptr_emchar_n (newnonreloc, iii)));
|
|
427 }
|
428
|
428 }
|
|
429 }
|
|
430
|
|
431 UNGCPRO;
|
|
432 }
|
|
433
|
|
434 #define RESET_PRINT_GENSYM do { \
|
|
435 if (!CONSP (Vprint_gensym)) \
|
|
436 Vprint_gensym_alist = Qnil; \
|
|
437 } while (0)
|
|
438
|
|
439 static Lisp_Object
|
|
440 canonicalize_printcharfun (Lisp_Object printcharfun)
|
|
441 {
|
|
442 if (NILP (printcharfun))
|
|
443 printcharfun = Vstandard_output;
|
|
444
|
|
445 if (EQ (printcharfun, Qt) || NILP (printcharfun))
|
|
446 printcharfun = Fselected_frame (Qnil); /* print to minibuffer */
|
|
447
|
|
448 return printcharfun;
|
|
449 }
|
|
450
|
|
451 static Lisp_Object
|
|
452 print_prepare (Lisp_Object printcharfun, Lisp_Object *frame_kludge)
|
|
453 {
|
|
454 /* Emacs won't print while GCing, but an external debugger might */
|
771
|
455 #ifdef NO_PRINT_DURING_GC
|
428
|
456 if (gc_in_progress)
|
|
457 return Qnil;
|
771
|
458 #endif
|
|
459
|
428
|
460 RESET_PRINT_GENSYM;
|
|
461
|
|
462 printcharfun = canonicalize_printcharfun (printcharfun);
|
|
463
|
|
464 /* Here we could safely return the canonicalized PRINTCHARFUN.
|
|
465 However, if PRINTCHARFUN is a frame, printing of complex
|
|
466 structures becomes very expensive, because `append-message'
|
|
467 (called by echo_area_append) gets called as many times as
|
|
468 output_string() is called (and that's a *lot*). append-message
|
|
469 tries to keep top of the message-stack in sync with the contents
|
|
470 of " *Echo Area" buffer, consing a new string for each component
|
|
471 of the printed structure. For instance, if you print (a a),
|
|
472 append-message will cons up the following strings:
|
|
473
|
|
474 "("
|
|
475 "(a"
|
|
476 "(a "
|
|
477 "(a a"
|
|
478 "(a a)"
|
|
479
|
|
480 and will use only the last one. With larger objects, this turns
|
|
481 into an O(n^2) consing frenzy that locks up XEmacs in incessant
|
|
482 garbage collection.
|
|
483
|
|
484 We prevent this by creating a resizing_buffer stream and letting
|
|
485 the printer write into it. print_finish() will notice this
|
|
486 stream, and invoke echo_area_append() with the stream's buffer,
|
|
487 only once. */
|
|
488 if (FRAMEP (printcharfun))
|
|
489 {
|
|
490 CHECK_LIVE_FRAME (printcharfun);
|
|
491 *frame_kludge = printcharfun;
|
|
492 printcharfun = make_resizing_buffer_output_stream ();
|
|
493 }
|
|
494
|
|
495 return printcharfun;
|
|
496 }
|
|
497
|
|
498 static void
|
|
499 print_finish (Lisp_Object stream, Lisp_Object frame_kludge)
|
|
500 {
|
|
501 /* Emacs won't print while GCing, but an external debugger might */
|
771
|
502 #ifdef NO_PRINT_DURING_GC
|
428
|
503 if (gc_in_progress)
|
|
504 return;
|
771
|
505 #endif
|
|
506
|
428
|
507 RESET_PRINT_GENSYM;
|
|
508
|
|
509 /* See the comment in print_prepare(). */
|
|
510 if (FRAMEP (frame_kludge))
|
|
511 {
|
|
512 struct frame *f = XFRAME (frame_kludge);
|
|
513 Lstream *str = XLSTREAM (stream);
|
|
514 CHECK_LIVE_FRAME (frame_kludge);
|
|
515
|
|
516 Lstream_flush (str);
|
|
517 if (!EQ (Vprint_message_label, echo_area_status (f)))
|
|
518 clear_echo_area_from_print (f, Qnil, 1);
|
|
519 echo_area_append (f, resizing_buffer_stream_ptr (str),
|
|
520 Qnil, 0, Lstream_byte_count (str),
|
|
521 Vprint_message_label);
|
|
522 Lstream_delete (str);
|
|
523 }
|
|
524 }
|
|
525
|
|
526 /* Used for printing a single-byte character (*not* any Emchar). */
|
|
527 #define write_char_internal(string_of_length_1, stream) \
|
665
|
528 output_string (stream, (const Intbyte *) (string_of_length_1), \
|
428
|
529 Qnil, 0, 1)
|
|
530
|
771
|
531 /* Write internal-format data to STREAM. See output_string() for
|
|
532 interpretation of STREAM.
|
|
533
|
|
534 NOTE: Do not call this with the data of a Lisp_String, as
|
428
|
535 printcharfun might cause a GC, which might cause the string's data
|
|
536 to be relocated. To princ a Lisp string, use:
|
|
537
|
|
538 print_internal (string, printcharfun, 0);
|
|
539
|
|
540 Also note that STREAM should be the result of
|
|
541 canonicalize_printcharfun() (i.e. Qnil means stdout, not
|
|
542 Vstandard_output, etc.) */
|
|
543 void
|
665
|
544 write_string_1 (const Intbyte *str, Bytecount size, Lisp_Object stream)
|
428
|
545 {
|
|
546 /* This function can GC */
|
665
|
547 #ifdef ERROR_CHECK_CHARBPOS
|
428
|
548 assert (size >= 0);
|
|
549 #endif
|
|
550 output_string (stream, str, Qnil, 0, size);
|
|
551 }
|
|
552
|
|
553 void
|
771
|
554 write_string (const Intbyte *str, Lisp_Object stream)
|
|
555 {
|
|
556 /* This function can GC */
|
|
557 write_string_1 (str, qxestrlen (str), stream);
|
|
558 }
|
|
559
|
|
560 void
|
|
561 write_c_string (const CIntbyte *str, Lisp_Object stream)
|
428
|
562 {
|
|
563 /* This function can GC */
|
665
|
564 write_string_1 ((const Intbyte *) str, strlen (str), stream);
|
428
|
565 }
|
|
566
|
771
|
567 /* Write a printf-style string to STREAM; see output_string(). */
|
|
568
|
|
569 void
|
|
570 write_fmt_string (Lisp_Object stream, const CIntbyte *fmt, ...)
|
|
571 {
|
|
572 va_list va;
|
|
573 Intbyte *str;
|
|
574 Bytecount len;
|
|
575 int count;
|
|
576
|
|
577 va_start (va, fmt);
|
|
578 str = emacs_vsprintf_malloc (fmt, va, &len);
|
|
579 va_end (va);
|
|
580 count = record_unwind_protect_freeing (str);
|
|
581 write_string_1 (str, len, stream);
|
|
582 unbind_to (count);
|
|
583 }
|
|
584
|
|
585 /* Write a printf-style string to STREAM, where the arguments are
|
|
586 Lisp objects and not C strings or integers; see output_string().
|
|
587
|
|
588 #### It shouldn't be necessary to specify the number of arguments.
|
|
589 This would require some rewriting of the doprnt() functions, though. */
|
|
590
|
|
591 void
|
|
592 write_fmt_string_lisp (Lisp_Object stream, const CIntbyte *fmt, int nargs, ...)
|
|
593 {
|
|
594 Lisp_Object *args = alloca_array (Lisp_Object, nargs);
|
|
595 va_list va;
|
|
596 int i;
|
|
597 Intbyte *str;
|
|
598 Bytecount len;
|
|
599 int count;
|
|
600
|
|
601 va_start (va, nargs);
|
|
602 for (i = 0; i < nargs; i++)
|
|
603 args[i] = va_arg (va, Lisp_Object);
|
|
604 va_end (va);
|
|
605 str = emacs_vsprintf_malloc_lisp (fmt, Qnil, nargs, args, &len);
|
|
606 count = record_unwind_protect_freeing (str);
|
|
607 write_string_1 (str, len, stream);
|
|
608 unbind_to (count);
|
|
609 }
|
|
610
|
|
611 void
|
|
612 stderr_out_lisp (const CIntbyte *fmt, int nargs, ...)
|
|
613 {
|
|
614 Lisp_Object *args = alloca_array (Lisp_Object, nargs);
|
|
615 va_list va;
|
|
616 int i;
|
|
617 Intbyte *str;
|
|
618 Bytecount len;
|
|
619 int count;
|
|
620
|
|
621 va_start (va, nargs);
|
|
622 for (i = 0; i < nargs; i++)
|
|
623 args[i] = va_arg (va, Lisp_Object);
|
|
624 va_end (va);
|
|
625 str = emacs_vsprintf_malloc_lisp (fmt, Qnil, nargs, args, &len);
|
|
626 count = record_unwind_protect_freeing (str);
|
|
627 write_string_1 (str, len, Qexternal_debugging_output);
|
|
628 unbind_to (count);
|
|
629 }
|
|
630
|
428
|
631
|
|
632 DEFUN ("write-char", Fwrite_char, 1, 2, 0, /*
|
444
|
633 Output character CHARACTER to stream STREAM.
|
428
|
634 STREAM defaults to the value of `standard-output' (which see).
|
|
635 */
|
444
|
636 (character, stream))
|
428
|
637 {
|
|
638 /* This function can GC */
|
665
|
639 Intbyte str[MAX_EMCHAR_LEN];
|
428
|
640 Bytecount len;
|
|
641
|
444
|
642 CHECK_CHAR_COERCE_INT (character);
|
|
643 len = set_charptr_emchar (str, XCHAR (character));
|
428
|
644 output_string (canonicalize_printcharfun (stream), str, Qnil, 0, len);
|
444
|
645 return character;
|
428
|
646 }
|
|
647
|
|
648 void
|
|
649 temp_output_buffer_setup (Lisp_Object bufname)
|
|
650 {
|
|
651 /* This function can GC */
|
|
652 struct buffer *old = current_buffer;
|
|
653 Lisp_Object buf;
|
|
654
|
|
655 #ifdef I18N3
|
|
656 /* #### This function should accept a Lisp_Object instead of a char *,
|
|
657 so that proper translation on the buffer name can occur. */
|
|
658 #endif
|
|
659
|
|
660 Fset_buffer (Fget_buffer_create (bufname));
|
|
661
|
|
662 current_buffer->read_only = Qnil;
|
|
663 Ferase_buffer (Qnil);
|
|
664
|
|
665 XSETBUFFER (buf, current_buffer);
|
|
666 specbind (Qstandard_output, buf);
|
|
667
|
|
668 set_buffer_internal (old);
|
|
669 }
|
|
670
|
|
671 Lisp_Object
|
|
672 internal_with_output_to_temp_buffer (Lisp_Object bufname,
|
|
673 Lisp_Object (*function) (Lisp_Object arg),
|
|
674 Lisp_Object arg,
|
|
675 Lisp_Object same_frame)
|
|
676 {
|
|
677 int speccount = specpdl_depth ();
|
|
678 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
679 Lisp_Object buf = Qnil;
|
|
680
|
|
681 GCPRO3 (buf, arg, same_frame);
|
|
682
|
|
683 temp_output_buffer_setup (bufname);
|
|
684 buf = Vstandard_output;
|
|
685
|
|
686 arg = (*function) (arg);
|
|
687
|
|
688 temp_output_buffer_show (buf, same_frame);
|
|
689 UNGCPRO;
|
|
690
|
771
|
691 return unbind_to_1 (speccount, arg);
|
428
|
692 }
|
|
693
|
|
694 DEFUN ("with-output-to-temp-buffer", Fwith_output_to_temp_buffer, 1, UNEVALLED, 0, /*
|
|
695 Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer.
|
|
696 The buffer is cleared out initially, and marked as unmodified when done.
|
|
697 All output done by BODY is inserted in that buffer by default.
|
|
698 The buffer is displayed in another window, but not selected.
|
|
699 The value of the last form in BODY is returned.
|
|
700 If BODY does not finish normally, the buffer BUFNAME is not displayed.
|
|
701
|
|
702 If variable `temp-buffer-show-function' is non-nil, call it at the end
|
|
703 to get the buffer displayed. It gets one argument, the buffer to display.
|
|
704 */
|
|
705 (args))
|
|
706 {
|
|
707 /* This function can GC */
|
|
708 Lisp_Object name = Qnil;
|
|
709 int speccount = specpdl_depth ();
|
|
710 struct gcpro gcpro1, gcpro2;
|
|
711 Lisp_Object val = Qnil;
|
|
712
|
|
713 #ifdef I18N3
|
|
714 /* #### should set the buffer to be translating. See print_internal(). */
|
|
715 #endif
|
|
716
|
|
717 GCPRO2 (name, val);
|
|
718 name = Feval (XCAR (args));
|
|
719
|
|
720 CHECK_STRING (name);
|
|
721
|
|
722 temp_output_buffer_setup (name);
|
|
723 UNGCPRO;
|
|
724
|
|
725 val = Fprogn (XCDR (args));
|
|
726
|
|
727 temp_output_buffer_show (Vstandard_output, Qnil);
|
|
728
|
771
|
729 return unbind_to_1 (speccount, val);
|
428
|
730 }
|
|
731
|
|
732 DEFUN ("terpri", Fterpri, 0, 1, 0, /*
|
|
733 Output a newline to STREAM.
|
|
734 If STREAM is omitted or nil, the value of `standard-output' is used.
|
|
735 */
|
|
736 (stream))
|
|
737 {
|
|
738 /* This function can GC */
|
|
739 write_char_internal ("\n", canonicalize_printcharfun (stream));
|
|
740 return Qt;
|
|
741 }
|
|
742
|
|
743 DEFUN ("prin1", Fprin1, 1, 2, 0, /*
|
|
744 Output the printed representation of OBJECT, any Lisp object.
|
|
745 Quoting characters are printed when needed to make output that `read'
|
|
746 can handle, whenever this is possible.
|
|
747 Output stream is STREAM, or value of `standard-output' (which see).
|
|
748 */
|
|
749 (object, stream))
|
|
750 {
|
|
751 /* This function can GC */
|
|
752 Lisp_Object frame = Qnil;
|
|
753 struct gcpro gcpro1, gcpro2;
|
|
754 GCPRO2 (object, stream);
|
|
755
|
|
756 print_depth = 0;
|
|
757 stream = print_prepare (stream, &frame);
|
|
758 print_internal (object, stream, 1);
|
|
759 print_finish (stream, frame);
|
|
760
|
|
761 UNGCPRO;
|
|
762 return object;
|
|
763 }
|
|
764
|
|
765 DEFUN ("prin1-to-string", Fprin1_to_string, 1, 2, 0, /*
|
|
766 Return a string containing the printed representation of OBJECT,
|
|
767 any Lisp object. Quoting characters are used when needed to make output
|
|
768 that `read' can handle, whenever this is possible, unless the optional
|
|
769 second argument NOESCAPE is non-nil.
|
|
770 */
|
|
771 (object, noescape))
|
|
772 {
|
|
773 /* This function can GC */
|
|
774 Lisp_Object result = Qnil;
|
|
775 Lisp_Object stream = make_resizing_buffer_output_stream ();
|
|
776 Lstream *str = XLSTREAM (stream);
|
|
777 /* gcpro OBJECT in case a caller forgot to do so */
|
|
778 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
779 GCPRO3 (object, stream, result);
|
|
780
|
|
781 print_depth = 0;
|
|
782 RESET_PRINT_GENSYM;
|
|
783 print_internal (object, stream, NILP (noescape));
|
|
784 RESET_PRINT_GENSYM;
|
|
785 Lstream_flush (str);
|
|
786 UNGCPRO;
|
|
787 result = make_string (resizing_buffer_stream_ptr (str),
|
|
788 Lstream_byte_count (str));
|
|
789 Lstream_delete (str);
|
|
790 return result;
|
|
791 }
|
|
792
|
|
793 DEFUN ("princ", Fprinc, 1, 2, 0, /*
|
|
794 Output the printed representation of OBJECT, any Lisp object.
|
|
795 No quoting characters are used; no delimiters are printed around
|
|
796 the contents of strings.
|
444
|
797 Output stream is STREAM, or value of `standard-output' (which see).
|
428
|
798 */
|
|
799 (object, stream))
|
|
800 {
|
|
801 /* This function can GC */
|
|
802 Lisp_Object frame = Qnil;
|
|
803 struct gcpro gcpro1, gcpro2;
|
|
804
|
|
805 GCPRO2 (object, stream);
|
|
806 stream = print_prepare (stream, &frame);
|
|
807 print_depth = 0;
|
|
808 print_internal (object, stream, 0);
|
|
809 print_finish (stream, frame);
|
|
810 UNGCPRO;
|
|
811 return object;
|
|
812 }
|
|
813
|
|
814 DEFUN ("print", Fprint, 1, 2, 0, /*
|
|
815 Output the printed representation of OBJECT, with newlines around it.
|
|
816 Quoting characters are printed when needed to make output that `read'
|
|
817 can handle, whenever this is possible.
|
|
818 Output stream is STREAM, or value of `standard-output' (which see).
|
|
819 */
|
|
820 (object, stream))
|
|
821 {
|
|
822 /* This function can GC */
|
|
823 Lisp_Object frame = Qnil;
|
|
824 struct gcpro gcpro1, gcpro2;
|
|
825
|
|
826 GCPRO2 (object, stream);
|
|
827 stream = print_prepare (stream, &frame);
|
|
828 print_depth = 0;
|
|
829 write_char_internal ("\n", stream);
|
|
830 print_internal (object, stream, 1);
|
|
831 write_char_internal ("\n", stream);
|
|
832 print_finish (stream, frame);
|
|
833 UNGCPRO;
|
|
834 return object;
|
|
835 }
|
|
836
|
|
837 /* Print an error message for the error DATA to STREAM. This is a
|
|
838 complete implementation of `display-error', which used to be in
|
|
839 Lisp (see prim/cmdloop.el). It was ported to C so it can be used
|
|
840 efficiently by Ferror_message_string. Fdisplay_error and
|
|
841 Ferror_message_string are trivial wrappers around this function.
|
|
842
|
|
843 STREAM should be the result of canonicalize_printcharfun(). */
|
|
844 static void
|
|
845 print_error_message (Lisp_Object error_object, Lisp_Object stream)
|
|
846 {
|
|
847 /* This function can GC */
|
|
848 Lisp_Object type = Fcar_safe (error_object);
|
|
849 Lisp_Object method = Qnil;
|
|
850 Lisp_Object tail;
|
|
851
|
|
852 /* No need to GCPRO anything under the assumption that ERROR_OBJECT
|
|
853 is GCPRO'd. */
|
|
854
|
|
855 if (! (CONSP (error_object) && SYMBOLP (type)
|
|
856 && CONSP (Fget (type, Qerror_conditions, Qnil))))
|
|
857 goto error_throw;
|
|
858
|
|
859 tail = XCDR (error_object);
|
|
860 while (!NILP (tail))
|
|
861 {
|
|
862 if (CONSP (tail))
|
|
863 tail = XCDR (tail);
|
|
864 else
|
|
865 goto error_throw;
|
|
866 }
|
|
867 tail = Fget (type, Qerror_conditions, Qnil);
|
|
868 while (!NILP (tail))
|
|
869 {
|
|
870 if (!(CONSP (tail) && SYMBOLP (XCAR (tail))))
|
|
871 goto error_throw;
|
|
872 else if (!NILP (Fget (XCAR (tail), Qdisplay_error, Qnil)))
|
|
873 {
|
|
874 method = Fget (XCAR (tail), Qdisplay_error, Qnil);
|
|
875 goto error_throw;
|
|
876 }
|
|
877 else
|
|
878 tail = XCDR (tail);
|
|
879 }
|
|
880 /* Default method */
|
|
881 {
|
|
882 int first = 1;
|
|
883 int speccount = specpdl_depth ();
|
438
|
884 Lisp_Object frame = Qnil;
|
|
885 struct gcpro gcpro1;
|
|
886 GCPRO1 (stream);
|
428
|
887
|
|
888 specbind (Qprint_message_label, Qerror);
|
438
|
889 stream = print_prepare (stream, &frame);
|
|
890
|
428
|
891 tail = Fcdr (error_object);
|
|
892 if (EQ (type, Qerror))
|
|
893 {
|
|
894 print_internal (Fcar (tail), stream, 0);
|
|
895 tail = Fcdr (tail);
|
|
896 }
|
|
897 else
|
|
898 {
|
|
899 Lisp_Object errmsg = Fget (type, Qerror_message, Qnil);
|
|
900 if (NILP (errmsg))
|
|
901 print_internal (type, stream, 0);
|
|
902 else
|
|
903 print_internal (LISP_GETTEXT (errmsg), stream, 0);
|
|
904 }
|
|
905 while (!NILP (tail))
|
|
906 {
|
|
907 write_c_string (first ? ": " : ", ", stream);
|
563
|
908 /* Most errors have an explanatory string as their first argument,
|
|
909 and it looks better not to put the quotes around it. */
|
|
910 print_internal (Fcar (tail), stream,
|
|
911 !(first && STRINGP (Fcar (tail))) ||
|
|
912 !NILP (Fget (type, Qerror_lacks_explanatory_string,
|
|
913 Qnil)));
|
428
|
914 tail = Fcdr (tail);
|
|
915 first = 0;
|
|
916 }
|
438
|
917 print_finish (stream, frame);
|
|
918 UNGCPRO;
|
771
|
919 unbind_to (speccount);
|
428
|
920 return;
|
|
921 /* not reached */
|
|
922 }
|
|
923
|
|
924 error_throw:
|
|
925 if (NILP (method))
|
|
926 {
|
|
927 write_c_string (GETTEXT ("Peculiar error "), stream);
|
|
928 print_internal (error_object, stream, 1);
|
|
929 return;
|
|
930 }
|
|
931 else
|
|
932 {
|
|
933 call2 (method, error_object, stream);
|
|
934 }
|
|
935 }
|
|
936
|
|
937 DEFUN ("error-message-string", Ferror_message_string, 1, 1, 0, /*
|
|
938 Convert ERROR-OBJECT to an error message, and return it.
|
|
939
|
|
940 The format of ERROR-OBJECT should be (ERROR-SYMBOL . DATA). The
|
|
941 message is equivalent to the one that would be issued by
|
|
942 `display-error' with the same argument.
|
|
943 */
|
|
944 (error_object))
|
|
945 {
|
|
946 /* This function can GC */
|
|
947 Lisp_Object result = Qnil;
|
|
948 Lisp_Object stream = make_resizing_buffer_output_stream ();
|
|
949 struct gcpro gcpro1;
|
|
950 GCPRO1 (stream);
|
|
951
|
|
952 print_error_message (error_object, stream);
|
|
953 Lstream_flush (XLSTREAM (stream));
|
|
954 result = make_string (resizing_buffer_stream_ptr (XLSTREAM (stream)),
|
|
955 Lstream_byte_count (XLSTREAM (stream)));
|
|
956 Lstream_delete (XLSTREAM (stream));
|
|
957
|
|
958 UNGCPRO;
|
|
959 return result;
|
|
960 }
|
|
961
|
|
962 DEFUN ("display-error", Fdisplay_error, 2, 2, 0, /*
|
|
963 Display ERROR-OBJECT on STREAM in a user-friendly way.
|
|
964 */
|
|
965 (error_object, stream))
|
|
966 {
|
|
967 /* This function can GC */
|
|
968 print_error_message (error_object, canonicalize_printcharfun (stream));
|
|
969 return Qnil;
|
|
970 }
|
|
971
|
|
972
|
|
973 #ifdef LISP_FLOAT_TYPE
|
|
974
|
|
975 Lisp_Object Vfloat_output_format;
|
|
976
|
|
977 /*
|
|
978 * This buffer should be at least as large as the max string size of the
|
440
|
979 * largest float, printed in the biggest notation. This is undoubtedly
|
428
|
980 * 20d float_output_format, with the negative of the C-constant "HUGE"
|
|
981 * from <math.h>.
|
|
982 *
|
|
983 * On the vax the worst case is -1e38 in 20d format which takes 61 bytes.
|
|
984 *
|
|
985 * I assume that IEEE-754 format numbers can take 329 bytes for the worst
|
|
986 * case of -1e307 in 20d float_output_format. What is one to do (short of
|
|
987 * re-writing _doprnt to be more sane)?
|
|
988 * -wsr
|
|
989 */
|
|
990 void
|
|
991 float_to_string (char *buf, double data)
|
|
992 {
|
665
|
993 Intbyte *cp, c;
|
428
|
994 int width;
|
|
995
|
|
996 if (NILP (Vfloat_output_format)
|
|
997 || !STRINGP (Vfloat_output_format))
|
|
998 lose:
|
|
999 sprintf (buf, "%.16g", data);
|
|
1000 else /* oink oink */
|
|
1001 {
|
|
1002 /* Check that the spec we have is fully valid.
|
|
1003 This means not only valid for printf,
|
|
1004 but meant for floats, and reasonable. */
|
|
1005 cp = XSTRING_DATA (Vfloat_output_format);
|
|
1006
|
|
1007 if (cp[0] != '%')
|
|
1008 goto lose;
|
|
1009 if (cp[1] != '.')
|
|
1010 goto lose;
|
|
1011
|
|
1012 cp += 2;
|
|
1013 for (width = 0; (c = *cp, isdigit (c)); cp++)
|
|
1014 {
|
|
1015 width *= 10;
|
|
1016 width += c - '0';
|
|
1017 }
|
|
1018
|
|
1019 if (*cp != 'e' && *cp != 'f' && *cp != 'g' && *cp != 'E' && *cp != 'G')
|
|
1020 goto lose;
|
|
1021
|
|
1022 if (width < (int) (*cp != 'e' && *cp != 'E') || width > DBL_DIG)
|
|
1023 goto lose;
|
|
1024
|
|
1025 if (cp[1] != 0)
|
|
1026 goto lose;
|
|
1027
|
|
1028 sprintf (buf, (char *) XSTRING_DATA (Vfloat_output_format),
|
|
1029 data);
|
|
1030 }
|
|
1031
|
|
1032 /* added by jwz: don't allow "1.0" to print as "1"; that destroys
|
|
1033 the read-equivalence of lisp objects. (* x 1) and (* x 1.0) do
|
|
1034 not do the same thing, so it's important that the printed
|
|
1035 representation of that form not be corrupted by the printer.
|
|
1036 */
|
|
1037 {
|
665
|
1038 Intbyte *s = (Intbyte *) buf; /* don't use signed chars here!
|
428
|
1039 isdigit() can't hack them! */
|
|
1040 if (*s == '-') s++;
|
|
1041 for (; *s; s++)
|
|
1042 /* if there's a non-digit, then there is a decimal point, or
|
|
1043 it's in exponential notation, both of which are ok. */
|
|
1044 if (!isdigit (*s))
|
|
1045 goto DONE_LABEL;
|
|
1046 /* otherwise, we need to hack it. */
|
|
1047 *s++ = '.';
|
|
1048 *s++ = '0';
|
|
1049 *s = 0;
|
|
1050 }
|
|
1051 DONE_LABEL:
|
|
1052
|
|
1053 /* Some machines print "0.4" as ".4". I don't like that. */
|
|
1054 if (buf [0] == '.' || (buf [0] == '-' && buf [1] == '.'))
|
|
1055 {
|
|
1056 int i;
|
|
1057 for (i = strlen (buf) + 1; i >= 0; i--)
|
|
1058 buf [i+1] = buf [i];
|
|
1059 buf [(buf [0] == '-' ? 1 : 0)] = '0';
|
|
1060 }
|
|
1061 }
|
|
1062 #endif /* LISP_FLOAT_TYPE */
|
|
1063
|
577
|
1064 #define ONE_DIGIT(figure) *p++ = n / (figure) + '0'
|
|
1065 #define ONE_DIGIT_ADVANCE(figure) (ONE_DIGIT (figure), n %= (figure))
|
|
1066
|
|
1067 #define DIGITS_1(figure) ONE_DIGIT (figure)
|
|
1068 #define DIGITS_2(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_1 ((figure) / 10)
|
|
1069 #define DIGITS_3(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_2 ((figure) / 10)
|
|
1070 #define DIGITS_4(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_3 ((figure) / 10)
|
|
1071 #define DIGITS_5(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_4 ((figure) / 10)
|
|
1072 #define DIGITS_6(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_5 ((figure) / 10)
|
|
1073 #define DIGITS_7(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_6 ((figure) / 10)
|
|
1074 #define DIGITS_8(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_7 ((figure) / 10)
|
|
1075 #define DIGITS_9(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_8 ((figure) / 10)
|
|
1076 #define DIGITS_10(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_9 ((figure) / 10)
|
|
1077
|
|
1078 /* DIGITS_<11-20> are only used on machines with 64-bit longs. */
|
428
|
1079
|
577
|
1080 #define DIGITS_11(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_10 ((figure) / 10)
|
|
1081 #define DIGITS_12(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_11 ((figure) / 10)
|
|
1082 #define DIGITS_13(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_12 ((figure) / 10)
|
|
1083 #define DIGITS_14(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_13 ((figure) / 10)
|
|
1084 #define DIGITS_15(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_14 ((figure) / 10)
|
|
1085 #define DIGITS_16(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_15 ((figure) / 10)
|
|
1086 #define DIGITS_17(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_16 ((figure) / 10)
|
|
1087 #define DIGITS_18(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_17 ((figure) / 10)
|
|
1088 #define DIGITS_19(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_18 ((figure) / 10)
|
|
1089
|
|
1090 /* Print NUMBER to BUFFER in base 10. This is completely equivalent
|
|
1091 to `sprintf(buffer, "%ld", number)', only much faster.
|
|
1092
|
|
1093 The speedup may make a difference in programs that frequently
|
|
1094 convert numbers to strings. Some implementations of sprintf,
|
|
1095 particularly the one in GNU libc, have been known to be extremely
|
|
1096 slow compared to this function.
|
|
1097
|
|
1098 BUFFER should accept as many bytes as you expect the number to take
|
|
1099 up. On machines with 64-bit longs the maximum needed size is 24
|
|
1100 bytes. That includes the worst-case digits, the optional `-' sign,
|
|
1101 and the trailing \0. */
|
|
1102
|
|
1103 void
|
428
|
1104 long_to_string (char *buffer, long number)
|
|
1105 {
|
577
|
1106 char *p = buffer;
|
|
1107 long n = number;
|
|
1108
|
428
|
1109 #if (SIZEOF_LONG != 4) && (SIZEOF_LONG != 8)
|
577
|
1110 /* We are running in a strange or misconfigured environment. Let
|
|
1111 sprintf cope with it. */
|
|
1112 sprintf (buffer, "%ld", n);
|
|
1113 #else /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */
|
428
|
1114
|
577
|
1115 if (n < 0)
|
428
|
1116 {
|
|
1117 *p++ = '-';
|
577
|
1118 n = -n;
|
428
|
1119 }
|
|
1120
|
577
|
1121 if (n < 10) { DIGITS_1 (1); }
|
|
1122 else if (n < 100) { DIGITS_2 (10); }
|
|
1123 else if (n < 1000) { DIGITS_3 (100); }
|
|
1124 else if (n < 10000) { DIGITS_4 (1000); }
|
|
1125 else if (n < 100000) { DIGITS_5 (10000); }
|
|
1126 else if (n < 1000000) { DIGITS_6 (100000); }
|
|
1127 else if (n < 10000000) { DIGITS_7 (1000000); }
|
|
1128 else if (n < 100000000) { DIGITS_8 (10000000); }
|
|
1129 else if (n < 1000000000) { DIGITS_9 (100000000); }
|
|
1130 #if SIZEOF_LONG == 4
|
|
1131 /* ``if (1)'' serves only to preserve editor indentation. */
|
|
1132 else if (1) { DIGITS_10 (1000000000); }
|
|
1133 #else /* SIZEOF_LONG != 4 */
|
|
1134 else if (n < 10000000000L) { DIGITS_10 (1000000000L); }
|
|
1135 else if (n < 100000000000L) { DIGITS_11 (10000000000L); }
|
|
1136 else if (n < 1000000000000L) { DIGITS_12 (100000000000L); }
|
|
1137 else if (n < 10000000000000L) { DIGITS_13 (1000000000000L); }
|
|
1138 else if (n < 100000000000000L) { DIGITS_14 (10000000000000L); }
|
|
1139 else if (n < 1000000000000000L) { DIGITS_15 (100000000000000L); }
|
|
1140 else if (n < 10000000000000000L) { DIGITS_16 (1000000000000000L); }
|
|
1141 else if (n < 100000000000000000L) { DIGITS_17 (10000000000000000L); }
|
|
1142 else if (n < 1000000000000000000L) { DIGITS_18 (100000000000000000L); }
|
|
1143 else { DIGITS_19 (1000000000000000000L); }
|
|
1144 #endif /* SIZEOF_LONG != 4 */
|
|
1145
|
428
|
1146 *p = '\0';
|
|
1147 #endif /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */
|
|
1148 }
|
577
|
1149
|
|
1150 #undef ONE_DIGIT
|
|
1151 #undef ONE_DIGIT_ADVANCE
|
|
1152
|
|
1153 #undef DIGITS_1
|
|
1154 #undef DIGITS_2
|
|
1155 #undef DIGITS_3
|
|
1156 #undef DIGITS_4
|
|
1157 #undef DIGITS_5
|
|
1158 #undef DIGITS_6
|
|
1159 #undef DIGITS_7
|
|
1160 #undef DIGITS_8
|
|
1161 #undef DIGITS_9
|
|
1162 #undef DIGITS_10
|
|
1163 #undef DIGITS_11
|
|
1164 #undef DIGITS_12
|
|
1165 #undef DIGITS_13
|
|
1166 #undef DIGITS_14
|
|
1167 #undef DIGITS_15
|
|
1168 #undef DIGITS_16
|
|
1169 #undef DIGITS_17
|
|
1170 #undef DIGITS_18
|
|
1171 #undef DIGITS_19
|
428
|
1172
|
|
1173 static void
|
442
|
1174 print_vector_internal (const char *start, const char *end,
|
428
|
1175 Lisp_Object obj,
|
|
1176 Lisp_Object printcharfun, int escapeflag)
|
|
1177 {
|
|
1178 /* This function can GC */
|
|
1179 int i;
|
|
1180 int len = XVECTOR_LENGTH (obj);
|
|
1181 int last = len;
|
|
1182 struct gcpro gcpro1, gcpro2;
|
|
1183 GCPRO2 (obj, printcharfun);
|
|
1184
|
|
1185 if (INTP (Vprint_length))
|
|
1186 {
|
|
1187 int max = XINT (Vprint_length);
|
|
1188 if (max < len) last = max;
|
|
1189 }
|
|
1190
|
|
1191 write_c_string (start, printcharfun);
|
|
1192 for (i = 0; i < last; i++)
|
|
1193 {
|
|
1194 Lisp_Object elt = XVECTOR_DATA (obj)[i];
|
|
1195 if (i != 0) write_char_internal (" ", printcharfun);
|
|
1196 print_internal (elt, printcharfun, escapeflag);
|
|
1197 }
|
|
1198 UNGCPRO;
|
|
1199 if (last != len)
|
|
1200 write_c_string (" ...", printcharfun);
|
|
1201 write_c_string (end, printcharfun);
|
|
1202 }
|
|
1203
|
|
1204 void
|
|
1205 print_cons (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1206 {
|
|
1207 /* This function can GC */
|
|
1208 struct gcpro gcpro1, gcpro2;
|
|
1209
|
|
1210 /* If print_readably is on, print (quote -foo-) as '-foo-
|
|
1211 (Yeah, this should really be what print-pretty does, but we
|
|
1212 don't have the rest of a pretty printer, and this actually
|
|
1213 has non-negligible impact on size/speed of .elc files.)
|
|
1214 */
|
|
1215 if (print_readably &&
|
|
1216 EQ (XCAR (obj), Qquote) &&
|
|
1217 CONSP (XCDR (obj)) &&
|
|
1218 NILP (XCDR (XCDR (obj))))
|
|
1219 {
|
|
1220 obj = XCAR (XCDR (obj));
|
|
1221 GCPRO2 (obj, printcharfun);
|
|
1222 write_char_internal ("\'", printcharfun);
|
|
1223 UNGCPRO;
|
|
1224 print_internal (obj, printcharfun, escapeflag);
|
|
1225 return;
|
|
1226 }
|
|
1227
|
|
1228 GCPRO2 (obj, printcharfun);
|
|
1229 write_char_internal ("(", printcharfun);
|
|
1230
|
|
1231 {
|
|
1232 int len;
|
|
1233 int max = INTP (Vprint_length) ? XINT (Vprint_length) : INT_MAX;
|
|
1234 Lisp_Object tortoise;
|
|
1235 /* Use tortoise/hare to make sure circular lists don't infloop */
|
|
1236
|
|
1237 for (tortoise = obj, len = 0;
|
|
1238 CONSP (obj);
|
|
1239 obj = XCDR (obj), len++)
|
|
1240 {
|
|
1241 if (len > 0)
|
|
1242 write_char_internal (" ", printcharfun);
|
|
1243 if (EQ (obj, tortoise) && len > 0)
|
|
1244 {
|
|
1245 if (print_readably)
|
563
|
1246 printing_unreadable_object ("circular list");
|
428
|
1247 else
|
|
1248 write_c_string ("... <circular list>", printcharfun);
|
|
1249 break;
|
|
1250 }
|
|
1251 if (len & 1)
|
|
1252 tortoise = XCDR (tortoise);
|
|
1253 if (len > max)
|
|
1254 {
|
|
1255 write_c_string ("...", printcharfun);
|
|
1256 break;
|
|
1257 }
|
|
1258 print_internal (XCAR (obj), printcharfun, escapeflag);
|
|
1259 }
|
|
1260 }
|
|
1261 if (!LISTP (obj))
|
|
1262 {
|
|
1263 write_c_string (" . ", printcharfun);
|
|
1264 print_internal (obj, printcharfun, escapeflag);
|
|
1265 }
|
|
1266 UNGCPRO;
|
|
1267
|
|
1268 write_char_internal (")", printcharfun);
|
|
1269 return;
|
|
1270 }
|
|
1271
|
|
1272 void
|
|
1273 print_vector (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1274 {
|
|
1275 print_vector_internal ("[", "]", obj, printcharfun, escapeflag);
|
|
1276 }
|
|
1277
|
|
1278 void
|
|
1279 print_string (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1280 {
|
440
|
1281 Lisp_String *s = XSTRING (obj);
|
428
|
1282 /* We distinguish between Bytecounts and Charcounts, to make
|
|
1283 Vprint_string_length work correctly under Mule. */
|
|
1284 Charcount size = string_char_length (s);
|
|
1285 Charcount max = size;
|
|
1286 Bytecount bcmax = string_length (s);
|
|
1287 struct gcpro gcpro1, gcpro2;
|
|
1288 GCPRO2 (obj, printcharfun);
|
|
1289
|
|
1290 if (INTP (Vprint_string_length) &&
|
|
1291 XINT (Vprint_string_length) < max)
|
|
1292 {
|
|
1293 max = XINT (Vprint_string_length);
|
771
|
1294 bcmax = string_index_char_to_byte (s, max);
|
428
|
1295 }
|
|
1296 if (max < 0)
|
|
1297 {
|
|
1298 max = 0;
|
|
1299 bcmax = 0;
|
|
1300 }
|
|
1301
|
|
1302 if (!escapeflag)
|
|
1303 {
|
|
1304 /* This deals with GC-relocation and Mule. */
|
|
1305 output_string (printcharfun, 0, obj, 0, bcmax);
|
|
1306 if (max < size)
|
|
1307 write_c_string (" ...", printcharfun);
|
|
1308 }
|
|
1309 else
|
|
1310 {
|
|
1311 Bytecount i, last = 0;
|
|
1312
|
|
1313 write_char_internal ("\"", printcharfun);
|
|
1314 for (i = 0; i < bcmax; i++)
|
|
1315 {
|
665
|
1316 Intbyte ch = string_byte (s, i);
|
428
|
1317 if (ch == '\"' || ch == '\\'
|
|
1318 || (ch == '\n' && print_escape_newlines))
|
|
1319 {
|
|
1320 if (i > last)
|
|
1321 {
|
|
1322 output_string (printcharfun, 0, obj, last,
|
|
1323 i - last);
|
|
1324 }
|
|
1325 if (ch == '\n')
|
|
1326 {
|
|
1327 write_c_string ("\\n", printcharfun);
|
|
1328 }
|
|
1329 else
|
|
1330 {
|
|
1331 write_char_internal ("\\", printcharfun);
|
|
1332 /* This is correct for Mule because the
|
|
1333 character is either \ or " */
|
|
1334 write_char_internal (string_data (s) + i, printcharfun);
|
|
1335 }
|
|
1336 last = i + 1;
|
|
1337 }
|
|
1338 }
|
|
1339 if (bcmax > last)
|
|
1340 {
|
|
1341 output_string (printcharfun, 0, obj, last,
|
|
1342 bcmax - last);
|
|
1343 }
|
|
1344 if (max < size)
|
|
1345 write_c_string (" ...", printcharfun);
|
|
1346 write_char_internal ("\"", printcharfun);
|
|
1347 }
|
|
1348 UNGCPRO;
|
|
1349 }
|
|
1350
|
|
1351 static void
|
|
1352 default_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
|
|
1353 int escapeflag)
|
|
1354 {
|
|
1355 struct lcrecord_header *header =
|
|
1356 (struct lcrecord_header *) XPNTR (obj);
|
|
1357 char buf[200];
|
|
1358
|
|
1359 if (print_readably)
|
563
|
1360 printing_unreadable_object
|
|
1361 ("#<%s 0x%x>",
|
|
1362 LHEADER_IMPLEMENTATION (&header->lheader)->name,
|
|
1363 header->uid);
|
428
|
1364
|
|
1365 sprintf (buf, "#<%s 0x%x>",
|
|
1366 LHEADER_IMPLEMENTATION (&header->lheader)->name,
|
|
1367 header->uid);
|
|
1368 write_c_string (buf, printcharfun);
|
|
1369 }
|
|
1370
|
|
1371 void
|
|
1372 internal_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
|
|
1373 int escapeflag)
|
|
1374 {
|
|
1375 char buf[200];
|
|
1376 sprintf (buf, "#<INTERNAL OBJECT (XEmacs bug?) (%s) 0x%lx>",
|
|
1377 XRECORD_LHEADER_IMPLEMENTATION (obj)->name,
|
|
1378 (unsigned long) XPNTR (obj));
|
|
1379 write_c_string (buf, printcharfun);
|
|
1380 }
|
|
1381
|
|
1382 void
|
|
1383 print_internal (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1384 {
|
|
1385 /* This function can GC */
|
|
1386
|
|
1387 QUIT;
|
|
1388
|
771
|
1389 #ifdef NO_PRINT_DURING_GC
|
428
|
1390 /* Emacs won't print while GCing, but an external debugger might */
|
|
1391 if (gc_in_progress) return;
|
771
|
1392 #endif
|
|
1393
|
|
1394 /* Try to check for a bogus pointer if we're in a situation where it may
|
|
1395 be likely. In such cases, crashing is counterproductive. */
|
|
1396 if (inhibit_non_essential_printing_operations || print_unbuffered)
|
|
1397 {
|
|
1398 if (XTYPE (obj) == Lisp_Type_Record)
|
|
1399 {
|
|
1400 struct lrecord_header *lheader = XRECORD_LHEADER (obj);
|
|
1401
|
|
1402 if (!debug_can_access_memory (lheader, sizeof (*lheader)))
|
|
1403 {
|
|
1404 char buf[128];
|
|
1405
|
|
1406 sprintf (buf, "#<EMACS BUG: BAD MEMORY %p>", lheader);
|
|
1407 write_c_string (buf, printcharfun);
|
|
1408 return;
|
|
1409 }
|
|
1410 else
|
|
1411 {
|
|
1412 const struct lrecord_implementation *impl;
|
|
1413
|
|
1414 if ((int) lheader->type >= lrecord_type_count)
|
|
1415 {
|
|
1416 char buf[128];
|
|
1417
|
|
1418 sprintf (buf, "#<EMACS BUG: bad type %d BAD MEMORY %p>",
|
|
1419 lheader->type, lheader);
|
|
1420 write_c_string (buf, printcharfun);
|
|
1421 return;
|
|
1422 }
|
|
1423
|
|
1424 impl = LHEADER_IMPLEMENTATION (lheader);
|
|
1425 if (!debug_can_access_memory
|
|
1426 (lheader,
|
|
1427 (impl->size_in_bytes_method ?
|
|
1428 impl->size_in_bytes_method (lheader) :
|
|
1429 impl->static_size)))
|
|
1430 {
|
|
1431 char buf[128];
|
|
1432
|
|
1433 sprintf (buf, "#<EMACS BUG: type %s BAD MEMORY %p>",
|
|
1434 impl->name, lheader);
|
|
1435 write_c_string (buf, printcharfun);
|
|
1436 return;
|
|
1437 }
|
|
1438
|
|
1439 if (STRINGP (obj))
|
|
1440 {
|
|
1441 Lisp_String *l = (Lisp_String *) lheader;
|
|
1442 if (!debug_can_access_memory
|
|
1443 (l->data, l->size))
|
|
1444 {
|
|
1445 char buf[128];
|
|
1446
|
|
1447 sprintf (buf, "#<EMACS BUG: %p (BAD STRING DATA %p)>",
|
|
1448 lheader, l->data);
|
|
1449 write_c_string (buf, printcharfun);
|
|
1450 return;
|
|
1451 }
|
|
1452 }
|
|
1453 }
|
|
1454 }
|
|
1455 }
|
428
|
1456
|
|
1457 #ifdef I18N3
|
|
1458 /* #### Both input and output streams should have a flag associated
|
|
1459 with them indicating whether output to that stream, or strings
|
|
1460 read from the stream, get translated using Fgettext(). Such a
|
|
1461 stream is called a "translating stream". For the minibuffer and
|
|
1462 external-debugging-output this is always true on output, and
|
|
1463 with-output-to-temp-buffer sets the flag to true for the buffer
|
|
1464 it creates. This flag should also be user-settable. Perhaps it
|
|
1465 should be split up into two flags, one for input and one for
|
|
1466 output. */
|
|
1467 #endif
|
|
1468
|
|
1469 /* Detect circularities and truncate them.
|
|
1470 No need to offer any alternative--this is better than an error. */
|
|
1471 if (CONSP (obj) || VECTORP (obj) || COMPILED_FUNCTIONP (obj))
|
|
1472 {
|
|
1473 int i;
|
|
1474 for (i = 0; i < print_depth; i++)
|
|
1475 if (EQ (obj, being_printed[i]))
|
|
1476 {
|
603
|
1477 char buf[DECIMAL_PRINT_SIZE (long) + 1];
|
428
|
1478 *buf = '#';
|
|
1479 long_to_string (buf + 1, i);
|
|
1480 write_c_string (buf, printcharfun);
|
|
1481 return;
|
|
1482 }
|
|
1483 }
|
|
1484
|
|
1485 being_printed[print_depth] = obj;
|
|
1486 print_depth++;
|
|
1487
|
|
1488 if (print_depth > PRINT_CIRCLE)
|
563
|
1489 signal_error (Qstack_overflow, "Apparently circular structure being printed", Qunbound);
|
428
|
1490
|
|
1491 switch (XTYPE (obj))
|
|
1492 {
|
|
1493 case Lisp_Type_Int_Even:
|
|
1494 case Lisp_Type_Int_Odd:
|
|
1495 {
|
603
|
1496 char buf[DECIMAL_PRINT_SIZE (EMACS_INT)];
|
428
|
1497 long_to_string (buf, XINT (obj));
|
|
1498 write_c_string (buf, printcharfun);
|
|
1499 break;
|
|
1500 }
|
|
1501
|
|
1502 case Lisp_Type_Char:
|
|
1503 {
|
|
1504 /* God intended that this be #\..., you know. */
|
|
1505 char buf[16];
|
|
1506 Emchar ch = XCHAR (obj);
|
|
1507 char *p = buf;
|
|
1508 *p++ = '?';
|
434
|
1509 if (ch < 32)
|
|
1510 {
|
|
1511 *p++ = '\\';
|
|
1512 switch (ch)
|
|
1513 {
|
|
1514 case '\t': *p++ = 't'; break;
|
|
1515 case '\n': *p++ = 'n'; break;
|
|
1516 case '\r': *p++ = 'r'; break;
|
|
1517 default:
|
|
1518 *p++ = '^';
|
|
1519 *p++ = ch + 64;
|
|
1520 if ((ch + 64) == '\\')
|
|
1521 *p++ = '\\';
|
|
1522 break;
|
|
1523 }
|
|
1524 }
|
|
1525 else if (ch < 127)
|
428
|
1526 {
|
434
|
1527 /* syntactically special characters should be escaped. */
|
|
1528 switch (ch)
|
|
1529 {
|
|
1530 case ' ':
|
|
1531 case '"':
|
|
1532 case '#':
|
|
1533 case '\'':
|
|
1534 case '(':
|
|
1535 case ')':
|
|
1536 case ',':
|
|
1537 case '.':
|
|
1538 case ';':
|
|
1539 case '?':
|
|
1540 case '[':
|
|
1541 case '\\':
|
|
1542 case ']':
|
|
1543 case '`':
|
|
1544 *p++ = '\\';
|
|
1545 }
|
|
1546 *p++ = ch;
|
428
|
1547 }
|
|
1548 else if (ch == 127)
|
434
|
1549 {
|
|
1550 *p++ = '\\', *p++ = '^', *p++ = '?';
|
|
1551 }
|
|
1552 else if (ch < 160)
|
428
|
1553 {
|
|
1554 *p++ = '\\', *p++ = '^';
|
665
|
1555 p += set_charptr_emchar ((Intbyte *) p, ch + 64);
|
428
|
1556 }
|
|
1557 else
|
434
|
1558 {
|
665
|
1559 p += set_charptr_emchar ((Intbyte *) p, ch);
|
434
|
1560 }
|
440
|
1561
|
665
|
1562 output_string (printcharfun, (Intbyte *) buf, Qnil, 0, p - buf);
|
434
|
1563
|
428
|
1564 break;
|
|
1565 }
|
|
1566
|
|
1567 case Lisp_Type_Record:
|
|
1568 {
|
|
1569 struct lrecord_header *lheader = XRECORD_LHEADER (obj);
|
|
1570 struct gcpro gcpro1, gcpro2;
|
|
1571
|
|
1572 if (CONSP (obj) || VECTORP(obj))
|
|
1573 {
|
|
1574 /* If deeper than spec'd depth, print placeholder. */
|
|
1575 if (INTP (Vprint_level)
|
|
1576 && print_depth > XINT (Vprint_level))
|
|
1577 {
|
|
1578 GCPRO2 (obj, printcharfun);
|
|
1579 write_c_string ("...", printcharfun);
|
|
1580 UNGCPRO;
|
|
1581 break;
|
|
1582 }
|
|
1583 }
|
|
1584
|
|
1585 GCPRO2 (obj, printcharfun);
|
|
1586 if (LHEADER_IMPLEMENTATION (lheader)->printer)
|
|
1587 ((LHEADER_IMPLEMENTATION (lheader)->printer)
|
|
1588 (obj, printcharfun, escapeflag));
|
|
1589 else
|
|
1590 default_object_printer (obj, printcharfun, escapeflag);
|
|
1591 UNGCPRO;
|
|
1592 break;
|
|
1593 }
|
|
1594
|
|
1595 default:
|
|
1596 {
|
|
1597 #ifdef ERROR_CHECK_TYPECHECK
|
|
1598 abort ();
|
|
1599 #else /* not ERROR_CHECK_TYPECHECK */
|
|
1600 char buf[128];
|
|
1601 /* We're in trouble if this happens! */
|
|
1602 if (print_readably)
|
571
|
1603 signal_error (Qinternal_error, "printing illegal data type #o%03o",
|
579
|
1604 make_int (XTYPE (obj)));
|
428
|
1605 write_c_string ("#<EMACS BUG: ILLEGAL DATATYPE ",
|
|
1606 printcharfun);
|
|
1607 sprintf (buf, "(#o%3o)", (int) XTYPE (obj));
|
|
1608 write_c_string (buf, printcharfun);
|
|
1609 write_c_string
|
|
1610 (" Save your buffers immediately and please report this bug>",
|
|
1611 printcharfun);
|
|
1612 #endif /* not ERROR_CHECK_TYPECHECK */
|
|
1613 break;
|
|
1614 }
|
|
1615 }
|
|
1616
|
|
1617 print_depth--;
|
|
1618 }
|
|
1619
|
|
1620
|
|
1621 #ifdef LISP_FLOAT_TYPE
|
|
1622 void
|
|
1623 print_float (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1624 {
|
|
1625 char pigbuf[350]; /* see comments in float_to_string */
|
|
1626
|
|
1627 float_to_string (pigbuf, XFLOAT_DATA (obj));
|
|
1628 write_c_string (pigbuf, printcharfun);
|
|
1629 }
|
|
1630 #endif /* LISP_FLOAT_TYPE */
|
|
1631
|
|
1632 void
|
|
1633 print_symbol (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1634 {
|
|
1635 /* This function can GC */
|
|
1636 /* #### Bug!! (intern "") isn't printed in some distinguished way */
|
|
1637 /* #### (the reader also loses on it) */
|
440
|
1638 Lisp_String *name = symbol_name (XSYMBOL (obj));
|
428
|
1639 Bytecount size = string_length (name);
|
|
1640 struct gcpro gcpro1, gcpro2;
|
|
1641
|
|
1642 if (!escapeflag)
|
|
1643 {
|
|
1644 /* This deals with GC-relocation */
|
|
1645 Lisp_Object nameobj;
|
|
1646 XSETSTRING (nameobj, name);
|
|
1647 output_string (printcharfun, 0, nameobj, 0, size);
|
|
1648 return;
|
|
1649 }
|
|
1650 GCPRO2 (obj, printcharfun);
|
|
1651
|
|
1652 /* If we print an uninterned symbol as part of a complex object and
|
|
1653 the flag print-gensym is non-nil, prefix it with #n= to read the
|
|
1654 object back with the #n# reader syntax later if needed. */
|
|
1655 if (!NILP (Vprint_gensym)
|
442
|
1656 /* #### Test whether this produces a noticeable slow-down for
|
428
|
1657 printing when print-gensym is non-nil. */
|
|
1658 && !EQ (obj, oblookup (Vobarray,
|
|
1659 string_data (symbol_name (XSYMBOL (obj))),
|
|
1660 string_length (symbol_name (XSYMBOL (obj))))))
|
|
1661 {
|
|
1662 if (print_depth > 1)
|
|
1663 {
|
|
1664 Lisp_Object tem = Fassq (obj, Vprint_gensym_alist);
|
|
1665 if (CONSP (tem))
|
|
1666 {
|
|
1667 write_char_internal ("#", printcharfun);
|
|
1668 print_internal (XCDR (tem), printcharfun, escapeflag);
|
|
1669 write_char_internal ("#", printcharfun);
|
446
|
1670 UNGCPRO;
|
428
|
1671 return;
|
|
1672 }
|
|
1673 else
|
|
1674 {
|
|
1675 if (CONSP (Vprint_gensym_alist))
|
|
1676 {
|
|
1677 /* Vprint_gensym_alist is exposed to Lisp, so we
|
|
1678 have to be careful. */
|
|
1679 CHECK_CONS (XCAR (Vprint_gensym_alist));
|
|
1680 CHECK_INT (XCDR (XCAR (Vprint_gensym_alist)));
|
|
1681 XSETINT (tem, XINT (XCDR (XCAR (Vprint_gensym_alist))) + 1);
|
|
1682 }
|
|
1683 else
|
|
1684 XSETINT (tem, 1);
|
|
1685 Vprint_gensym_alist = Fcons (Fcons (obj, tem), Vprint_gensym_alist);
|
|
1686
|
|
1687 write_char_internal ("#", printcharfun);
|
|
1688 print_internal (tem, printcharfun, escapeflag);
|
|
1689 write_char_internal ("=", printcharfun);
|
|
1690 }
|
|
1691 }
|
|
1692 write_c_string ("#:", printcharfun);
|
|
1693 }
|
|
1694
|
|
1695 /* Does it look like an integer or a float? */
|
|
1696 {
|
665
|
1697 Intbyte *data = string_data (name);
|
428
|
1698 Bytecount confusing = 0;
|
|
1699
|
|
1700 if (size == 0)
|
|
1701 goto not_yet_confused; /* Really confusing */
|
|
1702 else if (isdigit (data[0]))
|
|
1703 confusing = 0;
|
|
1704 else if (size == 1)
|
|
1705 goto not_yet_confused;
|
|
1706 else if (data[0] == '-' || data[0] == '+')
|
|
1707 confusing = 1;
|
|
1708 else
|
|
1709 goto not_yet_confused;
|
|
1710
|
|
1711 for (; confusing < size; confusing++)
|
|
1712 {
|
|
1713 if (!isdigit (data[confusing]))
|
|
1714 {
|
|
1715 confusing = 0;
|
|
1716 break;
|
|
1717 }
|
|
1718 }
|
|
1719 not_yet_confused:
|
|
1720
|
|
1721 #ifdef LISP_FLOAT_TYPE
|
|
1722 if (!confusing)
|
|
1723 /* #### Ugh, this is needlessly complex and slow for what we
|
|
1724 need here. It might be a good idea to copy equivalent code
|
|
1725 from FSF. --hniksic */
|
|
1726 confusing = isfloat_string ((char *) data);
|
|
1727 #endif
|
|
1728 if (confusing)
|
|
1729 write_char_internal ("\\", printcharfun);
|
|
1730 }
|
|
1731
|
|
1732 {
|
|
1733 Lisp_Object nameobj;
|
|
1734 Bytecount i;
|
|
1735 Bytecount last = 0;
|
|
1736
|
|
1737 XSETSTRING (nameobj, name);
|
|
1738 for (i = 0; i < size; i++)
|
|
1739 {
|
|
1740 switch (string_byte (name, i))
|
|
1741 {
|
|
1742 case 0: case 1: case 2: case 3:
|
|
1743 case 4: case 5: case 6: case 7:
|
|
1744 case 8: case 9: case 10: case 11:
|
|
1745 case 12: case 13: case 14: case 15:
|
|
1746 case 16: case 17: case 18: case 19:
|
|
1747 case 20: case 21: case 22: case 23:
|
|
1748 case 24: case 25: case 26: case 27:
|
|
1749 case 28: case 29: case 30: case 31:
|
|
1750 case ' ': case '\"': case '\\': case '\'':
|
|
1751 case ';': case '#' : case '(' : case ')':
|
|
1752 case ',': case '.' : case '`' :
|
|
1753 case '[': case ']' : case '?' :
|
|
1754 if (i > last)
|
|
1755 output_string (printcharfun, 0, nameobj, last, i - last);
|
|
1756 write_char_internal ("\\", printcharfun);
|
|
1757 last = i;
|
|
1758 }
|
|
1759 }
|
|
1760 output_string (printcharfun, 0, nameobj, last, size - last);
|
|
1761 }
|
|
1762 UNGCPRO;
|
|
1763 }
|
|
1764
|
|
1765
|
442
|
1766 /* Useful on systems or in places where writing to stdout is unavailable or
|
|
1767 not working. */
|
428
|
1768
|
|
1769 static int alternate_do_pointer;
|
|
1770 static char alternate_do_string[5000];
|
|
1771
|
|
1772 DEFUN ("alternate-debugging-output", Falternate_debugging_output, 1, 1, 0, /*
|
|
1773 Append CHARACTER to the array `alternate_do_string'.
|
|
1774 This can be used in place of `external-debugging-output' as a function
|
|
1775 to be passed to `print'. Before calling `print', set `alternate_do_pointer'
|
|
1776 to 0.
|
|
1777 */
|
|
1778 (character))
|
|
1779 {
|
665
|
1780 Intbyte str[MAX_EMCHAR_LEN];
|
428
|
1781 Bytecount len;
|
|
1782
|
|
1783 CHECK_CHAR_COERCE_INT (character);
|
|
1784 len = set_charptr_emchar (str, XCHAR (character));
|
771
|
1785 write_string_to_alternate_debugging_output (str, len);
|
|
1786
|
|
1787 return character;
|
|
1788 }
|
|
1789
|
|
1790 static void
|
|
1791 write_string_to_alternate_debugging_output (Intbyte *str, Bytecount len)
|
|
1792 {
|
|
1793 int extlen;
|
|
1794 const Extbyte *extptr;
|
|
1795 #if 0 /* We want to see the internal representation, don't we? */
|
|
1796 if (initialized && !inhibit_non_essential_printing_operations)
|
|
1797 TO_EXTERNAL_FORMAT (DATA, (str, len),
|
|
1798 ALLOCA, (extptr, extlen),
|
|
1799 Qterminal);
|
|
1800 else
|
|
1801 #endif /* 0 */
|
|
1802 {
|
|
1803 extlen = len;
|
|
1804 extptr = (Extbyte *) str;
|
|
1805 }
|
428
|
1806 memcpy (alternate_do_string + alternate_do_pointer, extptr, extlen);
|
|
1807 alternate_do_pointer += extlen;
|
|
1808 alternate_do_string[alternate_do_pointer] = 0;
|
|
1809 }
|
|
1810
|
|
1811 DEFUN ("external-debugging-output", Fexternal_debugging_output, 1, 3, 0, /*
|
|
1812 Write CHAR-OR-STRING to stderr or stdout.
|
|
1813 If optional arg STDOUT-P is non-nil, write to stdout; otherwise, write
|
|
1814 to stderr. You can use this function to write directly to the terminal.
|
|
1815 This function can be used as the STREAM argument of Fprint() or the like.
|
|
1816
|
442
|
1817 Under MS Windows, this writes output to the console window (which is
|
|
1818 created, if necessary), unless XEmacs is being run noninteractively
|
|
1819 \(i.e. using the `-batch' argument).
|
|
1820
|
428
|
1821 If you have opened a termscript file (using `open-termscript'), then
|
|
1822 the output also will be logged to this file.
|
|
1823 */
|
|
1824 (char_or_string, stdout_p, device))
|
|
1825 {
|
|
1826 FILE *file = 0;
|
|
1827 struct console *con = 0;
|
|
1828
|
|
1829 if (NILP (device))
|
|
1830 {
|
|
1831 if (!NILP (stdout_p))
|
|
1832 file = stdout;
|
|
1833 else
|
|
1834 file = stderr;
|
|
1835 }
|
|
1836 else
|
|
1837 {
|
|
1838 CHECK_LIVE_DEVICE (device);
|
|
1839 if (!DEVICE_TTY_P (XDEVICE (device)) &&
|
|
1840 !DEVICE_STREAM_P (XDEVICE (device)))
|
563
|
1841 wtaerror ("Must be tty or stream device", device);
|
428
|
1842 con = XCONSOLE (DEVICE_CONSOLE (XDEVICE (device)));
|
|
1843 if (DEVICE_TTY_P (XDEVICE (device)))
|
|
1844 file = 0;
|
|
1845 else if (!NILP (stdout_p))
|
|
1846 file = CONSOLE_STREAM_DATA (con)->out;
|
|
1847 else
|
|
1848 file = CONSOLE_STREAM_DATA (con)->err;
|
|
1849 }
|
|
1850
|
|
1851 if (STRINGP (char_or_string))
|
|
1852 write_string_to_stdio_stream (file, con,
|
|
1853 XSTRING_DATA (char_or_string),
|
771
|
1854 XSTRING_LENGTH (char_or_string),
|
|
1855 print_unbuffered);
|
428
|
1856 else
|
|
1857 {
|
665
|
1858 Intbyte str[MAX_EMCHAR_LEN];
|
428
|
1859 Bytecount len;
|
|
1860
|
|
1861 CHECK_CHAR_COERCE_INT (char_or_string);
|
|
1862 len = set_charptr_emchar (str, XCHAR (char_or_string));
|
771
|
1863 write_string_to_stdio_stream (file, con, str, len, print_unbuffered);
|
428
|
1864 }
|
|
1865
|
|
1866 return char_or_string;
|
|
1867 }
|
|
1868
|
|
1869 DEFUN ("open-termscript", Fopen_termscript, 1, 1, "FOpen termscript file: ", /*
|
444
|
1870 Start writing all terminal output to FILENAME as well as the terminal.
|
|
1871 FILENAME = nil means just close any termscript file currently open.
|
428
|
1872 */
|
444
|
1873 (filename))
|
428
|
1874 {
|
|
1875 /* This function can GC */
|
|
1876 if (termscript != 0)
|
|
1877 {
|
771
|
1878 retry_fclose (termscript);
|
444
|
1879 termscript = 0;
|
|
1880 }
|
|
1881
|
|
1882 if (! NILP (filename))
|
|
1883 {
|
|
1884 filename = Fexpand_file_name (filename, Qnil);
|
771
|
1885 termscript = qxe_fopen (XSTRING_DATA (filename), "w");
|
428
|
1886 if (termscript == NULL)
|
563
|
1887 report_file_error ("Opening termscript", filename);
|
428
|
1888 }
|
|
1889 return Qnil;
|
|
1890 }
|
|
1891
|
440
|
1892 static int debug_print_length = 50;
|
|
1893 static int debug_print_level = 15;
|
|
1894 static int debug_print_readably = -1;
|
428
|
1895
|
771
|
1896 /* Debugging kludge -- unbuffered */
|
428
|
1897 static void
|
|
1898 debug_print_no_newline (Lisp_Object debug_print_obj)
|
|
1899 {
|
|
1900 /* This function can GC */
|
440
|
1901 int save_print_readably = print_readably;
|
|
1902 int save_print_depth = print_depth;
|
|
1903 Lisp_Object save_Vprint_length = Vprint_length;
|
|
1904 Lisp_Object save_Vprint_level = Vprint_level;
|
|
1905 Lisp_Object save_Vinhibit_quit = Vinhibit_quit;
|
428
|
1906 struct gcpro gcpro1, gcpro2, gcpro3;
|
440
|
1907 GCPRO3 (save_Vprint_level, save_Vprint_length, save_Vinhibit_quit);
|
428
|
1908
|
|
1909 print_depth = 0;
|
440
|
1910 print_readably = debug_print_readably != -1 ? debug_print_readably : 0;
|
428
|
1911 print_unbuffered++;
|
|
1912 /* Could use unwind-protect, but why bother? */
|
|
1913 if (debug_print_length > 0)
|
|
1914 Vprint_length = make_int (debug_print_length);
|
|
1915 if (debug_print_level > 0)
|
|
1916 Vprint_level = make_int (debug_print_level);
|
440
|
1917
|
428
|
1918 print_internal (debug_print_obj, Qexternal_debugging_output, 1);
|
442
|
1919 alternate_do_pointer = 0;
|
|
1920 print_internal (debug_print_obj, Qalternate_debugging_output, 1);
|
|
1921 #ifdef WIN32_NATIVE
|
|
1922 /* Write out to the debugger, as well */
|
|
1923 print_internal (debug_print_obj, Qmswindows_debugging_output, 1);
|
|
1924 #endif
|
440
|
1925
|
|
1926 Vinhibit_quit = save_Vinhibit_quit;
|
|
1927 Vprint_level = save_Vprint_level;
|
|
1928 Vprint_length = save_Vprint_length;
|
|
1929 print_depth = save_print_depth;
|
|
1930 print_readably = save_print_readably;
|
428
|
1931 print_unbuffered--;
|
|
1932 UNGCPRO;
|
|
1933 }
|
|
1934
|
|
1935 void
|
|
1936 debug_print (Lisp_Object debug_print_obj)
|
|
1937 {
|
|
1938 debug_print_no_newline (debug_print_obj);
|
771
|
1939 debug_out ("\n");
|
428
|
1940 }
|
|
1941
|
|
1942 /* Debugging kludge -- unbuffered */
|
|
1943 /* This function provided for the benefit of the debugger. */
|
|
1944 void
|
|
1945 debug_backtrace (void)
|
|
1946 {
|
|
1947 /* This function can GC */
|
|
1948 int old_print_readably = print_readably;
|
|
1949 int old_print_depth = print_depth;
|
|
1950 Lisp_Object old_print_length = Vprint_length;
|
|
1951 Lisp_Object old_print_level = Vprint_level;
|
|
1952 Lisp_Object old_inhibit_quit = Vinhibit_quit;
|
|
1953
|
|
1954 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
1955 GCPRO3 (old_print_level, old_print_length, old_inhibit_quit);
|
|
1956
|
|
1957 print_depth = 0;
|
|
1958 print_readably = 0;
|
|
1959 print_unbuffered++;
|
|
1960 /* Could use unwind-protect, but why bother? */
|
|
1961 if (debug_print_length > 0)
|
|
1962 Vprint_length = make_int (debug_print_length);
|
|
1963 if (debug_print_level > 0)
|
|
1964 Vprint_level = make_int (debug_print_level);
|
|
1965
|
|
1966 Fbacktrace (Qexternal_debugging_output, Qt);
|
|
1967 stderr_out ("\n");
|
|
1968
|
|
1969 Vinhibit_quit = old_inhibit_quit;
|
|
1970 Vprint_level = old_print_level;
|
|
1971 Vprint_length = old_print_length;
|
|
1972 print_depth = old_print_depth;
|
|
1973 print_readably = old_print_readably;
|
|
1974 print_unbuffered--;
|
|
1975
|
|
1976 UNGCPRO;
|
|
1977 }
|
|
1978
|
|
1979 void
|
|
1980 debug_short_backtrace (int length)
|
|
1981 {
|
|
1982 int first = 1;
|
|
1983 struct backtrace *bt = backtrace_list;
|
771
|
1984 debug_out (" [");
|
428
|
1985 while (length > 0 && bt)
|
|
1986 {
|
|
1987 if (!first)
|
|
1988 {
|
771
|
1989 debug_out (", ");
|
428
|
1990 }
|
|
1991 if (COMPILED_FUNCTIONP (*bt->function))
|
|
1992 {
|
|
1993 #if defined(COMPILED_FUNCTION_ANNOTATION_HACK)
|
|
1994 Lisp_Object ann =
|
|
1995 compiled_function_annotation (XCOMPILED_FUNCTION (*bt->function));
|
|
1996 #else
|
|
1997 Lisp_Object ann = Qnil;
|
|
1998 #endif
|
|
1999 if (!NILP (ann))
|
|
2000 {
|
771
|
2001 debug_out ("<compiled-function from ");
|
428
|
2002 debug_print_no_newline (ann);
|
771
|
2003 debug_out (">");
|
428
|
2004 }
|
|
2005 else
|
|
2006 {
|
771
|
2007 debug_out ("<compiled-function of unknown origin>");
|
428
|
2008 }
|
|
2009 }
|
|
2010 else
|
|
2011 debug_print_no_newline (*bt->function);
|
|
2012 first = 0;
|
|
2013 length--;
|
|
2014 bt = bt->next;
|
|
2015 }
|
771
|
2016 debug_out ("]\n");
|
428
|
2017 }
|
|
2018
|
|
2019
|
|
2020 void
|
|
2021 syms_of_print (void)
|
|
2022 {
|
563
|
2023 DEFSYMBOL (Qstandard_output);
|
428
|
2024
|
563
|
2025 DEFSYMBOL (Qprint_length);
|
428
|
2026
|
563
|
2027 DEFSYMBOL (Qprint_string_length);
|
428
|
2028
|
563
|
2029 DEFSYMBOL (Qdisplay_error);
|
|
2030 DEFSYMBOL (Qprint_message_label);
|
428
|
2031
|
|
2032 DEFSUBR (Fprin1);
|
|
2033 DEFSUBR (Fprin1_to_string);
|
|
2034 DEFSUBR (Fprinc);
|
|
2035 DEFSUBR (Fprint);
|
|
2036 DEFSUBR (Ferror_message_string);
|
|
2037 DEFSUBR (Fdisplay_error);
|
|
2038 DEFSUBR (Fterpri);
|
|
2039 DEFSUBR (Fwrite_char);
|
|
2040 DEFSUBR (Falternate_debugging_output);
|
|
2041 DEFSUBR (Fexternal_debugging_output);
|
|
2042 DEFSUBR (Fopen_termscript);
|
563
|
2043 DEFSYMBOL (Qexternal_debugging_output);
|
|
2044 DEFSYMBOL (Qalternate_debugging_output);
|
442
|
2045 #ifdef HAVE_MS_WINDOWS
|
563
|
2046 DEFSYMBOL (Qmswindows_debugging_output);
|
442
|
2047 #endif
|
428
|
2048 DEFSUBR (Fwith_output_to_temp_buffer);
|
|
2049 }
|
|
2050
|
|
2051 void
|
|
2052 reinit_vars_of_print (void)
|
|
2053 {
|
|
2054 alternate_do_pointer = 0;
|
|
2055 }
|
|
2056
|
|
2057 void
|
|
2058 vars_of_print (void)
|
|
2059 {
|
|
2060 reinit_vars_of_print ();
|
|
2061
|
|
2062 DEFVAR_LISP ("standard-output", &Vstandard_output /*
|
|
2063 Output stream `print' uses by default for outputting a character.
|
|
2064 This may be any function of one argument.
|
|
2065 It may also be a buffer (output is inserted before point)
|
|
2066 or a marker (output is inserted and the marker is advanced)
|
|
2067 or the symbol t (output appears in the minibuffer line).
|
|
2068 */ );
|
|
2069 Vstandard_output = Qt;
|
|
2070
|
|
2071 #ifdef LISP_FLOAT_TYPE
|
|
2072 DEFVAR_LISP ("float-output-format", &Vfloat_output_format /*
|
|
2073 The format descriptor string that lisp uses to print floats.
|
|
2074 This is a %-spec like those accepted by `printf' in C,
|
|
2075 but with some restrictions. It must start with the two characters `%.'.
|
|
2076 After that comes an integer precision specification,
|
|
2077 and then a letter which controls the format.
|
|
2078 The letters allowed are `e', `f' and `g'.
|
|
2079 Use `e' for exponential notation "DIG.DIGITSeEXPT"
|
|
2080 Use `f' for decimal point notation "DIGITS.DIGITS".
|
|
2081 Use `g' to choose the shorter of those two formats for the number at hand.
|
|
2082 The precision in any of these cases is the number of digits following
|
|
2083 the decimal point. With `f', a precision of 0 means to omit the
|
|
2084 decimal point. 0 is not allowed with `f' or `g'.
|
|
2085
|
|
2086 A value of nil means to use `%.16g'.
|
|
2087
|
|
2088 Regardless of the value of `float-output-format', a floating point number
|
|
2089 will never be printed in such a way that it is ambiguous with an integer;
|
|
2090 that is, a floating-point number will always be printed with a decimal
|
|
2091 point and/or an exponent, even if the digits following the decimal point
|
|
2092 are all zero. This is to preserve read-equivalence.
|
|
2093 */ );
|
|
2094 Vfloat_output_format = Qnil;
|
|
2095 #endif /* LISP_FLOAT_TYPE */
|
|
2096
|
|
2097 DEFVAR_LISP ("print-length", &Vprint_length /*
|
|
2098 Maximum length of list or vector to print before abbreviating.
|
|
2099 A value of nil means no limit.
|
|
2100 */ );
|
|
2101 Vprint_length = Qnil;
|
|
2102
|
|
2103 DEFVAR_LISP ("print-string-length", &Vprint_string_length /*
|
|
2104 Maximum length of string to print before abbreviating.
|
|
2105 A value of nil means no limit.
|
|
2106 */ );
|
|
2107 Vprint_string_length = Qnil;
|
|
2108
|
|
2109 DEFVAR_LISP ("print-level", &Vprint_level /*
|
|
2110 Maximum depth of list nesting to print before abbreviating.
|
|
2111 A value of nil means no limit.
|
|
2112 */ );
|
|
2113 Vprint_level = Qnil;
|
|
2114
|
|
2115 DEFVAR_BOOL ("print-escape-newlines", &print_escape_newlines /*
|
|
2116 Non-nil means print newlines in strings as backslash-n.
|
|
2117 */ );
|
|
2118 print_escape_newlines = 0;
|
|
2119
|
|
2120 DEFVAR_BOOL ("print-readably", &print_readably /*
|
|
2121 If non-nil, then all objects will be printed in a readable form.
|
|
2122 If an object has no readable representation, then an error is signalled.
|
|
2123 When print-readably is true, compiled-function objects will be written in
|
|
2124 #[...] form instead of in #<compiled-function [...]> form, and two-element
|
|
2125 lists of the form (quote object) will be written as the equivalent 'object.
|
|
2126 Do not SET this variable; bind it instead.
|
|
2127 */ );
|
|
2128 print_readably = 0;
|
|
2129
|
|
2130 /* #### I think this should default to t. But we'd better wait
|
|
2131 until we see that it works out. */
|
|
2132 DEFVAR_LISP ("print-gensym", &Vprint_gensym /*
|
|
2133 If non-nil, then uninterned symbols will be printed specially.
|
|
2134 Uninterned symbols are those which are not present in `obarray', that is,
|
|
2135 those which were made with `make-symbol' or by calling `intern' with a
|
|
2136 second argument.
|
|
2137
|
|
2138 When print-gensym is true, such symbols will be preceded by "#:",
|
|
2139 which causes the reader to create a new symbol instead of interning
|
|
2140 and returning an existing one. Beware: the #: syntax creates a new
|
|
2141 symbol each time it is seen, so if you print an object which contains
|
|
2142 two pointers to the same uninterned symbol, `read' will not duplicate
|
|
2143 that structure.
|
|
2144
|
|
2145 If the value of `print-gensym' is a cons cell, then in addition
|
|
2146 refrain from clearing `print-gensym-alist' on entry to and exit from
|
|
2147 printing functions, so that the use of #...# and #...= can carry over
|
|
2148 for several separately printed objects.
|
|
2149 */ );
|
|
2150 Vprint_gensym = Qnil;
|
|
2151
|
|
2152 DEFVAR_LISP ("print-gensym-alist", &Vprint_gensym_alist /*
|
|
2153 Association list of elements (GENSYM . N) to guide use of #N# and #N=.
|
|
2154 In each element, GENSYM is an uninterned symbol that has been associated
|
|
2155 with #N= for the specified value of N.
|
|
2156 */ );
|
|
2157 Vprint_gensym_alist = Qnil;
|
|
2158
|
|
2159 DEFVAR_LISP ("print-message-label", &Vprint_message_label /*
|
|
2160 Label for minibuffer messages created with `print'. This should
|
|
2161 generally be bound with `let' rather than set. (See `display-message'.)
|
|
2162 */ );
|
|
2163 Vprint_message_label = Qprint;
|
|
2164 }
|