428
|
1 /* Lisp object printing and output streams.
|
|
2 Copyright (C) 1985, 1986, 1988, 1992-1995 Free Software Foundation, Inc.
|
793
|
3 Copyright (C) 1995, 1996, 2000, 2001, 2002 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 {
|
793
|
327 cclen = string_offset_byte_to_char_len (reloc, offset, len);
|
771
|
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))
|
793
|
408 ccoff = string_index_byte_to_char (reloc, offset);
|
771
|
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
|
793
|
567 void
|
|
568 write_eistring (const Eistring *ei, Lisp_Object stream)
|
|
569 {
|
|
570 write_string_1 (eidata (ei), eilen (ei), stream);
|
|
571 }
|
|
572
|
771
|
573 /* Write a printf-style string to STREAM; see output_string(). */
|
|
574
|
|
575 void
|
|
576 write_fmt_string (Lisp_Object stream, const CIntbyte *fmt, ...)
|
|
577 {
|
|
578 va_list va;
|
|
579 Intbyte *str;
|
|
580 Bytecount len;
|
|
581 int count;
|
|
582
|
|
583 va_start (va, fmt);
|
|
584 str = emacs_vsprintf_malloc (fmt, va, &len);
|
|
585 va_end (va);
|
|
586 count = record_unwind_protect_freeing (str);
|
|
587 write_string_1 (str, len, stream);
|
|
588 unbind_to (count);
|
|
589 }
|
|
590
|
|
591 /* Write a printf-style string to STREAM, where the arguments are
|
|
592 Lisp objects and not C strings or integers; see output_string().
|
|
593
|
|
594 #### It shouldn't be necessary to specify the number of arguments.
|
|
595 This would require some rewriting of the doprnt() functions, though. */
|
|
596
|
|
597 void
|
|
598 write_fmt_string_lisp (Lisp_Object stream, const CIntbyte *fmt, int nargs, ...)
|
|
599 {
|
|
600 Lisp_Object *args = alloca_array (Lisp_Object, nargs);
|
|
601 va_list va;
|
|
602 int i;
|
|
603 Intbyte *str;
|
|
604 Bytecount len;
|
|
605 int count;
|
|
606
|
|
607 va_start (va, nargs);
|
|
608 for (i = 0; i < nargs; i++)
|
|
609 args[i] = va_arg (va, Lisp_Object);
|
|
610 va_end (va);
|
|
611 str = emacs_vsprintf_malloc_lisp (fmt, Qnil, nargs, args, &len);
|
|
612 count = record_unwind_protect_freeing (str);
|
|
613 write_string_1 (str, len, stream);
|
|
614 unbind_to (count);
|
|
615 }
|
|
616
|
|
617 void
|
|
618 stderr_out_lisp (const CIntbyte *fmt, int nargs, ...)
|
|
619 {
|
|
620 Lisp_Object *args = alloca_array (Lisp_Object, nargs);
|
|
621 va_list va;
|
|
622 int i;
|
|
623 Intbyte *str;
|
|
624 Bytecount len;
|
|
625 int count;
|
|
626
|
|
627 va_start (va, nargs);
|
|
628 for (i = 0; i < nargs; i++)
|
|
629 args[i] = va_arg (va, Lisp_Object);
|
|
630 va_end (va);
|
|
631 str = emacs_vsprintf_malloc_lisp (fmt, Qnil, nargs, args, &len);
|
|
632 count = record_unwind_protect_freeing (str);
|
|
633 write_string_1 (str, len, Qexternal_debugging_output);
|
|
634 unbind_to (count);
|
|
635 }
|
|
636
|
428
|
637
|
|
638 DEFUN ("write-char", Fwrite_char, 1, 2, 0, /*
|
444
|
639 Output character CHARACTER to stream STREAM.
|
428
|
640 STREAM defaults to the value of `standard-output' (which see).
|
|
641 */
|
444
|
642 (character, stream))
|
428
|
643 {
|
|
644 /* This function can GC */
|
665
|
645 Intbyte str[MAX_EMCHAR_LEN];
|
428
|
646 Bytecount len;
|
|
647
|
444
|
648 CHECK_CHAR_COERCE_INT (character);
|
|
649 len = set_charptr_emchar (str, XCHAR (character));
|
428
|
650 output_string (canonicalize_printcharfun (stream), str, Qnil, 0, len);
|
444
|
651 return character;
|
428
|
652 }
|
|
653
|
|
654 void
|
|
655 temp_output_buffer_setup (Lisp_Object bufname)
|
|
656 {
|
|
657 /* This function can GC */
|
|
658 struct buffer *old = current_buffer;
|
|
659 Lisp_Object buf;
|
|
660
|
|
661 #ifdef I18N3
|
|
662 /* #### This function should accept a Lisp_Object instead of a char *,
|
|
663 so that proper translation on the buffer name can occur. */
|
|
664 #endif
|
|
665
|
|
666 Fset_buffer (Fget_buffer_create (bufname));
|
|
667
|
|
668 current_buffer->read_only = Qnil;
|
|
669 Ferase_buffer (Qnil);
|
|
670
|
793
|
671 buf = wrap_buffer (current_buffer);
|
428
|
672 specbind (Qstandard_output, buf);
|
|
673
|
|
674 set_buffer_internal (old);
|
|
675 }
|
|
676
|
|
677 Lisp_Object
|
|
678 internal_with_output_to_temp_buffer (Lisp_Object bufname,
|
|
679 Lisp_Object (*function) (Lisp_Object arg),
|
|
680 Lisp_Object arg,
|
|
681 Lisp_Object same_frame)
|
|
682 {
|
|
683 int speccount = specpdl_depth ();
|
|
684 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
685 Lisp_Object buf = Qnil;
|
|
686
|
|
687 GCPRO3 (buf, arg, same_frame);
|
|
688
|
|
689 temp_output_buffer_setup (bufname);
|
|
690 buf = Vstandard_output;
|
|
691
|
|
692 arg = (*function) (arg);
|
|
693
|
|
694 temp_output_buffer_show (buf, same_frame);
|
|
695 UNGCPRO;
|
|
696
|
771
|
697 return unbind_to_1 (speccount, arg);
|
428
|
698 }
|
|
699
|
|
700 DEFUN ("with-output-to-temp-buffer", Fwith_output_to_temp_buffer, 1, UNEVALLED, 0, /*
|
|
701 Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer.
|
|
702 The buffer is cleared out initially, and marked as unmodified when done.
|
|
703 All output done by BODY is inserted in that buffer by default.
|
|
704 The buffer is displayed in another window, but not selected.
|
|
705 The value of the last form in BODY is returned.
|
|
706 If BODY does not finish normally, the buffer BUFNAME is not displayed.
|
|
707
|
|
708 If variable `temp-buffer-show-function' is non-nil, call it at the end
|
|
709 to get the buffer displayed. It gets one argument, the buffer to display.
|
|
710 */
|
|
711 (args))
|
|
712 {
|
|
713 /* This function can GC */
|
|
714 Lisp_Object name = Qnil;
|
|
715 int speccount = specpdl_depth ();
|
|
716 struct gcpro gcpro1, gcpro2;
|
|
717 Lisp_Object val = Qnil;
|
|
718
|
|
719 #ifdef I18N3
|
|
720 /* #### should set the buffer to be translating. See print_internal(). */
|
|
721 #endif
|
|
722
|
|
723 GCPRO2 (name, val);
|
|
724 name = Feval (XCAR (args));
|
|
725
|
|
726 CHECK_STRING (name);
|
|
727
|
|
728 temp_output_buffer_setup (name);
|
|
729 UNGCPRO;
|
|
730
|
|
731 val = Fprogn (XCDR (args));
|
|
732
|
|
733 temp_output_buffer_show (Vstandard_output, Qnil);
|
|
734
|
771
|
735 return unbind_to_1 (speccount, val);
|
428
|
736 }
|
|
737
|
|
738 DEFUN ("terpri", Fterpri, 0, 1, 0, /*
|
|
739 Output a newline to STREAM.
|
|
740 If STREAM is omitted or nil, the value of `standard-output' is used.
|
|
741 */
|
|
742 (stream))
|
|
743 {
|
|
744 /* This function can GC */
|
|
745 write_char_internal ("\n", canonicalize_printcharfun (stream));
|
|
746 return Qt;
|
|
747 }
|
|
748
|
|
749 DEFUN ("prin1", Fprin1, 1, 2, 0, /*
|
|
750 Output the printed representation of OBJECT, any Lisp object.
|
|
751 Quoting characters are printed when needed to make output that `read'
|
|
752 can handle, whenever this is possible.
|
|
753 Output stream is STREAM, or value of `standard-output' (which see).
|
|
754 */
|
|
755 (object, stream))
|
|
756 {
|
|
757 /* This function can GC */
|
|
758 Lisp_Object frame = Qnil;
|
|
759 struct gcpro gcpro1, gcpro2;
|
|
760 GCPRO2 (object, stream);
|
|
761
|
|
762 print_depth = 0;
|
|
763 stream = print_prepare (stream, &frame);
|
|
764 print_internal (object, stream, 1);
|
|
765 print_finish (stream, frame);
|
|
766
|
|
767 UNGCPRO;
|
|
768 return object;
|
|
769 }
|
|
770
|
|
771 DEFUN ("prin1-to-string", Fprin1_to_string, 1, 2, 0, /*
|
|
772 Return a string containing the printed representation of OBJECT,
|
|
773 any Lisp object. Quoting characters are used when needed to make output
|
|
774 that `read' can handle, whenever this is possible, unless the optional
|
|
775 second argument NOESCAPE is non-nil.
|
|
776 */
|
|
777 (object, noescape))
|
|
778 {
|
|
779 /* This function can GC */
|
|
780 Lisp_Object result = Qnil;
|
|
781 Lisp_Object stream = make_resizing_buffer_output_stream ();
|
|
782 Lstream *str = XLSTREAM (stream);
|
|
783 /* gcpro OBJECT in case a caller forgot to do so */
|
|
784 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
785 GCPRO3 (object, stream, result);
|
|
786
|
|
787 print_depth = 0;
|
|
788 RESET_PRINT_GENSYM;
|
|
789 print_internal (object, stream, NILP (noescape));
|
|
790 RESET_PRINT_GENSYM;
|
|
791 Lstream_flush (str);
|
|
792 UNGCPRO;
|
|
793 result = make_string (resizing_buffer_stream_ptr (str),
|
|
794 Lstream_byte_count (str));
|
|
795 Lstream_delete (str);
|
|
796 return result;
|
|
797 }
|
|
798
|
|
799 DEFUN ("princ", Fprinc, 1, 2, 0, /*
|
|
800 Output the printed representation of OBJECT, any Lisp object.
|
|
801 No quoting characters are used; no delimiters are printed around
|
|
802 the contents of strings.
|
444
|
803 Output stream is STREAM, or value of `standard-output' (which see).
|
428
|
804 */
|
|
805 (object, stream))
|
|
806 {
|
|
807 /* This function can GC */
|
|
808 Lisp_Object frame = Qnil;
|
|
809 struct gcpro gcpro1, gcpro2;
|
|
810
|
|
811 GCPRO2 (object, stream);
|
|
812 stream = print_prepare (stream, &frame);
|
|
813 print_depth = 0;
|
|
814 print_internal (object, stream, 0);
|
|
815 print_finish (stream, frame);
|
|
816 UNGCPRO;
|
|
817 return object;
|
|
818 }
|
|
819
|
|
820 DEFUN ("print", Fprint, 1, 2, 0, /*
|
|
821 Output the printed representation of OBJECT, with newlines around it.
|
|
822 Quoting characters are printed when needed to make output that `read'
|
|
823 can handle, whenever this is possible.
|
|
824 Output stream is STREAM, or value of `standard-output' (which see).
|
|
825 */
|
|
826 (object, stream))
|
|
827 {
|
|
828 /* This function can GC */
|
|
829 Lisp_Object frame = Qnil;
|
|
830 struct gcpro gcpro1, gcpro2;
|
|
831
|
|
832 GCPRO2 (object, stream);
|
|
833 stream = print_prepare (stream, &frame);
|
|
834 print_depth = 0;
|
|
835 write_char_internal ("\n", stream);
|
|
836 print_internal (object, stream, 1);
|
|
837 write_char_internal ("\n", stream);
|
|
838 print_finish (stream, frame);
|
|
839 UNGCPRO;
|
|
840 return object;
|
|
841 }
|
|
842
|
|
843 /* Print an error message for the error DATA to STREAM. This is a
|
|
844 complete implementation of `display-error', which used to be in
|
|
845 Lisp (see prim/cmdloop.el). It was ported to C so it can be used
|
|
846 efficiently by Ferror_message_string. Fdisplay_error and
|
|
847 Ferror_message_string are trivial wrappers around this function.
|
|
848
|
|
849 STREAM should be the result of canonicalize_printcharfun(). */
|
|
850 static void
|
|
851 print_error_message (Lisp_Object error_object, Lisp_Object stream)
|
|
852 {
|
|
853 /* This function can GC */
|
|
854 Lisp_Object type = Fcar_safe (error_object);
|
|
855 Lisp_Object method = Qnil;
|
|
856 Lisp_Object tail;
|
|
857
|
|
858 /* No need to GCPRO anything under the assumption that ERROR_OBJECT
|
|
859 is GCPRO'd. */
|
|
860
|
|
861 if (! (CONSP (error_object) && SYMBOLP (type)
|
|
862 && CONSP (Fget (type, Qerror_conditions, Qnil))))
|
|
863 goto error_throw;
|
|
864
|
|
865 tail = XCDR (error_object);
|
|
866 while (!NILP (tail))
|
|
867 {
|
|
868 if (CONSP (tail))
|
|
869 tail = XCDR (tail);
|
|
870 else
|
|
871 goto error_throw;
|
|
872 }
|
|
873 tail = Fget (type, Qerror_conditions, Qnil);
|
|
874 while (!NILP (tail))
|
|
875 {
|
|
876 if (!(CONSP (tail) && SYMBOLP (XCAR (tail))))
|
|
877 goto error_throw;
|
|
878 else if (!NILP (Fget (XCAR (tail), Qdisplay_error, Qnil)))
|
|
879 {
|
|
880 method = Fget (XCAR (tail), Qdisplay_error, Qnil);
|
|
881 goto error_throw;
|
|
882 }
|
|
883 else
|
|
884 tail = XCDR (tail);
|
|
885 }
|
|
886 /* Default method */
|
|
887 {
|
|
888 int first = 1;
|
|
889 int speccount = specpdl_depth ();
|
438
|
890 Lisp_Object frame = Qnil;
|
|
891 struct gcpro gcpro1;
|
|
892 GCPRO1 (stream);
|
428
|
893
|
|
894 specbind (Qprint_message_label, Qerror);
|
438
|
895 stream = print_prepare (stream, &frame);
|
|
896
|
428
|
897 tail = Fcdr (error_object);
|
|
898 if (EQ (type, Qerror))
|
|
899 {
|
|
900 print_internal (Fcar (tail), stream, 0);
|
|
901 tail = Fcdr (tail);
|
|
902 }
|
|
903 else
|
|
904 {
|
|
905 Lisp_Object errmsg = Fget (type, Qerror_message, Qnil);
|
|
906 if (NILP (errmsg))
|
|
907 print_internal (type, stream, 0);
|
|
908 else
|
|
909 print_internal (LISP_GETTEXT (errmsg), stream, 0);
|
|
910 }
|
|
911 while (!NILP (tail))
|
|
912 {
|
|
913 write_c_string (first ? ": " : ", ", stream);
|
563
|
914 /* Most errors have an explanatory string as their first argument,
|
|
915 and it looks better not to put the quotes around it. */
|
|
916 print_internal (Fcar (tail), stream,
|
|
917 !(first && STRINGP (Fcar (tail))) ||
|
|
918 !NILP (Fget (type, Qerror_lacks_explanatory_string,
|
|
919 Qnil)));
|
428
|
920 tail = Fcdr (tail);
|
|
921 first = 0;
|
|
922 }
|
438
|
923 print_finish (stream, frame);
|
|
924 UNGCPRO;
|
771
|
925 unbind_to (speccount);
|
428
|
926 return;
|
|
927 /* not reached */
|
|
928 }
|
|
929
|
|
930 error_throw:
|
|
931 if (NILP (method))
|
|
932 {
|
|
933 write_c_string (GETTEXT ("Peculiar error "), stream);
|
|
934 print_internal (error_object, stream, 1);
|
|
935 return;
|
|
936 }
|
|
937 else
|
|
938 {
|
|
939 call2 (method, error_object, stream);
|
|
940 }
|
|
941 }
|
|
942
|
|
943 DEFUN ("error-message-string", Ferror_message_string, 1, 1, 0, /*
|
|
944 Convert ERROR-OBJECT to an error message, and return it.
|
|
945
|
|
946 The format of ERROR-OBJECT should be (ERROR-SYMBOL . DATA). The
|
|
947 message is equivalent to the one that would be issued by
|
|
948 `display-error' with the same argument.
|
|
949 */
|
|
950 (error_object))
|
|
951 {
|
|
952 /* This function can GC */
|
|
953 Lisp_Object result = Qnil;
|
|
954 Lisp_Object stream = make_resizing_buffer_output_stream ();
|
|
955 struct gcpro gcpro1;
|
|
956 GCPRO1 (stream);
|
|
957
|
|
958 print_error_message (error_object, stream);
|
|
959 Lstream_flush (XLSTREAM (stream));
|
|
960 result = make_string (resizing_buffer_stream_ptr (XLSTREAM (stream)),
|
|
961 Lstream_byte_count (XLSTREAM (stream)));
|
|
962 Lstream_delete (XLSTREAM (stream));
|
|
963
|
|
964 UNGCPRO;
|
|
965 return result;
|
|
966 }
|
|
967
|
|
968 DEFUN ("display-error", Fdisplay_error, 2, 2, 0, /*
|
|
969 Display ERROR-OBJECT on STREAM in a user-friendly way.
|
|
970 */
|
|
971 (error_object, stream))
|
|
972 {
|
|
973 /* This function can GC */
|
|
974 print_error_message (error_object, canonicalize_printcharfun (stream));
|
|
975 return Qnil;
|
|
976 }
|
|
977
|
|
978
|
|
979 #ifdef LISP_FLOAT_TYPE
|
|
980
|
|
981 Lisp_Object Vfloat_output_format;
|
|
982
|
|
983 /*
|
|
984 * This buffer should be at least as large as the max string size of the
|
440
|
985 * largest float, printed in the biggest notation. This is undoubtedly
|
428
|
986 * 20d float_output_format, with the negative of the C-constant "HUGE"
|
|
987 * from <math.h>.
|
|
988 *
|
|
989 * On the vax the worst case is -1e38 in 20d format which takes 61 bytes.
|
|
990 *
|
|
991 * I assume that IEEE-754 format numbers can take 329 bytes for the worst
|
|
992 * case of -1e307 in 20d float_output_format. What is one to do (short of
|
|
993 * re-writing _doprnt to be more sane)?
|
|
994 * -wsr
|
|
995 */
|
|
996 void
|
|
997 float_to_string (char *buf, double data)
|
|
998 {
|
665
|
999 Intbyte *cp, c;
|
428
|
1000 int width;
|
|
1001
|
|
1002 if (NILP (Vfloat_output_format)
|
|
1003 || !STRINGP (Vfloat_output_format))
|
|
1004 lose:
|
|
1005 sprintf (buf, "%.16g", data);
|
|
1006 else /* oink oink */
|
|
1007 {
|
|
1008 /* Check that the spec we have is fully valid.
|
|
1009 This means not only valid for printf,
|
|
1010 but meant for floats, and reasonable. */
|
|
1011 cp = XSTRING_DATA (Vfloat_output_format);
|
|
1012
|
|
1013 if (cp[0] != '%')
|
|
1014 goto lose;
|
|
1015 if (cp[1] != '.')
|
|
1016 goto lose;
|
|
1017
|
|
1018 cp += 2;
|
|
1019 for (width = 0; (c = *cp, isdigit (c)); cp++)
|
|
1020 {
|
|
1021 width *= 10;
|
|
1022 width += c - '0';
|
|
1023 }
|
|
1024
|
|
1025 if (*cp != 'e' && *cp != 'f' && *cp != 'g' && *cp != 'E' && *cp != 'G')
|
|
1026 goto lose;
|
|
1027
|
|
1028 if (width < (int) (*cp != 'e' && *cp != 'E') || width > DBL_DIG)
|
|
1029 goto lose;
|
|
1030
|
|
1031 if (cp[1] != 0)
|
|
1032 goto lose;
|
|
1033
|
|
1034 sprintf (buf, (char *) XSTRING_DATA (Vfloat_output_format),
|
|
1035 data);
|
|
1036 }
|
|
1037
|
|
1038 /* added by jwz: don't allow "1.0" to print as "1"; that destroys
|
|
1039 the read-equivalence of lisp objects. (* x 1) and (* x 1.0) do
|
|
1040 not do the same thing, so it's important that the printed
|
|
1041 representation of that form not be corrupted by the printer.
|
|
1042 */
|
|
1043 {
|
665
|
1044 Intbyte *s = (Intbyte *) buf; /* don't use signed chars here!
|
428
|
1045 isdigit() can't hack them! */
|
|
1046 if (*s == '-') s++;
|
|
1047 for (; *s; s++)
|
|
1048 /* if there's a non-digit, then there is a decimal point, or
|
|
1049 it's in exponential notation, both of which are ok. */
|
|
1050 if (!isdigit (*s))
|
|
1051 goto DONE_LABEL;
|
|
1052 /* otherwise, we need to hack it. */
|
|
1053 *s++ = '.';
|
|
1054 *s++ = '0';
|
|
1055 *s = 0;
|
|
1056 }
|
|
1057 DONE_LABEL:
|
|
1058
|
|
1059 /* Some machines print "0.4" as ".4". I don't like that. */
|
|
1060 if (buf [0] == '.' || (buf [0] == '-' && buf [1] == '.'))
|
|
1061 {
|
|
1062 int i;
|
|
1063 for (i = strlen (buf) + 1; i >= 0; i--)
|
|
1064 buf [i+1] = buf [i];
|
|
1065 buf [(buf [0] == '-' ? 1 : 0)] = '0';
|
|
1066 }
|
|
1067 }
|
|
1068 #endif /* LISP_FLOAT_TYPE */
|
|
1069
|
577
|
1070 #define ONE_DIGIT(figure) *p++ = n / (figure) + '0'
|
|
1071 #define ONE_DIGIT_ADVANCE(figure) (ONE_DIGIT (figure), n %= (figure))
|
|
1072
|
|
1073 #define DIGITS_1(figure) ONE_DIGIT (figure)
|
|
1074 #define DIGITS_2(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_1 ((figure) / 10)
|
|
1075 #define DIGITS_3(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_2 ((figure) / 10)
|
|
1076 #define DIGITS_4(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_3 ((figure) / 10)
|
|
1077 #define DIGITS_5(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_4 ((figure) / 10)
|
|
1078 #define DIGITS_6(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_5 ((figure) / 10)
|
|
1079 #define DIGITS_7(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_6 ((figure) / 10)
|
|
1080 #define DIGITS_8(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_7 ((figure) / 10)
|
|
1081 #define DIGITS_9(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_8 ((figure) / 10)
|
|
1082 #define DIGITS_10(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_9 ((figure) / 10)
|
|
1083
|
|
1084 /* DIGITS_<11-20> are only used on machines with 64-bit longs. */
|
428
|
1085
|
577
|
1086 #define DIGITS_11(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_10 ((figure) / 10)
|
|
1087 #define DIGITS_12(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_11 ((figure) / 10)
|
|
1088 #define DIGITS_13(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_12 ((figure) / 10)
|
|
1089 #define DIGITS_14(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_13 ((figure) / 10)
|
|
1090 #define DIGITS_15(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_14 ((figure) / 10)
|
|
1091 #define DIGITS_16(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_15 ((figure) / 10)
|
|
1092 #define DIGITS_17(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_16 ((figure) / 10)
|
|
1093 #define DIGITS_18(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_17 ((figure) / 10)
|
|
1094 #define DIGITS_19(figure) ONE_DIGIT_ADVANCE (figure); DIGITS_18 ((figure) / 10)
|
|
1095
|
|
1096 /* Print NUMBER to BUFFER in base 10. This is completely equivalent
|
|
1097 to `sprintf(buffer, "%ld", number)', only much faster.
|
|
1098
|
|
1099 The speedup may make a difference in programs that frequently
|
|
1100 convert numbers to strings. Some implementations of sprintf,
|
|
1101 particularly the one in GNU libc, have been known to be extremely
|
|
1102 slow compared to this function.
|
|
1103
|
|
1104 BUFFER should accept as many bytes as you expect the number to take
|
|
1105 up. On machines with 64-bit longs the maximum needed size is 24
|
|
1106 bytes. That includes the worst-case digits, the optional `-' sign,
|
|
1107 and the trailing \0. */
|
|
1108
|
|
1109 void
|
428
|
1110 long_to_string (char *buffer, long number)
|
|
1111 {
|
577
|
1112 char *p = buffer;
|
|
1113 long n = number;
|
|
1114
|
428
|
1115 #if (SIZEOF_LONG != 4) && (SIZEOF_LONG != 8)
|
577
|
1116 /* We are running in a strange or misconfigured environment. Let
|
|
1117 sprintf cope with it. */
|
|
1118 sprintf (buffer, "%ld", n);
|
|
1119 #else /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */
|
428
|
1120
|
577
|
1121 if (n < 0)
|
428
|
1122 {
|
|
1123 *p++ = '-';
|
577
|
1124 n = -n;
|
428
|
1125 }
|
|
1126
|
577
|
1127 if (n < 10) { DIGITS_1 (1); }
|
|
1128 else if (n < 100) { DIGITS_2 (10); }
|
|
1129 else if (n < 1000) { DIGITS_3 (100); }
|
|
1130 else if (n < 10000) { DIGITS_4 (1000); }
|
|
1131 else if (n < 100000) { DIGITS_5 (10000); }
|
|
1132 else if (n < 1000000) { DIGITS_6 (100000); }
|
|
1133 else if (n < 10000000) { DIGITS_7 (1000000); }
|
|
1134 else if (n < 100000000) { DIGITS_8 (10000000); }
|
|
1135 else if (n < 1000000000) { DIGITS_9 (100000000); }
|
|
1136 #if SIZEOF_LONG == 4
|
|
1137 /* ``if (1)'' serves only to preserve editor indentation. */
|
|
1138 else if (1) { DIGITS_10 (1000000000); }
|
|
1139 #else /* SIZEOF_LONG != 4 */
|
|
1140 else if (n < 10000000000L) { DIGITS_10 (1000000000L); }
|
|
1141 else if (n < 100000000000L) { DIGITS_11 (10000000000L); }
|
|
1142 else if (n < 1000000000000L) { DIGITS_12 (100000000000L); }
|
|
1143 else if (n < 10000000000000L) { DIGITS_13 (1000000000000L); }
|
|
1144 else if (n < 100000000000000L) { DIGITS_14 (10000000000000L); }
|
|
1145 else if (n < 1000000000000000L) { DIGITS_15 (100000000000000L); }
|
|
1146 else if (n < 10000000000000000L) { DIGITS_16 (1000000000000000L); }
|
|
1147 else if (n < 100000000000000000L) { DIGITS_17 (10000000000000000L); }
|
|
1148 else if (n < 1000000000000000000L) { DIGITS_18 (100000000000000000L); }
|
|
1149 else { DIGITS_19 (1000000000000000000L); }
|
|
1150 #endif /* SIZEOF_LONG != 4 */
|
|
1151
|
428
|
1152 *p = '\0';
|
|
1153 #endif /* (SIZEOF_LONG == 4) || (SIZEOF_LONG == 8) */
|
|
1154 }
|
577
|
1155
|
|
1156 #undef ONE_DIGIT
|
|
1157 #undef ONE_DIGIT_ADVANCE
|
|
1158
|
|
1159 #undef DIGITS_1
|
|
1160 #undef DIGITS_2
|
|
1161 #undef DIGITS_3
|
|
1162 #undef DIGITS_4
|
|
1163 #undef DIGITS_5
|
|
1164 #undef DIGITS_6
|
|
1165 #undef DIGITS_7
|
|
1166 #undef DIGITS_8
|
|
1167 #undef DIGITS_9
|
|
1168 #undef DIGITS_10
|
|
1169 #undef DIGITS_11
|
|
1170 #undef DIGITS_12
|
|
1171 #undef DIGITS_13
|
|
1172 #undef DIGITS_14
|
|
1173 #undef DIGITS_15
|
|
1174 #undef DIGITS_16
|
|
1175 #undef DIGITS_17
|
|
1176 #undef DIGITS_18
|
|
1177 #undef DIGITS_19
|
428
|
1178
|
|
1179 static void
|
442
|
1180 print_vector_internal (const char *start, const char *end,
|
428
|
1181 Lisp_Object obj,
|
|
1182 Lisp_Object printcharfun, int escapeflag)
|
|
1183 {
|
|
1184 /* This function can GC */
|
|
1185 int i;
|
|
1186 int len = XVECTOR_LENGTH (obj);
|
|
1187 int last = len;
|
|
1188 struct gcpro gcpro1, gcpro2;
|
|
1189 GCPRO2 (obj, printcharfun);
|
|
1190
|
|
1191 if (INTP (Vprint_length))
|
|
1192 {
|
|
1193 int max = XINT (Vprint_length);
|
|
1194 if (max < len) last = max;
|
|
1195 }
|
|
1196
|
|
1197 write_c_string (start, printcharfun);
|
|
1198 for (i = 0; i < last; i++)
|
|
1199 {
|
|
1200 Lisp_Object elt = XVECTOR_DATA (obj)[i];
|
|
1201 if (i != 0) write_char_internal (" ", printcharfun);
|
|
1202 print_internal (elt, printcharfun, escapeflag);
|
|
1203 }
|
|
1204 UNGCPRO;
|
|
1205 if (last != len)
|
|
1206 write_c_string (" ...", printcharfun);
|
|
1207 write_c_string (end, printcharfun);
|
|
1208 }
|
|
1209
|
|
1210 void
|
|
1211 print_cons (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1212 {
|
|
1213 /* This function can GC */
|
|
1214 struct gcpro gcpro1, gcpro2;
|
|
1215
|
|
1216 /* If print_readably is on, print (quote -foo-) as '-foo-
|
|
1217 (Yeah, this should really be what print-pretty does, but we
|
|
1218 don't have the rest of a pretty printer, and this actually
|
|
1219 has non-negligible impact on size/speed of .elc files.)
|
|
1220 */
|
|
1221 if (print_readably &&
|
|
1222 EQ (XCAR (obj), Qquote) &&
|
|
1223 CONSP (XCDR (obj)) &&
|
|
1224 NILP (XCDR (XCDR (obj))))
|
|
1225 {
|
|
1226 obj = XCAR (XCDR (obj));
|
|
1227 GCPRO2 (obj, printcharfun);
|
|
1228 write_char_internal ("\'", printcharfun);
|
|
1229 UNGCPRO;
|
|
1230 print_internal (obj, printcharfun, escapeflag);
|
|
1231 return;
|
|
1232 }
|
|
1233
|
|
1234 GCPRO2 (obj, printcharfun);
|
|
1235 write_char_internal ("(", printcharfun);
|
|
1236
|
|
1237 {
|
|
1238 int len;
|
|
1239 int max = INTP (Vprint_length) ? XINT (Vprint_length) : INT_MAX;
|
|
1240 Lisp_Object tortoise;
|
|
1241 /* Use tortoise/hare to make sure circular lists don't infloop */
|
|
1242
|
|
1243 for (tortoise = obj, len = 0;
|
|
1244 CONSP (obj);
|
|
1245 obj = XCDR (obj), len++)
|
|
1246 {
|
|
1247 if (len > 0)
|
|
1248 write_char_internal (" ", printcharfun);
|
|
1249 if (EQ (obj, tortoise) && len > 0)
|
|
1250 {
|
|
1251 if (print_readably)
|
563
|
1252 printing_unreadable_object ("circular list");
|
428
|
1253 else
|
|
1254 write_c_string ("... <circular list>", printcharfun);
|
|
1255 break;
|
|
1256 }
|
|
1257 if (len & 1)
|
|
1258 tortoise = XCDR (tortoise);
|
|
1259 if (len > max)
|
|
1260 {
|
|
1261 write_c_string ("...", printcharfun);
|
|
1262 break;
|
|
1263 }
|
|
1264 print_internal (XCAR (obj), printcharfun, escapeflag);
|
|
1265 }
|
|
1266 }
|
|
1267 if (!LISTP (obj))
|
|
1268 {
|
|
1269 write_c_string (" . ", printcharfun);
|
|
1270 print_internal (obj, printcharfun, escapeflag);
|
|
1271 }
|
|
1272 UNGCPRO;
|
|
1273
|
|
1274 write_char_internal (")", printcharfun);
|
|
1275 return;
|
|
1276 }
|
|
1277
|
|
1278 void
|
|
1279 print_vector (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1280 {
|
|
1281 print_vector_internal ("[", "]", obj, printcharfun, escapeflag);
|
|
1282 }
|
|
1283
|
|
1284 void
|
|
1285 print_string (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1286 {
|
|
1287 /* We distinguish between Bytecounts and Charcounts, to make
|
|
1288 Vprint_string_length work correctly under Mule. */
|
793
|
1289 Charcount size = XSTRING_CHAR_LENGTH (obj);
|
428
|
1290 Charcount max = size;
|
793
|
1291 Bytecount bcmax = XSTRING_LENGTH (obj);
|
428
|
1292 struct gcpro gcpro1, gcpro2;
|
|
1293 GCPRO2 (obj, printcharfun);
|
|
1294
|
|
1295 if (INTP (Vprint_string_length) &&
|
|
1296 XINT (Vprint_string_length) < max)
|
|
1297 {
|
|
1298 max = XINT (Vprint_string_length);
|
793
|
1299 bcmax = string_index_char_to_byte (obj, max);
|
428
|
1300 }
|
|
1301 if (max < 0)
|
|
1302 {
|
|
1303 max = 0;
|
|
1304 bcmax = 0;
|
|
1305 }
|
|
1306
|
|
1307 if (!escapeflag)
|
|
1308 {
|
|
1309 /* This deals with GC-relocation and Mule. */
|
|
1310 output_string (printcharfun, 0, obj, 0, bcmax);
|
|
1311 if (max < size)
|
|
1312 write_c_string (" ...", printcharfun);
|
|
1313 }
|
|
1314 else
|
|
1315 {
|
|
1316 Bytecount i, last = 0;
|
|
1317
|
|
1318 write_char_internal ("\"", printcharfun);
|
|
1319 for (i = 0; i < bcmax; i++)
|
|
1320 {
|
793
|
1321 Intbyte ch = XSTRING_BYTE (obj, i);
|
428
|
1322 if (ch == '\"' || ch == '\\'
|
|
1323 || (ch == '\n' && print_escape_newlines))
|
|
1324 {
|
|
1325 if (i > last)
|
|
1326 {
|
|
1327 output_string (printcharfun, 0, obj, last,
|
|
1328 i - last);
|
|
1329 }
|
|
1330 if (ch == '\n')
|
|
1331 {
|
|
1332 write_c_string ("\\n", printcharfun);
|
|
1333 }
|
|
1334 else
|
|
1335 {
|
|
1336 write_char_internal ("\\", printcharfun);
|
|
1337 /* This is correct for Mule because the
|
|
1338 character is either \ or " */
|
793
|
1339 write_char_internal (XSTRING_DATA (obj) + i, printcharfun);
|
428
|
1340 }
|
|
1341 last = i + 1;
|
|
1342 }
|
|
1343 }
|
|
1344 if (bcmax > last)
|
|
1345 {
|
|
1346 output_string (printcharfun, 0, obj, last,
|
|
1347 bcmax - last);
|
|
1348 }
|
|
1349 if (max < size)
|
|
1350 write_c_string (" ...", printcharfun);
|
|
1351 write_char_internal ("\"", printcharfun);
|
|
1352 }
|
|
1353 UNGCPRO;
|
|
1354 }
|
|
1355
|
|
1356 static void
|
|
1357 default_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
|
|
1358 int escapeflag)
|
|
1359 {
|
|
1360 struct lcrecord_header *header =
|
|
1361 (struct lcrecord_header *) XPNTR (obj);
|
|
1362 char buf[200];
|
|
1363
|
|
1364 if (print_readably)
|
563
|
1365 printing_unreadable_object
|
|
1366 ("#<%s 0x%x>",
|
|
1367 LHEADER_IMPLEMENTATION (&header->lheader)->name,
|
|
1368 header->uid);
|
428
|
1369
|
|
1370 sprintf (buf, "#<%s 0x%x>",
|
|
1371 LHEADER_IMPLEMENTATION (&header->lheader)->name,
|
|
1372 header->uid);
|
|
1373 write_c_string (buf, printcharfun);
|
|
1374 }
|
|
1375
|
|
1376 void
|
|
1377 internal_object_printer (Lisp_Object obj, Lisp_Object printcharfun,
|
|
1378 int escapeflag)
|
|
1379 {
|
|
1380 char buf[200];
|
|
1381 sprintf (buf, "#<INTERNAL OBJECT (XEmacs bug?) (%s) 0x%lx>",
|
|
1382 XRECORD_LHEADER_IMPLEMENTATION (obj)->name,
|
|
1383 (unsigned long) XPNTR (obj));
|
|
1384 write_c_string (buf, printcharfun);
|
|
1385 }
|
|
1386
|
|
1387 void
|
|
1388 print_internal (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1389 {
|
|
1390 /* This function can GC */
|
|
1391
|
|
1392 QUIT;
|
|
1393
|
771
|
1394 #ifdef NO_PRINT_DURING_GC
|
428
|
1395 /* Emacs won't print while GCing, but an external debugger might */
|
|
1396 if (gc_in_progress) return;
|
771
|
1397 #endif
|
|
1398
|
|
1399 /* Try to check for a bogus pointer if we're in a situation where it may
|
|
1400 be likely. In such cases, crashing is counterproductive. */
|
|
1401 if (inhibit_non_essential_printing_operations || print_unbuffered)
|
|
1402 {
|
|
1403 if (XTYPE (obj) == Lisp_Type_Record)
|
|
1404 {
|
|
1405 struct lrecord_header *lheader = XRECORD_LHEADER (obj);
|
|
1406
|
|
1407 if (!debug_can_access_memory (lheader, sizeof (*lheader)))
|
|
1408 {
|
|
1409 char buf[128];
|
|
1410
|
|
1411 sprintf (buf, "#<EMACS BUG: BAD MEMORY %p>", lheader);
|
|
1412 write_c_string (buf, printcharfun);
|
|
1413 return;
|
|
1414 }
|
|
1415 else
|
|
1416 {
|
|
1417 const struct lrecord_implementation *impl;
|
|
1418
|
|
1419 if ((int) lheader->type >= lrecord_type_count)
|
|
1420 {
|
|
1421 char buf[128];
|
|
1422
|
|
1423 sprintf (buf, "#<EMACS BUG: bad type %d BAD MEMORY %p>",
|
|
1424 lheader->type, lheader);
|
|
1425 write_c_string (buf, printcharfun);
|
|
1426 return;
|
|
1427 }
|
|
1428
|
|
1429 impl = LHEADER_IMPLEMENTATION (lheader);
|
|
1430 if (!debug_can_access_memory
|
|
1431 (lheader,
|
|
1432 (impl->size_in_bytes_method ?
|
|
1433 impl->size_in_bytes_method (lheader) :
|
|
1434 impl->static_size)))
|
|
1435 {
|
|
1436 char buf[128];
|
|
1437
|
|
1438 sprintf (buf, "#<EMACS BUG: type %s BAD MEMORY %p>",
|
|
1439 impl->name, lheader);
|
|
1440 write_c_string (buf, printcharfun);
|
|
1441 return;
|
|
1442 }
|
|
1443
|
|
1444 if (STRINGP (obj))
|
|
1445 {
|
|
1446 Lisp_String *l = (Lisp_String *) lheader;
|
|
1447 if (!debug_can_access_memory
|
793
|
1448 (l->data_, l->size_))
|
771
|
1449 {
|
|
1450 char buf[128];
|
|
1451
|
|
1452 sprintf (buf, "#<EMACS BUG: %p (BAD STRING DATA %p)>",
|
793
|
1453 lheader, l->data_);
|
771
|
1454 write_c_string (buf, printcharfun);
|
|
1455 return;
|
|
1456 }
|
|
1457 }
|
|
1458 }
|
|
1459 }
|
|
1460 }
|
428
|
1461
|
|
1462 #ifdef I18N3
|
|
1463 /* #### Both input and output streams should have a flag associated
|
|
1464 with them indicating whether output to that stream, or strings
|
|
1465 read from the stream, get translated using Fgettext(). Such a
|
|
1466 stream is called a "translating stream". For the minibuffer and
|
|
1467 external-debugging-output this is always true on output, and
|
|
1468 with-output-to-temp-buffer sets the flag to true for the buffer
|
|
1469 it creates. This flag should also be user-settable. Perhaps it
|
|
1470 should be split up into two flags, one for input and one for
|
|
1471 output. */
|
|
1472 #endif
|
|
1473
|
|
1474 /* Detect circularities and truncate them.
|
|
1475 No need to offer any alternative--this is better than an error. */
|
|
1476 if (CONSP (obj) || VECTORP (obj) || COMPILED_FUNCTIONP (obj))
|
|
1477 {
|
|
1478 int i;
|
|
1479 for (i = 0; i < print_depth; i++)
|
|
1480 if (EQ (obj, being_printed[i]))
|
|
1481 {
|
603
|
1482 char buf[DECIMAL_PRINT_SIZE (long) + 1];
|
428
|
1483 *buf = '#';
|
|
1484 long_to_string (buf + 1, i);
|
|
1485 write_c_string (buf, printcharfun);
|
|
1486 return;
|
|
1487 }
|
|
1488 }
|
|
1489
|
|
1490 being_printed[print_depth] = obj;
|
|
1491 print_depth++;
|
|
1492
|
|
1493 if (print_depth > PRINT_CIRCLE)
|
563
|
1494 signal_error (Qstack_overflow, "Apparently circular structure being printed", Qunbound);
|
428
|
1495
|
|
1496 switch (XTYPE (obj))
|
|
1497 {
|
|
1498 case Lisp_Type_Int_Even:
|
|
1499 case Lisp_Type_Int_Odd:
|
|
1500 {
|
603
|
1501 char buf[DECIMAL_PRINT_SIZE (EMACS_INT)];
|
428
|
1502 long_to_string (buf, XINT (obj));
|
|
1503 write_c_string (buf, printcharfun);
|
|
1504 break;
|
|
1505 }
|
|
1506
|
|
1507 case Lisp_Type_Char:
|
|
1508 {
|
|
1509 /* God intended that this be #\..., you know. */
|
|
1510 char buf[16];
|
|
1511 Emchar ch = XCHAR (obj);
|
|
1512 char *p = buf;
|
|
1513 *p++ = '?';
|
434
|
1514 if (ch < 32)
|
|
1515 {
|
|
1516 *p++ = '\\';
|
|
1517 switch (ch)
|
|
1518 {
|
|
1519 case '\t': *p++ = 't'; break;
|
|
1520 case '\n': *p++ = 'n'; break;
|
|
1521 case '\r': *p++ = 'r'; break;
|
|
1522 default:
|
|
1523 *p++ = '^';
|
|
1524 *p++ = ch + 64;
|
|
1525 if ((ch + 64) == '\\')
|
|
1526 *p++ = '\\';
|
|
1527 break;
|
|
1528 }
|
|
1529 }
|
|
1530 else if (ch < 127)
|
428
|
1531 {
|
434
|
1532 /* syntactically special characters should be escaped. */
|
|
1533 switch (ch)
|
|
1534 {
|
|
1535 case ' ':
|
|
1536 case '"':
|
|
1537 case '#':
|
|
1538 case '\'':
|
|
1539 case '(':
|
|
1540 case ')':
|
|
1541 case ',':
|
|
1542 case '.':
|
|
1543 case ';':
|
|
1544 case '?':
|
|
1545 case '[':
|
|
1546 case '\\':
|
|
1547 case ']':
|
|
1548 case '`':
|
|
1549 *p++ = '\\';
|
|
1550 }
|
|
1551 *p++ = ch;
|
428
|
1552 }
|
|
1553 else if (ch == 127)
|
434
|
1554 {
|
|
1555 *p++ = '\\', *p++ = '^', *p++ = '?';
|
|
1556 }
|
|
1557 else if (ch < 160)
|
428
|
1558 {
|
|
1559 *p++ = '\\', *p++ = '^';
|
665
|
1560 p += set_charptr_emchar ((Intbyte *) p, ch + 64);
|
428
|
1561 }
|
|
1562 else
|
434
|
1563 {
|
665
|
1564 p += set_charptr_emchar ((Intbyte *) p, ch);
|
434
|
1565 }
|
440
|
1566
|
665
|
1567 output_string (printcharfun, (Intbyte *) buf, Qnil, 0, p - buf);
|
434
|
1568
|
428
|
1569 break;
|
|
1570 }
|
|
1571
|
|
1572 case Lisp_Type_Record:
|
|
1573 {
|
|
1574 struct lrecord_header *lheader = XRECORD_LHEADER (obj);
|
|
1575 struct gcpro gcpro1, gcpro2;
|
|
1576
|
|
1577 if (CONSP (obj) || VECTORP(obj))
|
|
1578 {
|
|
1579 /* If deeper than spec'd depth, print placeholder. */
|
|
1580 if (INTP (Vprint_level)
|
|
1581 && print_depth > XINT (Vprint_level))
|
|
1582 {
|
|
1583 GCPRO2 (obj, printcharfun);
|
|
1584 write_c_string ("...", printcharfun);
|
|
1585 UNGCPRO;
|
|
1586 break;
|
|
1587 }
|
|
1588 }
|
|
1589
|
|
1590 GCPRO2 (obj, printcharfun);
|
|
1591 if (LHEADER_IMPLEMENTATION (lheader)->printer)
|
|
1592 ((LHEADER_IMPLEMENTATION (lheader)->printer)
|
|
1593 (obj, printcharfun, escapeflag));
|
|
1594 else
|
|
1595 default_object_printer (obj, printcharfun, escapeflag);
|
|
1596 UNGCPRO;
|
|
1597 break;
|
|
1598 }
|
|
1599
|
|
1600 default:
|
|
1601 {
|
|
1602 #ifdef ERROR_CHECK_TYPECHECK
|
|
1603 abort ();
|
|
1604 #else /* not ERROR_CHECK_TYPECHECK */
|
|
1605 char buf[128];
|
|
1606 /* We're in trouble if this happens! */
|
|
1607 if (print_readably)
|
571
|
1608 signal_error (Qinternal_error, "printing illegal data type #o%03o",
|
579
|
1609 make_int (XTYPE (obj)));
|
428
|
1610 write_c_string ("#<EMACS BUG: ILLEGAL DATATYPE ",
|
|
1611 printcharfun);
|
|
1612 sprintf (buf, "(#o%3o)", (int) XTYPE (obj));
|
|
1613 write_c_string (buf, printcharfun);
|
|
1614 write_c_string
|
|
1615 (" Save your buffers immediately and please report this bug>",
|
|
1616 printcharfun);
|
|
1617 #endif /* not ERROR_CHECK_TYPECHECK */
|
|
1618 break;
|
|
1619 }
|
|
1620 }
|
|
1621
|
|
1622 print_depth--;
|
|
1623 }
|
|
1624
|
|
1625
|
|
1626 #ifdef LISP_FLOAT_TYPE
|
|
1627 void
|
|
1628 print_float (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1629 {
|
|
1630 char pigbuf[350]; /* see comments in float_to_string */
|
|
1631
|
|
1632 float_to_string (pigbuf, XFLOAT_DATA (obj));
|
|
1633 write_c_string (pigbuf, printcharfun);
|
|
1634 }
|
|
1635 #endif /* LISP_FLOAT_TYPE */
|
|
1636
|
|
1637 void
|
|
1638 print_symbol (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
1639 {
|
|
1640 /* This function can GC */
|
|
1641 /* #### Bug!! (intern "") isn't printed in some distinguished way */
|
|
1642 /* #### (the reader also loses on it) */
|
793
|
1643 Lisp_Object name = symbol_name (XSYMBOL (obj));
|
|
1644 Bytecount size = XSTRING_LENGTH (name);
|
428
|
1645 struct gcpro gcpro1, gcpro2;
|
|
1646
|
|
1647 if (!escapeflag)
|
|
1648 {
|
|
1649 /* This deals with GC-relocation */
|
793
|
1650 output_string (printcharfun, 0, name, 0, size);
|
428
|
1651 return;
|
|
1652 }
|
|
1653 GCPRO2 (obj, printcharfun);
|
|
1654
|
|
1655 /* If we print an uninterned symbol as part of a complex object and
|
|
1656 the flag print-gensym is non-nil, prefix it with #n= to read the
|
|
1657 object back with the #n# reader syntax later if needed. */
|
|
1658 if (!NILP (Vprint_gensym)
|
442
|
1659 /* #### Test whether this produces a noticeable slow-down for
|
428
|
1660 printing when print-gensym is non-nil. */
|
|
1661 && !EQ (obj, oblookup (Vobarray,
|
793
|
1662 XSTRING_DATA (symbol_name (XSYMBOL (obj))),
|
|
1663 XSTRING_LENGTH (symbol_name (XSYMBOL (obj))))))
|
428
|
1664 {
|
|
1665 if (print_depth > 1)
|
|
1666 {
|
|
1667 Lisp_Object tem = Fassq (obj, Vprint_gensym_alist);
|
|
1668 if (CONSP (tem))
|
|
1669 {
|
|
1670 write_char_internal ("#", printcharfun);
|
|
1671 print_internal (XCDR (tem), printcharfun, escapeflag);
|
|
1672 write_char_internal ("#", printcharfun);
|
446
|
1673 UNGCPRO;
|
428
|
1674 return;
|
|
1675 }
|
|
1676 else
|
|
1677 {
|
|
1678 if (CONSP (Vprint_gensym_alist))
|
|
1679 {
|
|
1680 /* Vprint_gensym_alist is exposed to Lisp, so we
|
|
1681 have to be careful. */
|
|
1682 CHECK_CONS (XCAR (Vprint_gensym_alist));
|
|
1683 CHECK_INT (XCDR (XCAR (Vprint_gensym_alist)));
|
793
|
1684 tem = make_int (XINT (XCDR (XCAR (Vprint_gensym_alist))) + 1);
|
428
|
1685 }
|
|
1686 else
|
793
|
1687 tem = make_int (1);
|
428
|
1688 Vprint_gensym_alist = Fcons (Fcons (obj, tem), Vprint_gensym_alist);
|
|
1689
|
|
1690 write_char_internal ("#", printcharfun);
|
|
1691 print_internal (tem, printcharfun, escapeflag);
|
|
1692 write_char_internal ("=", printcharfun);
|
|
1693 }
|
|
1694 }
|
|
1695 write_c_string ("#:", printcharfun);
|
|
1696 }
|
|
1697
|
|
1698 /* Does it look like an integer or a float? */
|
|
1699 {
|
793
|
1700 Intbyte *data = XSTRING_DATA (name);
|
428
|
1701 Bytecount confusing = 0;
|
|
1702
|
|
1703 if (size == 0)
|
|
1704 goto not_yet_confused; /* Really confusing */
|
|
1705 else if (isdigit (data[0]))
|
|
1706 confusing = 0;
|
|
1707 else if (size == 1)
|
|
1708 goto not_yet_confused;
|
|
1709 else if (data[0] == '-' || data[0] == '+')
|
|
1710 confusing = 1;
|
|
1711 else
|
|
1712 goto not_yet_confused;
|
|
1713
|
|
1714 for (; confusing < size; confusing++)
|
|
1715 {
|
|
1716 if (!isdigit (data[confusing]))
|
|
1717 {
|
|
1718 confusing = 0;
|
|
1719 break;
|
|
1720 }
|
|
1721 }
|
|
1722 not_yet_confused:
|
|
1723
|
|
1724 #ifdef LISP_FLOAT_TYPE
|
|
1725 if (!confusing)
|
|
1726 /* #### Ugh, this is needlessly complex and slow for what we
|
|
1727 need here. It might be a good idea to copy equivalent code
|
|
1728 from FSF. --hniksic */
|
|
1729 confusing = isfloat_string ((char *) data);
|
|
1730 #endif
|
|
1731 if (confusing)
|
|
1732 write_char_internal ("\\", printcharfun);
|
|
1733 }
|
|
1734
|
|
1735 {
|
|
1736 Bytecount i;
|
|
1737 Bytecount last = 0;
|
|
1738
|
|
1739 for (i = 0; i < size; i++)
|
|
1740 {
|
793
|
1741 switch (XSTRING_BYTE (name, i))
|
428
|
1742 {
|
|
1743 case 0: case 1: case 2: case 3:
|
|
1744 case 4: case 5: case 6: case 7:
|
|
1745 case 8: case 9: case 10: case 11:
|
|
1746 case 12: case 13: case 14: case 15:
|
|
1747 case 16: case 17: case 18: case 19:
|
|
1748 case 20: case 21: case 22: case 23:
|
|
1749 case 24: case 25: case 26: case 27:
|
|
1750 case 28: case 29: case 30: case 31:
|
|
1751 case ' ': case '\"': case '\\': case '\'':
|
|
1752 case ';': case '#' : case '(' : case ')':
|
|
1753 case ',': case '.' : case '`' :
|
|
1754 case '[': case ']' : case '?' :
|
|
1755 if (i > last)
|
793
|
1756 output_string (printcharfun, 0, name, last, i - last);
|
428
|
1757 write_char_internal ("\\", printcharfun);
|
|
1758 last = i;
|
|
1759 }
|
|
1760 }
|
793
|
1761 output_string (printcharfun, 0, name, last, size - last);
|
428
|
1762 }
|
|
1763 UNGCPRO;
|
|
1764 }
|
|
1765
|
|
1766
|
442
|
1767 /* Useful on systems or in places where writing to stdout is unavailable or
|
|
1768 not working. */
|
428
|
1769
|
|
1770 static int alternate_do_pointer;
|
|
1771 static char alternate_do_string[5000];
|
|
1772
|
|
1773 DEFUN ("alternate-debugging-output", Falternate_debugging_output, 1, 1, 0, /*
|
|
1774 Append CHARACTER to the array `alternate_do_string'.
|
|
1775 This can be used in place of `external-debugging-output' as a function
|
|
1776 to be passed to `print'. Before calling `print', set `alternate_do_pointer'
|
|
1777 to 0.
|
|
1778 */
|
|
1779 (character))
|
|
1780 {
|
665
|
1781 Intbyte str[MAX_EMCHAR_LEN];
|
428
|
1782 Bytecount len;
|
|
1783
|
|
1784 CHECK_CHAR_COERCE_INT (character);
|
|
1785 len = set_charptr_emchar (str, XCHAR (character));
|
771
|
1786 write_string_to_alternate_debugging_output (str, len);
|
|
1787
|
|
1788 return character;
|
|
1789 }
|
|
1790
|
|
1791 static void
|
|
1792 write_string_to_alternate_debugging_output (Intbyte *str, Bytecount len)
|
|
1793 {
|
|
1794 int extlen;
|
|
1795 const Extbyte *extptr;
|
|
1796 #if 0 /* We want to see the internal representation, don't we? */
|
|
1797 if (initialized && !inhibit_non_essential_printing_operations)
|
|
1798 TO_EXTERNAL_FORMAT (DATA, (str, len),
|
|
1799 ALLOCA, (extptr, extlen),
|
|
1800 Qterminal);
|
|
1801 else
|
|
1802 #endif /* 0 */
|
|
1803 {
|
|
1804 extlen = len;
|
|
1805 extptr = (Extbyte *) str;
|
|
1806 }
|
428
|
1807 memcpy (alternate_do_string + alternate_do_pointer, extptr, extlen);
|
|
1808 alternate_do_pointer += extlen;
|
|
1809 alternate_do_string[alternate_do_pointer] = 0;
|
|
1810 }
|
|
1811
|
|
1812 DEFUN ("external-debugging-output", Fexternal_debugging_output, 1, 3, 0, /*
|
|
1813 Write CHAR-OR-STRING to stderr or stdout.
|
|
1814 If optional arg STDOUT-P is non-nil, write to stdout; otherwise, write
|
|
1815 to stderr. You can use this function to write directly to the terminal.
|
|
1816 This function can be used as the STREAM argument of Fprint() or the like.
|
|
1817
|
442
|
1818 Under MS Windows, this writes output to the console window (which is
|
|
1819 created, if necessary), unless XEmacs is being run noninteractively
|
|
1820 \(i.e. using the `-batch' argument).
|
|
1821
|
428
|
1822 If you have opened a termscript file (using `open-termscript'), then
|
|
1823 the output also will be logged to this file.
|
|
1824 */
|
|
1825 (char_or_string, stdout_p, device))
|
|
1826 {
|
|
1827 FILE *file = 0;
|
|
1828 struct console *con = 0;
|
|
1829
|
|
1830 if (NILP (device))
|
|
1831 {
|
|
1832 if (!NILP (stdout_p))
|
|
1833 file = stdout;
|
|
1834 else
|
|
1835 file = stderr;
|
|
1836 }
|
|
1837 else
|
|
1838 {
|
|
1839 CHECK_LIVE_DEVICE (device);
|
|
1840 if (!DEVICE_TTY_P (XDEVICE (device)) &&
|
|
1841 !DEVICE_STREAM_P (XDEVICE (device)))
|
563
|
1842 wtaerror ("Must be tty or stream device", device);
|
428
|
1843 con = XCONSOLE (DEVICE_CONSOLE (XDEVICE (device)));
|
|
1844 if (DEVICE_TTY_P (XDEVICE (device)))
|
|
1845 file = 0;
|
|
1846 else if (!NILP (stdout_p))
|
|
1847 file = CONSOLE_STREAM_DATA (con)->out;
|
|
1848 else
|
|
1849 file = CONSOLE_STREAM_DATA (con)->err;
|
|
1850 }
|
|
1851
|
|
1852 if (STRINGP (char_or_string))
|
|
1853 write_string_to_stdio_stream (file, con,
|
|
1854 XSTRING_DATA (char_or_string),
|
771
|
1855 XSTRING_LENGTH (char_or_string),
|
|
1856 print_unbuffered);
|
428
|
1857 else
|
|
1858 {
|
665
|
1859 Intbyte str[MAX_EMCHAR_LEN];
|
428
|
1860 Bytecount len;
|
|
1861
|
|
1862 CHECK_CHAR_COERCE_INT (char_or_string);
|
|
1863 len = set_charptr_emchar (str, XCHAR (char_or_string));
|
771
|
1864 write_string_to_stdio_stream (file, con, str, len, print_unbuffered);
|
428
|
1865 }
|
|
1866
|
|
1867 return char_or_string;
|
|
1868 }
|
|
1869
|
|
1870 DEFUN ("open-termscript", Fopen_termscript, 1, 1, "FOpen termscript file: ", /*
|
444
|
1871 Start writing all terminal output to FILENAME as well as the terminal.
|
|
1872 FILENAME = nil means just close any termscript file currently open.
|
428
|
1873 */
|
444
|
1874 (filename))
|
428
|
1875 {
|
|
1876 /* This function can GC */
|
|
1877 if (termscript != 0)
|
|
1878 {
|
771
|
1879 retry_fclose (termscript);
|
444
|
1880 termscript = 0;
|
|
1881 }
|
|
1882
|
|
1883 if (! NILP (filename))
|
|
1884 {
|
|
1885 filename = Fexpand_file_name (filename, Qnil);
|
771
|
1886 termscript = qxe_fopen (XSTRING_DATA (filename), "w");
|
428
|
1887 if (termscript == NULL)
|
563
|
1888 report_file_error ("Opening termscript", filename);
|
428
|
1889 }
|
|
1890 return Qnil;
|
|
1891 }
|
|
1892
|
440
|
1893 static int debug_print_length = 50;
|
|
1894 static int debug_print_level = 15;
|
|
1895 static int debug_print_readably = -1;
|
428
|
1896
|
771
|
1897 /* Debugging kludge -- unbuffered */
|
428
|
1898 static void
|
|
1899 debug_print_no_newline (Lisp_Object debug_print_obj)
|
|
1900 {
|
|
1901 /* This function can GC */
|
440
|
1902 int save_print_readably = print_readably;
|
|
1903 int save_print_depth = print_depth;
|
|
1904 Lisp_Object save_Vprint_length = Vprint_length;
|
|
1905 Lisp_Object save_Vprint_level = Vprint_level;
|
|
1906 Lisp_Object save_Vinhibit_quit = Vinhibit_quit;
|
428
|
1907 struct gcpro gcpro1, gcpro2, gcpro3;
|
440
|
1908 GCPRO3 (save_Vprint_level, save_Vprint_length, save_Vinhibit_quit);
|
428
|
1909
|
|
1910 print_depth = 0;
|
440
|
1911 print_readably = debug_print_readably != -1 ? debug_print_readably : 0;
|
428
|
1912 print_unbuffered++;
|
|
1913 /* Could use unwind-protect, but why bother? */
|
|
1914 if (debug_print_length > 0)
|
|
1915 Vprint_length = make_int (debug_print_length);
|
|
1916 if (debug_print_level > 0)
|
|
1917 Vprint_level = make_int (debug_print_level);
|
440
|
1918
|
428
|
1919 print_internal (debug_print_obj, Qexternal_debugging_output, 1);
|
442
|
1920 alternate_do_pointer = 0;
|
|
1921 print_internal (debug_print_obj, Qalternate_debugging_output, 1);
|
|
1922 #ifdef WIN32_NATIVE
|
|
1923 /* Write out to the debugger, as well */
|
|
1924 print_internal (debug_print_obj, Qmswindows_debugging_output, 1);
|
|
1925 #endif
|
440
|
1926
|
|
1927 Vinhibit_quit = save_Vinhibit_quit;
|
|
1928 Vprint_level = save_Vprint_level;
|
|
1929 Vprint_length = save_Vprint_length;
|
|
1930 print_depth = save_print_depth;
|
|
1931 print_readably = save_print_readably;
|
428
|
1932 print_unbuffered--;
|
|
1933 UNGCPRO;
|
|
1934 }
|
|
1935
|
|
1936 void
|
|
1937 debug_print (Lisp_Object debug_print_obj)
|
|
1938 {
|
|
1939 debug_print_no_newline (debug_print_obj);
|
771
|
1940 debug_out ("\n");
|
428
|
1941 }
|
|
1942
|
|
1943 /* Debugging kludge -- unbuffered */
|
|
1944 /* This function provided for the benefit of the debugger. */
|
|
1945 void
|
|
1946 debug_backtrace (void)
|
|
1947 {
|
|
1948 /* This function can GC */
|
|
1949 int old_print_readably = print_readably;
|
|
1950 int old_print_depth = print_depth;
|
|
1951 Lisp_Object old_print_length = Vprint_length;
|
|
1952 Lisp_Object old_print_level = Vprint_level;
|
|
1953 Lisp_Object old_inhibit_quit = Vinhibit_quit;
|
|
1954
|
|
1955 struct gcpro gcpro1, gcpro2, gcpro3;
|
|
1956 GCPRO3 (old_print_level, old_print_length, old_inhibit_quit);
|
|
1957
|
|
1958 print_depth = 0;
|
|
1959 print_readably = 0;
|
|
1960 print_unbuffered++;
|
|
1961 /* Could use unwind-protect, but why bother? */
|
|
1962 if (debug_print_length > 0)
|
|
1963 Vprint_length = make_int (debug_print_length);
|
|
1964 if (debug_print_level > 0)
|
|
1965 Vprint_level = make_int (debug_print_level);
|
|
1966
|
|
1967 Fbacktrace (Qexternal_debugging_output, Qt);
|
|
1968 stderr_out ("\n");
|
|
1969
|
|
1970 Vinhibit_quit = old_inhibit_quit;
|
|
1971 Vprint_level = old_print_level;
|
|
1972 Vprint_length = old_print_length;
|
|
1973 print_depth = old_print_depth;
|
|
1974 print_readably = old_print_readably;
|
|
1975 print_unbuffered--;
|
|
1976
|
|
1977 UNGCPRO;
|
|
1978 }
|
|
1979
|
|
1980 void
|
|
1981 debug_short_backtrace (int length)
|
|
1982 {
|
|
1983 int first = 1;
|
|
1984 struct backtrace *bt = backtrace_list;
|
771
|
1985 debug_out (" [");
|
428
|
1986 while (length > 0 && bt)
|
|
1987 {
|
|
1988 if (!first)
|
|
1989 {
|
771
|
1990 debug_out (", ");
|
428
|
1991 }
|
|
1992 if (COMPILED_FUNCTIONP (*bt->function))
|
|
1993 {
|
|
1994 #if defined(COMPILED_FUNCTION_ANNOTATION_HACK)
|
|
1995 Lisp_Object ann =
|
|
1996 compiled_function_annotation (XCOMPILED_FUNCTION (*bt->function));
|
|
1997 #else
|
|
1998 Lisp_Object ann = Qnil;
|
|
1999 #endif
|
|
2000 if (!NILP (ann))
|
|
2001 {
|
771
|
2002 debug_out ("<compiled-function from ");
|
428
|
2003 debug_print_no_newline (ann);
|
771
|
2004 debug_out (">");
|
428
|
2005 }
|
|
2006 else
|
|
2007 {
|
771
|
2008 debug_out ("<compiled-function of unknown origin>");
|
428
|
2009 }
|
|
2010 }
|
|
2011 else
|
|
2012 debug_print_no_newline (*bt->function);
|
|
2013 first = 0;
|
|
2014 length--;
|
|
2015 bt = bt->next;
|
|
2016 }
|
771
|
2017 debug_out ("]\n");
|
428
|
2018 }
|
|
2019
|
|
2020
|
|
2021 void
|
|
2022 syms_of_print (void)
|
|
2023 {
|
563
|
2024 DEFSYMBOL (Qstandard_output);
|
428
|
2025
|
563
|
2026 DEFSYMBOL (Qprint_length);
|
428
|
2027
|
563
|
2028 DEFSYMBOL (Qprint_string_length);
|
428
|
2029
|
563
|
2030 DEFSYMBOL (Qdisplay_error);
|
|
2031 DEFSYMBOL (Qprint_message_label);
|
428
|
2032
|
|
2033 DEFSUBR (Fprin1);
|
|
2034 DEFSUBR (Fprin1_to_string);
|
|
2035 DEFSUBR (Fprinc);
|
|
2036 DEFSUBR (Fprint);
|
|
2037 DEFSUBR (Ferror_message_string);
|
|
2038 DEFSUBR (Fdisplay_error);
|
|
2039 DEFSUBR (Fterpri);
|
|
2040 DEFSUBR (Fwrite_char);
|
|
2041 DEFSUBR (Falternate_debugging_output);
|
|
2042 DEFSUBR (Fexternal_debugging_output);
|
|
2043 DEFSUBR (Fopen_termscript);
|
563
|
2044 DEFSYMBOL (Qexternal_debugging_output);
|
|
2045 DEFSYMBOL (Qalternate_debugging_output);
|
442
|
2046 #ifdef HAVE_MS_WINDOWS
|
563
|
2047 DEFSYMBOL (Qmswindows_debugging_output);
|
442
|
2048 #endif
|
428
|
2049 DEFSUBR (Fwith_output_to_temp_buffer);
|
|
2050 }
|
|
2051
|
|
2052 void
|
|
2053 reinit_vars_of_print (void)
|
|
2054 {
|
|
2055 alternate_do_pointer = 0;
|
|
2056 }
|
|
2057
|
|
2058 void
|
|
2059 vars_of_print (void)
|
|
2060 {
|
|
2061 reinit_vars_of_print ();
|
|
2062
|
|
2063 DEFVAR_LISP ("standard-output", &Vstandard_output /*
|
|
2064 Output stream `print' uses by default for outputting a character.
|
|
2065 This may be any function of one argument.
|
|
2066 It may also be a buffer (output is inserted before point)
|
|
2067 or a marker (output is inserted and the marker is advanced)
|
|
2068 or the symbol t (output appears in the minibuffer line).
|
|
2069 */ );
|
|
2070 Vstandard_output = Qt;
|
|
2071
|
|
2072 #ifdef LISP_FLOAT_TYPE
|
|
2073 DEFVAR_LISP ("float-output-format", &Vfloat_output_format /*
|
|
2074 The format descriptor string that lisp uses to print floats.
|
|
2075 This is a %-spec like those accepted by `printf' in C,
|
|
2076 but with some restrictions. It must start with the two characters `%.'.
|
|
2077 After that comes an integer precision specification,
|
|
2078 and then a letter which controls the format.
|
|
2079 The letters allowed are `e', `f' and `g'.
|
|
2080 Use `e' for exponential notation "DIG.DIGITSeEXPT"
|
|
2081 Use `f' for decimal point notation "DIGITS.DIGITS".
|
|
2082 Use `g' to choose the shorter of those two formats for the number at hand.
|
|
2083 The precision in any of these cases is the number of digits following
|
|
2084 the decimal point. With `f', a precision of 0 means to omit the
|
|
2085 decimal point. 0 is not allowed with `f' or `g'.
|
|
2086
|
|
2087 A value of nil means to use `%.16g'.
|
|
2088
|
|
2089 Regardless of the value of `float-output-format', a floating point number
|
|
2090 will never be printed in such a way that it is ambiguous with an integer;
|
|
2091 that is, a floating-point number will always be printed with a decimal
|
|
2092 point and/or an exponent, even if the digits following the decimal point
|
|
2093 are all zero. This is to preserve read-equivalence.
|
|
2094 */ );
|
|
2095 Vfloat_output_format = Qnil;
|
|
2096 #endif /* LISP_FLOAT_TYPE */
|
|
2097
|
|
2098 DEFVAR_LISP ("print-length", &Vprint_length /*
|
|
2099 Maximum length of list or vector to print before abbreviating.
|
|
2100 A value of nil means no limit.
|
|
2101 */ );
|
|
2102 Vprint_length = Qnil;
|
|
2103
|
|
2104 DEFVAR_LISP ("print-string-length", &Vprint_string_length /*
|
|
2105 Maximum length of string to print before abbreviating.
|
|
2106 A value of nil means no limit.
|
|
2107 */ );
|
|
2108 Vprint_string_length = Qnil;
|
|
2109
|
|
2110 DEFVAR_LISP ("print-level", &Vprint_level /*
|
|
2111 Maximum depth of list nesting to print before abbreviating.
|
|
2112 A value of nil means no limit.
|
|
2113 */ );
|
|
2114 Vprint_level = Qnil;
|
|
2115
|
|
2116 DEFVAR_BOOL ("print-escape-newlines", &print_escape_newlines /*
|
|
2117 Non-nil means print newlines in strings as backslash-n.
|
|
2118 */ );
|
|
2119 print_escape_newlines = 0;
|
|
2120
|
|
2121 DEFVAR_BOOL ("print-readably", &print_readably /*
|
|
2122 If non-nil, then all objects will be printed in a readable form.
|
|
2123 If an object has no readable representation, then an error is signalled.
|
|
2124 When print-readably is true, compiled-function objects will be written in
|
|
2125 #[...] form instead of in #<compiled-function [...]> form, and two-element
|
|
2126 lists of the form (quote object) will be written as the equivalent 'object.
|
|
2127 Do not SET this variable; bind it instead.
|
|
2128 */ );
|
|
2129 print_readably = 0;
|
|
2130
|
|
2131 /* #### I think this should default to t. But we'd better wait
|
|
2132 until we see that it works out. */
|
|
2133 DEFVAR_LISP ("print-gensym", &Vprint_gensym /*
|
|
2134 If non-nil, then uninterned symbols will be printed specially.
|
|
2135 Uninterned symbols are those which are not present in `obarray', that is,
|
|
2136 those which were made with `make-symbol' or by calling `intern' with a
|
|
2137 second argument.
|
|
2138
|
|
2139 When print-gensym is true, such symbols will be preceded by "#:",
|
|
2140 which causes the reader to create a new symbol instead of interning
|
|
2141 and returning an existing one. Beware: the #: syntax creates a new
|
|
2142 symbol each time it is seen, so if you print an object which contains
|
|
2143 two pointers to the same uninterned symbol, `read' will not duplicate
|
|
2144 that structure.
|
|
2145
|
|
2146 If the value of `print-gensym' is a cons cell, then in addition
|
|
2147 refrain from clearing `print-gensym-alist' on entry to and exit from
|
|
2148 printing functions, so that the use of #...# and #...= can carry over
|
|
2149 for several separately printed objects.
|
|
2150 */ );
|
|
2151 Vprint_gensym = Qnil;
|
|
2152
|
|
2153 DEFVAR_LISP ("print-gensym-alist", &Vprint_gensym_alist /*
|
|
2154 Association list of elements (GENSYM . N) to guide use of #N# and #N=.
|
|
2155 In each element, GENSYM is an uninterned symbol that has been associated
|
|
2156 with #N= for the specified value of N.
|
|
2157 */ );
|
|
2158 Vprint_gensym_alist = Qnil;
|
|
2159
|
|
2160 DEFVAR_LISP ("print-message-label", &Vprint_message_label /*
|
|
2161 Label for minibuffer messages created with `print'. This should
|
|
2162 generally be bound with `let' rather than set. (See `display-message'.)
|
|
2163 */ );
|
|
2164 Vprint_message_label = Qprint;
|
|
2165 }
|