Mercurial > emacs
annotate src/print.c @ 10434:5cb0747f521f
(iso-aggressive-german-trans-tab): Doc fix.
(iso-cvt-ffh, iso-cvt-wfh, iso-cvt-ash): Doc fix.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Mon, 16 Jan 1995 22:48:03 +0000 |
parents | fdad41459fd6 |
children | a15a058ec779 |
rev | line source |
---|---|
329 | 1 /* Lisp object printing and output streams. |
5852
f2e341b1f908
(print): If print_escapes_newlines, print '\f' as "\\f".
Roland McGrath <roland@gnu.org>
parents:
5487
diff
changeset
|
2 Copyright (C) 1985, 1986, 1988, 1993, 1994 Free Software Foundation, Inc. |
329 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
621 | 8 the Free Software Foundation; either version 2, or (at your option) |
329 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4224
diff
changeset
|
21 #include <config.h> |
329 | 22 #include <stdio.h> |
23 #undef NULL | |
24 #include "lisp.h" | |
25 | |
26 #ifndef standalone | |
27 #include "buffer.h" | |
766 | 28 #include "frame.h" |
329 | 29 #include "window.h" |
30 #include "process.h" | |
31 #include "dispextern.h" | |
32 #include "termchar.h" | |
33 #endif /* not standalone */ | |
34 | |
1967 | 35 #ifdef USE_TEXT_PROPERTIES |
36 #include "intervals.h" | |
37 #endif | |
38 | |
329 | 39 Lisp_Object Vstandard_output, Qstandard_output; |
40 | |
41 #ifdef LISP_FLOAT_TYPE | |
42 Lisp_Object Vfloat_output_format, Qfloat_output_format; | |
43 #endif /* LISP_FLOAT_TYPE */ | |
44 | |
45 /* Avoid actual stack overflow in print. */ | |
46 int print_depth; | |
47 | |
379
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
48 /* Detect most circularities to print finite output. */ |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
49 #define PRINT_CIRCLE 200 |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
50 Lisp_Object being_printed[PRINT_CIRCLE]; |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
51 |
329 | 52 /* Maximum length of list to print in full; noninteger means |
53 effectively infinity */ | |
54 | |
55 Lisp_Object Vprint_length; | |
56 | |
57 /* Maximum depth of list to print in full; noninteger means | |
58 effectively infinity. */ | |
59 | |
60 Lisp_Object Vprint_level; | |
61 | |
62 /* Nonzero means print newlines in strings as \n. */ | |
63 | |
64 int print_escape_newlines; | |
65 | |
66 Lisp_Object Qprint_escape_newlines; | |
67 | |
10418
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
68 /* Nonzero means print newline to stdout before next minibuffer message. |
329 | 69 Defined in xdisp.c */ |
70 | |
71 extern int noninteractive_need_newline; | |
10418
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
72 |
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
73 /* Nonzero means print newline to message log before next message. |
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
74 Defined in xdisp.c */ |
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
75 |
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
76 extern int message_log_need_newline; |
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
77 |
329 | 78 #ifdef MAX_PRINT_CHARS |
79 static int print_chars; | |
80 static int max_print; | |
81 #endif /* MAX_PRINT_CHARS */ | |
1967 | 82 |
83 void print_interval (); | |
329 | 84 |
85 #if 0 | |
86 /* Convert between chars and GLYPHs */ | |
87 | |
88 int | |
89 glyphlen (glyphs) | |
90 register GLYPH *glyphs; | |
91 { | |
92 register int i = 0; | |
93 | |
94 while (glyphs[i]) | |
95 i++; | |
96 return i; | |
97 } | |
98 | |
99 void | |
100 str_to_glyph_cpy (str, glyphs) | |
101 char *str; | |
102 GLYPH *glyphs; | |
103 { | |
104 register GLYPH *gp = glyphs; | |
105 register char *cp = str; | |
106 | |
107 while (*cp) | |
108 *gp++ = *cp++; | |
109 } | |
110 | |
111 void | |
112 str_to_glyph_ncpy (str, glyphs, n) | |
113 char *str; | |
114 GLYPH *glyphs; | |
115 register int n; | |
116 { | |
117 register GLYPH *gp = glyphs; | |
118 register char *cp = str; | |
119 | |
120 while (n-- > 0) | |
121 *gp++ = *cp++; | |
122 } | |
123 | |
124 void | |
125 glyph_to_str_cpy (glyphs, str) | |
126 GLYPH *glyphs; | |
127 char *str; | |
128 { | |
129 register GLYPH *gp = glyphs; | |
130 register char *cp = str; | |
131 | |
132 while (*gp) | |
133 *str++ = *gp++ & 0377; | |
134 } | |
135 #endif | |
136 | |
3591
507f64624555
Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents:
3377
diff
changeset
|
137 /* Low level output routines for characters and strings */ |
329 | 138 |
139 /* Lisp functions to do output using a stream | |
140 must have the stream in a variable called printcharfun | |
141 and must start with PRINTPREPARE and end with PRINTFINISH. | |
142 Use PRINTCHAR to output one character, | |
143 or call strout to output a block of characters. | |
144 Also, each one must have the declarations | |
145 struct buffer *old = current_buffer; | |
146 int old_point = -1, start_point; | |
147 Lisp_Object original; | |
148 */ | |
149 | |
2193
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
150 #define PRINTPREPARE \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
151 original = printcharfun; \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
152 if (NILP (printcharfun)) printcharfun = Qt; \ |
9117
f69e6cf74874
(PRINTPREPARE, PRINTFINISH, float_to_string, print): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8854
diff
changeset
|
153 if (BUFFERP (printcharfun)) \ |
2193
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
154 { if (XBUFFER (printcharfun) != current_buffer) \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
155 Fset_buffer (printcharfun); \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
156 printcharfun = Qnil;} \ |
9117
f69e6cf74874
(PRINTPREPARE, PRINTFINISH, float_to_string, print): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8854
diff
changeset
|
157 if (MARKERP (printcharfun)) \ |
2193
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
158 { if (!(XMARKER (original)->buffer)) \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
159 error ("Marker does not point anywhere"); \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
160 if (XMARKER (original)->buffer != current_buffer) \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
161 set_buffer_internal (XMARKER (original)->buffer); \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
162 old_point = point; \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
163 SET_PT (marker_position (printcharfun)); \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
164 start_point = point; \ |
329 | 165 printcharfun = Qnil;} |
166 | |
2193
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
167 #define PRINTFINISH \ |
9117
f69e6cf74874
(PRINTPREPARE, PRINTFINISH, float_to_string, print): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8854
diff
changeset
|
168 if (MARKERP (original)) \ |
2193
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
169 Fset_marker (original, make_number (point), Qnil); \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
170 if (old_point >= 0) \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
171 SET_PT (old_point + (old_point >= start_point \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
172 ? point - start_point : 0)); \ |
652b38173a63
(PRINTPREPARE): Handle marker that points nowhere.
Richard M. Stallman <rms@gnu.org>
parents:
1991
diff
changeset
|
173 if (old != current_buffer) \ |
329 | 174 set_buffer_internal (old) |
175 | |
176 #define PRINTCHAR(ch) printchar (ch, printcharfun) | |
177 | |
5487
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
178 /* Index of first unused element of FRAME_MESSAGE_BUF(mini_frame). */ |
329 | 179 static int printbufidx; |
180 | |
181 static void | |
182 printchar (ch, fun) | |
183 unsigned char ch; | |
184 Lisp_Object fun; | |
185 { | |
186 Lisp_Object ch1; | |
187 | |
188 #ifdef MAX_PRINT_CHARS | |
189 if (max_print) | |
190 print_chars++; | |
191 #endif /* MAX_PRINT_CHARS */ | |
192 #ifndef standalone | |
193 if (EQ (fun, Qnil)) | |
194 { | |
195 QUIT; | |
196 insert (&ch, 1); | |
197 return; | |
198 } | |
199 | |
200 if (EQ (fun, Qt)) | |
201 { | |
6808
514a324b3681
(printchar, strout): Use FRAME_PTR, not struct frame *.
Karl Heuer <kwzh@gnu.org>
parents:
6802
diff
changeset
|
202 FRAME_PTR mini_frame |
5487
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
203 = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); |
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
204 |
329 | 205 if (noninteractive) |
206 { | |
207 putchar (ch); | |
208 noninteractive_need_newline = 1; | |
209 return; | |
210 } | |
211 | |
5487
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
212 if (echo_area_glyphs != FRAME_MESSAGE_BUF (mini_frame) |
329 | 213 || !message_buf_print) |
214 { | |
10418
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
215 if (message_log_need_newline) |
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
216 message_dolog ("", 0, 1); |
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
217 message_log_need_newline = 0; |
5487
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
218 echo_area_glyphs = FRAME_MESSAGE_BUF (mini_frame); |
329 | 219 printbufidx = 0; |
5233
83e771f33251
(printchar, strout): Set echo_area_glyphs_length.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
220 echo_area_glyphs_length = 0; |
329 | 221 message_buf_print = 1; |
222 } | |
223 | |
10418
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
224 message_dolog (&ch, 1, 0); |
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
225 message_log_need_newline = 1; |
5487
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
226 if (printbufidx < FRAME_WIDTH (mini_frame) - 1) |
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
227 FRAME_MESSAGE_BUF (mini_frame)[printbufidx++] = ch; |
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
228 FRAME_MESSAGE_BUF (mini_frame)[printbufidx] = 0; |
5233
83e771f33251
(printchar, strout): Set echo_area_glyphs_length.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
229 echo_area_glyphs_length = printbufidx; |
329 | 230 |
231 return; | |
232 } | |
233 #endif /* not standalone */ | |
234 | |
9317
58f6a917533b
(printchar): Don't use XFASTINT as an lvalue.
Karl Heuer <kwzh@gnu.org>
parents:
9276
diff
changeset
|
235 XSETFASTINT (ch1, ch); |
329 | 236 call1 (fun, ch1); |
237 } | |
238 | |
239 static void | |
240 strout (ptr, size, printcharfun) | |
241 char *ptr; | |
242 int size; | |
243 Lisp_Object printcharfun; | |
244 { | |
245 int i = 0; | |
246 | |
247 if (EQ (printcharfun, Qnil)) | |
248 { | |
249 insert (ptr, size >= 0 ? size : strlen (ptr)); | |
250 #ifdef MAX_PRINT_CHARS | |
251 if (max_print) | |
252 print_chars += size >= 0 ? size : strlen(ptr); | |
253 #endif /* MAX_PRINT_CHARS */ | |
254 return; | |
255 } | |
256 if (EQ (printcharfun, Qt)) | |
257 { | |
6808
514a324b3681
(printchar, strout): Use FRAME_PTR, not struct frame *.
Karl Heuer <kwzh@gnu.org>
parents:
6802
diff
changeset
|
258 FRAME_PTR mini_frame |
5487
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
259 = XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window))); |
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
260 |
329 | 261 i = size >= 0 ? size : strlen (ptr); |
262 #ifdef MAX_PRINT_CHARS | |
263 if (max_print) | |
264 print_chars += i; | |
265 #endif /* MAX_PRINT_CHARS */ | |
266 | |
267 if (noninteractive) | |
268 { | |
269 fwrite (ptr, 1, i, stdout); | |
270 noninteractive_need_newline = 1; | |
271 return; | |
272 } | |
273 | |
5487
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
274 if (echo_area_glyphs != FRAME_MESSAGE_BUF (mini_frame) |
329 | 275 || !message_buf_print) |
276 { | |
10418
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
277 if (message_log_need_newline) |
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
278 message_dolog ("", 0, 1); |
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
279 message_log_need_newline = 0; |
5487
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
280 echo_area_glyphs = FRAME_MESSAGE_BUF (mini_frame); |
329 | 281 printbufidx = 0; |
5233
83e771f33251
(printchar, strout): Set echo_area_glyphs_length.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
282 echo_area_glyphs_length = 0; |
329 | 283 message_buf_print = 1; |
284 } | |
285 | |
10418
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
286 message_dolog (ptr, i, 0); |
fdad41459fd6
(printchar, strout): Call message_dolog.
Karl Heuer <kwzh@gnu.org>
parents:
10301
diff
changeset
|
287 message_log_need_newline = 1; |
5487
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
288 if (i > FRAME_WIDTH (mini_frame) - printbufidx - 1) |
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
289 i = FRAME_WIDTH (mini_frame) - printbufidx - 1; |
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
290 bcopy (ptr, &FRAME_MESSAGE_BUF (mini_frame) [printbufidx], i); |
329 | 291 printbufidx += i; |
5233
83e771f33251
(printchar, strout): Set echo_area_glyphs_length.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
292 echo_area_glyphs_length = printbufidx; |
5487
58a9bb23c3ea
(strout, printchar): Use proper frame for minibuffer.
Richard M. Stallman <rms@gnu.org>
parents:
5233
diff
changeset
|
293 FRAME_MESSAGE_BUF (mini_frame) [printbufidx] = 0; |
329 | 294 |
295 return; | |
296 } | |
297 | |
298 if (size >= 0) | |
299 while (i < size) | |
300 PRINTCHAR (ptr[i++]); | |
301 else | |
302 while (ptr[i]) | |
303 PRINTCHAR (ptr[i++]); | |
304 } | |
305 | |
306 /* Print the contents of a string STRING using PRINTCHARFUN. | |
307 It isn't safe to use strout, because printing one char can relocate. */ | |
308 | |
309 print_string (string, printcharfun) | |
310 Lisp_Object string; | |
311 Lisp_Object printcharfun; | |
312 { | |
313 if (EQ (printcharfun, Qnil) || EQ (printcharfun, Qt)) | |
766 | 314 /* In predictable cases, strout is safe: output to buffer or frame. */ |
329 | 315 strout (XSTRING (string)->data, XSTRING (string)->size, printcharfun); |
316 else | |
317 { | |
318 /* Otherwise, fetch the string address for each character. */ | |
319 int i; | |
320 int size = XSTRING (string)->size; | |
321 struct gcpro gcpro1; | |
322 GCPRO1 (string); | |
323 for (i = 0; i < size; i++) | |
324 PRINTCHAR (XSTRING (string)->data[i]); | |
325 UNGCPRO; | |
326 } | |
327 } | |
328 | |
329 DEFUN ("write-char", Fwrite_char, Swrite_char, 1, 2, 0, | |
7185 | 330 "Output character CHAR to stream PRINTCHARFUN.\n\ |
331 PRINTCHARFUN defaults to the value of `standard-output' (which see).") | |
329 | 332 (ch, printcharfun) |
333 Lisp_Object ch, printcharfun; | |
334 { | |
335 struct buffer *old = current_buffer; | |
336 int old_point = -1; | |
337 int start_point; | |
338 Lisp_Object original; | |
339 | |
520 | 340 if (NILP (printcharfun)) |
329 | 341 printcharfun = Vstandard_output; |
342 CHECK_NUMBER (ch, 0); | |
343 PRINTPREPARE; | |
344 PRINTCHAR (XINT (ch)); | |
345 PRINTFINISH; | |
346 return ch; | |
347 } | |
348 | |
349 /* Used from outside of print.c to print a block of SIZE chars at DATA | |
350 on the default output stream. | |
351 Do not use this on the contents of a Lisp string. */ | |
352 | |
353 write_string (data, size) | |
354 char *data; | |
355 int size; | |
356 { | |
357 struct buffer *old = current_buffer; | |
358 Lisp_Object printcharfun; | |
359 int old_point = -1; | |
360 int start_point; | |
361 Lisp_Object original; | |
362 | |
363 printcharfun = Vstandard_output; | |
364 | |
365 PRINTPREPARE; | |
366 strout (data, size, printcharfun); | |
367 PRINTFINISH; | |
368 } | |
369 | |
370 /* Used from outside of print.c to print a block of SIZE chars at DATA | |
371 on a specified stream PRINTCHARFUN. | |
372 Do not use this on the contents of a Lisp string. */ | |
373 | |
374 write_string_1 (data, size, printcharfun) | |
375 char *data; | |
376 int size; | |
377 Lisp_Object printcharfun; | |
378 { | |
379 struct buffer *old = current_buffer; | |
380 int old_point = -1; | |
381 int start_point; | |
382 Lisp_Object original; | |
383 | |
384 PRINTPREPARE; | |
385 strout (data, size, printcharfun); | |
386 PRINTFINISH; | |
387 } | |
388 | |
389 | |
390 #ifndef standalone | |
391 | |
392 void | |
393 temp_output_buffer_setup (bufname) | |
394 char *bufname; | |
395 { | |
396 register struct buffer *old = current_buffer; | |
397 register Lisp_Object buf; | |
398 | |
399 Fset_buffer (Fget_buffer_create (build_string (bufname))); | |
400 | |
401 current_buffer->read_only = Qnil; | |
402 Ferase_buffer (); | |
403 | |
9276
ae62e12feac5
(temp_output_buffer_setup): Use new accessor macros instead of calling XSET
Karl Heuer <kwzh@gnu.org>
parents:
9117
diff
changeset
|
404 XSETBUFFER (buf, current_buffer); |
329 | 405 specbind (Qstandard_output, buf); |
406 | |
407 set_buffer_internal (old); | |
408 } | |
409 | |
410 Lisp_Object | |
411 internal_with_output_to_temp_buffer (bufname, function, args) | |
412 char *bufname; | |
413 Lisp_Object (*function) (); | |
414 Lisp_Object args; | |
415 { | |
416 int count = specpdl_ptr - specpdl; | |
417 Lisp_Object buf, val; | |
8315
8921d0012bd5
(internal_with_output_to_temp_buffer): gcpro things.
Richard M. Stallman <rms@gnu.org>
parents:
7185
diff
changeset
|
418 struct gcpro gcpro1; |
329 | 419 |
8315
8921d0012bd5
(internal_with_output_to_temp_buffer): gcpro things.
Richard M. Stallman <rms@gnu.org>
parents:
7185
diff
changeset
|
420 GCPRO1 (args); |
329 | 421 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
422 temp_output_buffer_setup (bufname); | |
423 buf = Vstandard_output; | |
8315
8921d0012bd5
(internal_with_output_to_temp_buffer): gcpro things.
Richard M. Stallman <rms@gnu.org>
parents:
7185
diff
changeset
|
424 UNGCPRO; |
329 | 425 |
426 val = (*function) (args); | |
427 | |
8315
8921d0012bd5
(internal_with_output_to_temp_buffer): gcpro things.
Richard M. Stallman <rms@gnu.org>
parents:
7185
diff
changeset
|
428 GCPRO1 (val); |
329 | 429 temp_output_buffer_show (buf); |
8315
8921d0012bd5
(internal_with_output_to_temp_buffer): gcpro things.
Richard M. Stallman <rms@gnu.org>
parents:
7185
diff
changeset
|
430 UNGCPRO; |
329 | 431 |
432 return unbind_to (count, val); | |
433 } | |
434 | |
435 DEFUN ("with-output-to-temp-buffer", Fwith_output_to_temp_buffer, Swith_output_to_temp_buffer, | |
436 1, UNEVALLED, 0, | |
437 "Bind `standard-output' to buffer BUFNAME, eval BODY, then show that buffer.\n\ | |
438 The buffer is cleared out initially, and marked as unmodified when done.\n\ | |
439 All output done by BODY is inserted in that buffer by default.\n\ | |
440 The buffer is displayed in another window, but not selected.\n\ | |
441 The value of the last form in BODY is returned.\n\ | |
442 If BODY does not finish normally, the buffer BUFNAME is not displayed.\n\n\ | |
3337
f5f76ebe6286
(Fwith_output_to_temp_buffer): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
2782
diff
changeset
|
443 If variable `temp-buffer-show-function' is non-nil, call it at the end\n\ |
329 | 444 to get the buffer displayed. It gets one argument, the buffer to display.") |
445 (args) | |
446 Lisp_Object args; | |
447 { | |
448 struct gcpro gcpro1; | |
449 Lisp_Object name; | |
450 int count = specpdl_ptr - specpdl; | |
451 Lisp_Object buf, val; | |
452 | |
453 GCPRO1(args); | |
454 name = Feval (Fcar (args)); | |
455 UNGCPRO; | |
456 | |
457 CHECK_STRING (name, 0); | |
458 temp_output_buffer_setup (XSTRING (name)->data); | |
459 buf = Vstandard_output; | |
460 | |
461 val = Fprogn (Fcdr (args)); | |
462 | |
463 temp_output_buffer_show (buf); | |
464 | |
465 return unbind_to (count, val); | |
466 } | |
467 #endif /* not standalone */ | |
468 | |
469 static void print (); | |
470 | |
471 DEFUN ("terpri", Fterpri, Sterpri, 0, 1, 0, | |
7185 | 472 "Output a newline to stream PRINTCHARFUN.\n\ |
473 If PRINTCHARFUN is omitted or nil, the value of `standard-output' is used.") | |
329 | 474 (printcharfun) |
475 Lisp_Object printcharfun; | |
476 { | |
477 struct buffer *old = current_buffer; | |
478 int old_point = -1; | |
479 int start_point; | |
480 Lisp_Object original; | |
481 | |
520 | 482 if (NILP (printcharfun)) |
329 | 483 printcharfun = Vstandard_output; |
484 PRINTPREPARE; | |
485 PRINTCHAR ('\n'); | |
486 PRINTFINISH; | |
487 return Qt; | |
488 } | |
489 | |
490 DEFUN ("prin1", Fprin1, Sprin1, 1, 2, 0, | |
491 "Output the printed representation of OBJECT, any Lisp object.\n\ | |
492 Quoting characters are printed when needed to make output that `read'\n\ | |
493 can handle, whenever this is possible.\n\ | |
7185 | 494 Output stream is PRINTCHARFUN, or value of `standard-output' (which see).") |
329 | 495 (obj, printcharfun) |
496 Lisp_Object obj, printcharfun; | |
497 { | |
498 struct buffer *old = current_buffer; | |
499 int old_point = -1; | |
500 int start_point; | |
501 Lisp_Object original; | |
502 | |
503 #ifdef MAX_PRINT_CHARS | |
504 max_print = 0; | |
505 #endif /* MAX_PRINT_CHARS */ | |
520 | 506 if (NILP (printcharfun)) |
329 | 507 printcharfun = Vstandard_output; |
508 PRINTPREPARE; | |
509 print_depth = 0; | |
510 print (obj, printcharfun, 1); | |
511 PRINTFINISH; | |
512 return obj; | |
513 } | |
514 | |
515 /* a buffer which is used to hold output being built by prin1-to-string */ | |
516 Lisp_Object Vprin1_to_string_buffer; | |
517 | |
518 DEFUN ("prin1-to-string", Fprin1_to_string, Sprin1_to_string, 1, 2, 0, | |
519 "Return a string containing the printed representation of OBJECT,\n\ | |
520 any Lisp object. Quoting characters are used when needed to make output\n\ | |
521 that `read' can handle, whenever this is possible, unless the optional\n\ | |
522 second argument NOESCAPE is non-nil.") | |
523 (obj, noescape) | |
524 Lisp_Object obj, noescape; | |
525 { | |
526 struct buffer *old = current_buffer; | |
527 int old_point = -1; | |
528 int start_point; | |
529 Lisp_Object original, printcharfun; | |
530 struct gcpro gcpro1; | |
531 | |
532 printcharfun = Vprin1_to_string_buffer; | |
533 PRINTPREPARE; | |
534 print_depth = 0; | |
520 | 535 print (obj, printcharfun, NILP (noescape)); |
329 | 536 /* Make Vprin1_to_string_buffer be the default buffer after PRINTFINSH */ |
537 PRINTFINISH; | |
538 set_buffer_internal (XBUFFER (Vprin1_to_string_buffer)); | |
539 obj = Fbuffer_string (); | |
540 | |
541 GCPRO1 (obj); | |
542 Ferase_buffer (); | |
543 set_buffer_internal (old); | |
544 UNGCPRO; | |
545 | |
546 return obj; | |
547 } | |
548 | |
549 DEFUN ("princ", Fprinc, Sprinc, 1, 2, 0, | |
550 "Output the printed representation of OBJECT, any Lisp object.\n\ | |
551 No quoting characters are used; no delimiters are printed around\n\ | |
552 the contents of strings.\n\ | |
7185 | 553 Output stream is PRINTCHARFUN, or value of standard-output (which see).") |
329 | 554 (obj, printcharfun) |
555 Lisp_Object obj, printcharfun; | |
556 { | |
557 struct buffer *old = current_buffer; | |
558 int old_point = -1; | |
559 int start_point; | |
560 Lisp_Object original; | |
561 | |
520 | 562 if (NILP (printcharfun)) |
329 | 563 printcharfun = Vstandard_output; |
564 PRINTPREPARE; | |
565 print_depth = 0; | |
566 print (obj, printcharfun, 0); | |
567 PRINTFINISH; | |
568 return obj; | |
569 } | |
570 | |
571 DEFUN ("print", Fprint, Sprint, 1, 2, 0, | |
572 "Output the printed representation of OBJECT, with newlines around it.\n\ | |
573 Quoting characters are printed when needed to make output that `read'\n\ | |
574 can handle, whenever this is possible.\n\ | |
7185 | 575 Output stream is PRINTCHARFUN, or value of `standard-output' (which see).") |
329 | 576 (obj, printcharfun) |
577 Lisp_Object obj, printcharfun; | |
578 { | |
579 struct buffer *old = current_buffer; | |
580 int old_point = -1; | |
581 int start_point; | |
582 Lisp_Object original; | |
583 struct gcpro gcpro1; | |
584 | |
585 #ifdef MAX_PRINT_CHARS | |
586 print_chars = 0; | |
587 max_print = MAX_PRINT_CHARS; | |
588 #endif /* MAX_PRINT_CHARS */ | |
520 | 589 if (NILP (printcharfun)) |
329 | 590 printcharfun = Vstandard_output; |
591 GCPRO1 (obj); | |
592 PRINTPREPARE; | |
593 print_depth = 0; | |
594 PRINTCHAR ('\n'); | |
595 print (obj, printcharfun, 1); | |
596 PRINTCHAR ('\n'); | |
597 PRINTFINISH; | |
598 #ifdef MAX_PRINT_CHARS | |
599 max_print = 0; | |
600 print_chars = 0; | |
601 #endif /* MAX_PRINT_CHARS */ | |
602 UNGCPRO; | |
603 return obj; | |
604 } | |
605 | |
606 /* The subroutine object for external-debugging-output is kept here | |
607 for the convenience of the debugger. */ | |
608 Lisp_Object Qexternal_debugging_output; | |
609 | |
621 | 610 DEFUN ("external-debugging-output", Fexternal_debugging_output, Sexternal_debugging_output, 1, 1, 0, |
611 "Write CHARACTER to stderr.\n\ | |
329 | 612 You can call print while debugging emacs, and pass it this function\n\ |
613 to make it write to the debugging output.\n") | |
621 | 614 (character) |
615 Lisp_Object character; | |
329 | 616 { |
617 CHECK_NUMBER (character, 0); | |
618 putc (XINT (character), stderr); | |
619 | |
620 return character; | |
621 } | |
6533
49f896769be4
(debug_print): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5852
diff
changeset
|
622 |
49f896769be4
(debug_print): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5852
diff
changeset
|
623 /* This is the interface for debugging printing. */ |
49f896769be4
(debug_print): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5852
diff
changeset
|
624 |
49f896769be4
(debug_print): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5852
diff
changeset
|
625 void |
49f896769be4
(debug_print): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5852
diff
changeset
|
626 debug_print (arg) |
49f896769be4
(debug_print): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5852
diff
changeset
|
627 Lisp_Object arg; |
49f896769be4
(debug_print): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5852
diff
changeset
|
628 { |
49f896769be4
(debug_print): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5852
diff
changeset
|
629 Fprin1 (arg, Qexternal_debugging_output); |
49f896769be4
(debug_print): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5852
diff
changeset
|
630 } |
329 | 631 |
632 #ifdef LISP_FLOAT_TYPE | |
633 | |
634 /* | |
1759
3c615a9dcd64
(float_to_string): Add `.0' at end if needed.
Richard M. Stallman <rms@gnu.org>
parents:
1521
diff
changeset
|
635 * The buffer should be at least as large as the max string size of the |
329 | 636 * largest float, printed in the biggest notation. This is undoubtably |
637 * 20d float_output_format, with the negative of the C-constant "HUGE" | |
638 * from <math.h>. | |
639 * | |
640 * On the vax the worst case is -1e38 in 20d format which takes 61 bytes. | |
641 * | |
642 * I assume that IEEE-754 format numbers can take 329 bytes for the worst | |
643 * case of -1e307 in 20d float_output_format. What is one to do (short of | |
644 * re-writing _doprnt to be more sane)? | |
645 * -wsr | |
646 */ | |
1759
3c615a9dcd64
(float_to_string): Add `.0' at end if needed.
Richard M. Stallman <rms@gnu.org>
parents:
1521
diff
changeset
|
647 |
3c615a9dcd64
(float_to_string): Add `.0' at end if needed.
Richard M. Stallman <rms@gnu.org>
parents:
1521
diff
changeset
|
648 void |
3c615a9dcd64
(float_to_string): Add `.0' at end if needed.
Richard M. Stallman <rms@gnu.org>
parents:
1521
diff
changeset
|
649 float_to_string (buf, data) |
1991
0f88f314fc34
* print.c (float_to_string): Define buf to be an unsigned char, to
Jim Blandy <jimb@redhat.com>
parents:
1967
diff
changeset
|
650 unsigned char *buf; |
329 | 651 double data; |
652 { | |
4140
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
653 unsigned char *cp; |
4224
6cb1cfba6500
(float_to_string): Don't use uninitialized pointer `cp'.
Richard M. Stallman <rms@gnu.org>
parents:
4140
diff
changeset
|
654 int width; |
329 | 655 |
520 | 656 if (NILP (Vfloat_output_format) |
9117
f69e6cf74874
(PRINTPREPARE, PRINTFINISH, float_to_string, print): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8854
diff
changeset
|
657 || !STRINGP (Vfloat_output_format)) |
329 | 658 lose: |
4224
6cb1cfba6500
(float_to_string): Don't use uninitialized pointer `cp'.
Richard M. Stallman <rms@gnu.org>
parents:
4140
diff
changeset
|
659 { |
6cb1cfba6500
(float_to_string): Don't use uninitialized pointer `cp'.
Richard M. Stallman <rms@gnu.org>
parents:
4140
diff
changeset
|
660 sprintf (buf, "%.17g", data); |
6cb1cfba6500
(float_to_string): Don't use uninitialized pointer `cp'.
Richard M. Stallman <rms@gnu.org>
parents:
4140
diff
changeset
|
661 width = -1; |
6cb1cfba6500
(float_to_string): Don't use uninitialized pointer `cp'.
Richard M. Stallman <rms@gnu.org>
parents:
4140
diff
changeset
|
662 } |
329 | 663 else /* oink oink */ |
664 { | |
665 /* Check that the spec we have is fully valid. | |
666 This means not only valid for printf, | |
667 but meant for floats, and reasonable. */ | |
668 cp = XSTRING (Vfloat_output_format)->data; | |
669 | |
670 if (cp[0] != '%') | |
671 goto lose; | |
672 if (cp[1] != '.') | |
673 goto lose; | |
674 | |
675 cp += 2; | |
4140
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
676 |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
677 /* Check the width specification. */ |
4224
6cb1cfba6500
(float_to_string): Don't use uninitialized pointer `cp'.
Richard M. Stallman <rms@gnu.org>
parents:
4140
diff
changeset
|
678 width = -1; |
4140
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
679 if ('0' <= *cp && *cp <= '9') |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
680 for (width = 0; (*cp >= '0' && *cp <= '9'); cp++) |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
681 width = (width * 10) + (*cp - '0'); |
329 | 682 |
683 if (*cp != 'e' && *cp != 'f' && *cp != 'g') | |
684 goto lose; | |
685 | |
4140
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
686 /* A precision of zero is valid for %f; everything else requires |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
687 at least one. Width may be omitted anywhere. */ |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
688 if (width != -1 |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
689 && (width < (*cp != 'f') |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
690 || width > DBL_DIG)) |
329 | 691 goto lose; |
692 | |
693 if (cp[1] != 0) | |
694 goto lose; | |
695 | |
696 sprintf (buf, XSTRING (Vfloat_output_format)->data, data); | |
697 } | |
1759
3c615a9dcd64
(float_to_string): Add `.0' at end if needed.
Richard M. Stallman <rms@gnu.org>
parents:
1521
diff
changeset
|
698 |
4140
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
699 /* Make sure there is a decimal point with digit after, or an |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
700 exponent, so that the value is readable as a float. But don't do |
4224
6cb1cfba6500
(float_to_string): Don't use uninitialized pointer `cp'.
Richard M. Stallman <rms@gnu.org>
parents:
4140
diff
changeset
|
701 this with "%.0f"; it's valid for that not to produce a decimal |
6cb1cfba6500
(float_to_string): Don't use uninitialized pointer `cp'.
Richard M. Stallman <rms@gnu.org>
parents:
4140
diff
changeset
|
702 point. Note that width can be 0 only for %.0f. */ |
6cb1cfba6500
(float_to_string): Don't use uninitialized pointer `cp'.
Richard M. Stallman <rms@gnu.org>
parents:
4140
diff
changeset
|
703 if (width != 0) |
1764
94ff5d9ef48a
(float_to_string): Add final 0 if text ends with decimal pt.
Richard M. Stallman <rms@gnu.org>
parents:
1759
diff
changeset
|
704 { |
4140
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
705 for (cp = buf; *cp; cp++) |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
706 if ((*cp < '0' || *cp > '9') && *cp != '-') |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
707 break; |
1764
94ff5d9ef48a
(float_to_string): Add final 0 if text ends with decimal pt.
Richard M. Stallman <rms@gnu.org>
parents:
1759
diff
changeset
|
708 |
4140
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
709 if (*cp == '.' && cp[1] == 0) |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
710 { |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
711 cp[1] = '0'; |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
712 cp[2] = 0; |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
713 } |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
714 |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
715 if (*cp == 0) |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
716 { |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
717 *cp++ = '.'; |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
718 *cp++ = '0'; |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
719 *cp++ = 0; |
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
720 } |
1759
3c615a9dcd64
(float_to_string): Add `.0' at end if needed.
Richard M. Stallman <rms@gnu.org>
parents:
1521
diff
changeset
|
721 } |
329 | 722 } |
723 #endif /* LISP_FLOAT_TYPE */ | |
724 | |
725 static void | |
726 print (obj, printcharfun, escapeflag) | |
727 Lisp_Object obj; | |
728 register Lisp_Object printcharfun; | |
729 int escapeflag; | |
730 { | |
731 char buf[30]; | |
732 | |
733 QUIT; | |
734 | |
379
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
735 #if 1 /* I'm not sure this is really worth doing. */ |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
736 /* Detect circularities and truncate them. |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
737 No need to offer any alternative--this is better than an error. */ |
9117
f69e6cf74874
(PRINTPREPARE, PRINTFINISH, float_to_string, print): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8854
diff
changeset
|
738 if (CONSP (obj) || VECTORP (obj) || COMPILEDP (obj)) |
379
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
739 { |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
740 int i; |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
741 for (i = 0; i < print_depth; i++) |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
742 if (EQ (obj, being_printed[i])) |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
743 { |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
744 sprintf (buf, "#%d", i); |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
745 strout (buf, -1, printcharfun); |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
746 return; |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
747 } |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
748 } |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
749 #endif |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
750 |
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
751 being_printed[print_depth] = obj; |
329 | 752 print_depth++; |
753 | |
379
34ec8957c6c0
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
373
diff
changeset
|
754 if (print_depth > PRINT_CIRCLE) |
329 | 755 error ("Apparently circular structure being printed"); |
756 #ifdef MAX_PRINT_CHARS | |
757 if (max_print && print_chars > max_print) | |
758 { | |
759 PRINTCHAR ('\n'); | |
760 print_chars = 0; | |
761 } | |
762 #endif /* MAX_PRINT_CHARS */ | |
763 | |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
764 switch (XGCTYPE (obj)) |
329 | 765 { |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
766 case Lisp_Int: |
329 | 767 sprintf (buf, "%d", XINT (obj)); |
768 strout (buf, -1, printcharfun); | |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
769 break; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
770 |
10001 | 771 #ifdef LISP_FLOAT_TYPE |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
772 case Lisp_Float: |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
773 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
774 char pigbuf[350]; /* see comments in float_to_string */ |
329 | 775 |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
776 float_to_string (pigbuf, XFLOAT(obj)->data); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
777 strout (pigbuf, -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
778 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
779 break; |
10001 | 780 #endif |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
781 |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
782 case Lisp_String: |
329 | 783 if (!escapeflag) |
784 print_string (obj, printcharfun); | |
785 else | |
786 { | |
787 register int i; | |
788 register unsigned char c; | |
789 struct gcpro gcpro1; | |
790 | |
1967 | 791 GCPRO1 (obj); |
792 | |
793 #ifdef USE_TEXT_PROPERTIES | |
794 if (!NULL_INTERVAL_P (XSTRING (obj)->intervals)) | |
795 { | |
796 PRINTCHAR ('#'); | |
797 PRINTCHAR ('('); | |
798 } | |
799 #endif | |
329 | 800 |
801 PRINTCHAR ('\"'); | |
802 for (i = 0; i < XSTRING (obj)->size; i++) | |
803 { | |
804 QUIT; | |
805 c = XSTRING (obj)->data[i]; | |
806 if (c == '\n' && print_escape_newlines) | |
807 { | |
808 PRINTCHAR ('\\'); | |
809 PRINTCHAR ('n'); | |
810 } | |
5852
f2e341b1f908
(print): If print_escapes_newlines, print '\f' as "\\f".
Roland McGrath <roland@gnu.org>
parents:
5487
diff
changeset
|
811 else if (c == '\f' && print_escape_newlines) |
f2e341b1f908
(print): If print_escapes_newlines, print '\f' as "\\f".
Roland McGrath <roland@gnu.org>
parents:
5487
diff
changeset
|
812 { |
f2e341b1f908
(print): If print_escapes_newlines, print '\f' as "\\f".
Roland McGrath <roland@gnu.org>
parents:
5487
diff
changeset
|
813 PRINTCHAR ('\\'); |
f2e341b1f908
(print): If print_escapes_newlines, print '\f' as "\\f".
Roland McGrath <roland@gnu.org>
parents:
5487
diff
changeset
|
814 PRINTCHAR ('f'); |
f2e341b1f908
(print): If print_escapes_newlines, print '\f' as "\\f".
Roland McGrath <roland@gnu.org>
parents:
5487
diff
changeset
|
815 } |
329 | 816 else |
817 { | |
818 if (c == '\"' || c == '\\') | |
819 PRINTCHAR ('\\'); | |
820 PRINTCHAR (c); | |
821 } | |
822 } | |
823 PRINTCHAR ('\"'); | |
1967 | 824 |
825 #ifdef USE_TEXT_PROPERTIES | |
826 if (!NULL_INTERVAL_P (XSTRING (obj)->intervals)) | |
827 { | |
828 traverse_intervals (XSTRING (obj)->intervals, | |
829 0, 0, print_interval, printcharfun); | |
830 PRINTCHAR (')'); | |
831 } | |
832 #endif | |
833 | |
329 | 834 UNGCPRO; |
835 } | |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
836 break; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
837 |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
838 case Lisp_Symbol: |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
839 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
840 register int confusing; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
841 register unsigned char *p = XSYMBOL (obj)->name->data; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
842 register unsigned char *end = p + XSYMBOL (obj)->name->size; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
843 register unsigned char c; |
329 | 844 |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
845 if (p != end && (*p == '-' || *p == '+')) p++; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
846 if (p == end) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
847 confusing = 0; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
848 else |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
849 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
850 while (p != end && *p >= '0' && *p <= '9') |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
851 p++; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
852 confusing = (end == p); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
853 } |
329 | 854 |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
855 p = XSYMBOL (obj)->name->data; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
856 while (p != end) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
857 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
858 QUIT; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
859 c = *p++; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
860 if (escapeflag) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
861 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
862 if (c == '\"' || c == '\\' || c == '\'' || c == ';' || c == '#' || |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
863 c == '(' || c == ')' || c == ',' || c =='.' || c == '`' || |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
864 c == '[' || c == ']' || c == '?' || c <= 040 || confusing) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
865 PRINTCHAR ('\\'), confusing = 0; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
866 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
867 PRINTCHAR (c); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
868 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
869 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
870 break; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
871 |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
872 case Lisp_Cons: |
329 | 873 /* If deeper than spec'd depth, print placeholder. */ |
9117
f69e6cf74874
(PRINTPREPARE, PRINTFINISH, float_to_string, print): Use type test macros.
Karl Heuer <kwzh@gnu.org>
parents:
8854
diff
changeset
|
874 if (INTEGERP (Vprint_level) |
329 | 875 && print_depth > XINT (Vprint_level)) |
10001 | 876 strout ("...", -1, printcharfun); |
877 else | |
329 | 878 { |
10001 | 879 PRINTCHAR ('('); |
329 | 880 { |
10001 | 881 register int i = 0; |
882 register int max = 0; | |
883 | |
884 if (INTEGERP (Vprint_length)) | |
885 max = XINT (Vprint_length); | |
886 /* Could recognize circularities in cdrs here, | |
887 but that would make printing of long lists quadratic. | |
888 It's not worth doing. */ | |
889 while (CONSP (obj)) | |
329 | 890 { |
10001 | 891 if (i++) |
892 PRINTCHAR (' '); | |
893 if (max && i > max) | |
894 { | |
895 strout ("...", 3, printcharfun); | |
896 break; | |
897 } | |
898 print (Fcar (obj), printcharfun, escapeflag); | |
899 obj = Fcdr (obj); | |
329 | 900 } |
901 } | |
10001 | 902 if (!NILP (obj) && !CONSP (obj)) |
903 { | |
904 strout (" . ", 3, printcharfun); | |
905 print (obj, printcharfun, escapeflag); | |
906 } | |
907 PRINTCHAR (')'); | |
329 | 908 } |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
909 break; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
910 |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
911 case Lisp_Vectorlike: |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
912 if (PROCESSP (obj)) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
913 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
914 if (escapeflag) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
915 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
916 strout ("#<process ", -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
917 print_string (XPROCESS (obj)->name, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
918 PRINTCHAR ('>'); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
919 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
920 else |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
921 print_string (XPROCESS (obj)->name, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
922 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
923 else if (SUBRP (obj)) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
924 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
925 strout ("#<subr ", -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
926 strout (XSUBR (obj)->symbol_name, -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
927 PRINTCHAR ('>'); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
928 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
929 #ifndef standalone |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
930 else if (WINDOWP (obj)) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
931 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
932 strout ("#<window ", -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
933 sprintf (buf, "%d", XFASTINT (XWINDOW (obj)->sequence_number)); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
934 strout (buf, -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
935 if (!NILP (XWINDOW (obj)->buffer)) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
936 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
937 strout (" on ", -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
938 print_string (XBUFFER (XWINDOW (obj)->buffer)->name, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
939 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
940 PRINTCHAR ('>'); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
941 } |
10301
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
942 else if (BUFFERP (obj)) |
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
943 { |
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
944 if (NILP (XBUFFER (obj)->name)) |
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
945 strout ("#<killed buffer>", -1, printcharfun); |
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
946 else if (escapeflag) |
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
947 { |
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
948 strout ("#<buffer ", -1, printcharfun); |
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
949 print_string (XBUFFER (obj)->name, printcharfun); |
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
950 PRINTCHAR ('>'); |
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
951 } |
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
952 else |
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
953 print_string (XBUFFER (obj)->name, printcharfun); |
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
954 } |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
955 else if (WINDOW_CONFIGURATIONP (obj)) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
956 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
957 strout ("#<window-configuration>", -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
958 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
959 #ifdef MULTI_FRAME |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
960 else if (FRAMEP (obj)) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
961 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
962 strout ((FRAME_LIVE_P (XFRAME (obj)) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
963 ? "#<frame " : "#<dead frame "), |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
964 -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
965 print_string (XFRAME (obj)->name, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
966 sprintf (buf, " 0x%lx", (unsigned long) (XFRAME (obj))); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
967 strout (buf, -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
968 PRINTCHAR ('>'); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
969 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
970 #endif |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
971 #endif /* not standalone */ |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
972 else |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
973 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
974 int size = XVECTOR (obj)->size; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
975 if (COMPILEDP (obj)) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
976 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
977 PRINTCHAR ('#'); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
978 size &= PSEUDOVECTOR_SIZE_MASK; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
979 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
980 |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
981 PRINTCHAR ('['); |
329 | 982 { |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
983 register int i; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
984 register Lisp_Object tem; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
985 for (i = 0; i < size; i++) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
986 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
987 if (i) PRINTCHAR (' '); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
988 tem = XVECTOR (obj)->contents[i]; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
989 print (tem, printcharfun, escapeflag); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
990 } |
329 | 991 } |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
992 PRINTCHAR (']'); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
993 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
994 break; |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
995 |
329 | 996 #ifndef standalone |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
997 case Lisp_Misc: |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
998 if (MARKERP (obj)) |
329 | 999 { |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1000 strout ("#<marker ", -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1001 if (!(XMARKER (obj)->buffer)) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1002 strout ("in no buffer", -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1003 else |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1004 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1005 sprintf (buf, "at %d", marker_position (obj)); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1006 strout (buf, -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1007 strout (" in ", -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1008 print_string (XMARKER (obj)->buffer->name, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1009 } |
329 | 1010 PRINTCHAR ('>'); |
10301
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
1011 break; |
329 | 1012 } |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1013 else if (OVERLAYP (obj)) |
329 | 1014 { |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1015 strout ("#<overlay ", -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1016 if (!(XMARKER (OVERLAY_START (obj))->buffer)) |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1017 strout ("in no buffer", -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1018 else |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1019 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1020 sprintf (buf, "from %d to %d in ", |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1021 marker_position (OVERLAY_START (obj)), |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1022 marker_position (OVERLAY_END (obj))); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1023 strout (buf, -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1024 print_string (XMARKER (OVERLAY_START (obj))->buffer->name, |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1025 printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1026 } |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1027 PRINTCHAR ('>'); |
10301
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
1028 break; |
329 | 1029 } |
10301
aa73a5c0d1f2
(print): Don't drop thru to error for markers and overlays.
Richard M. Stallman <rms@gnu.org>
parents:
10293
diff
changeset
|
1030 /* Other cases fall through to get an error. */ |
329 | 1031 #endif /* standalone */ |
10293
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1032 |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1033 default: |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1034 { |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1035 /* We're in trouble if this happens! |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1036 Probably should just abort () */ |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1037 strout ("#<EMACS BUG: INVALID DATATYPE ", -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1038 sprintf (buf, "(#o%3o)", (int) XTYPE (obj)); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1039 strout (buf, -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1040 strout (" Save your buffers immediately and please report this bug>", |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1041 -1, printcharfun); |
96cc5c0a7ada
(print): Get size of compiled function as pseudovector.
Richard M. Stallman <rms@gnu.org>
parents:
10001
diff
changeset
|
1042 } |
329 | 1043 } |
1044 | |
1045 print_depth--; | |
1046 } | |
1047 | |
1967 | 1048 #ifdef USE_TEXT_PROPERTIES |
1049 | |
1050 /* Print a description of INTERVAL using PRINTCHARFUN. | |
1051 This is part of printing a string that has text properties. */ | |
1052 | |
1053 void | |
1054 print_interval (interval, printcharfun) | |
1055 INTERVAL interval; | |
1056 Lisp_Object printcharfun; | |
1057 { | |
4003
49918d6c6dda
* print.c: Get rid of extra space at the end of print syntax for
Jim Blandy <jimb@redhat.com>
parents:
3591
diff
changeset
|
1058 PRINTCHAR (' '); |
1967 | 1059 print (make_number (interval->position), printcharfun, 1); |
1060 PRINTCHAR (' '); | |
1061 print (make_number (interval->position + LENGTH (interval)), | |
1062 printcharfun, 1); | |
1063 PRINTCHAR (' '); | |
1064 print (interval->plist, printcharfun, 1); | |
1065 } | |
1066 | |
1067 #endif /* USE_TEXT_PROPERTIES */ | |
1068 | |
329 | 1069 void |
1070 syms_of_print () | |
1071 { | |
1072 staticpro (&Qprint_escape_newlines); | |
1073 Qprint_escape_newlines = intern ("print-escape-newlines"); | |
1074 | |
1075 DEFVAR_LISP ("standard-output", &Vstandard_output, | |
1076 "Output stream `print' uses by default for outputting a character.\n\ | |
1077 This may be any function of one argument.\n\ | |
1078 It may also be a buffer (output is inserted before point)\n\ | |
1079 or a marker (output is inserted and the marker is advanced)\n\ | |
1080 or the symbol t (output appears in the minibuffer line)."); | |
1081 Vstandard_output = Qt; | |
1082 Qstandard_output = intern ("standard-output"); | |
1083 staticpro (&Qstandard_output); | |
1084 | |
1085 #ifdef LISP_FLOAT_TYPE | |
1086 DEFVAR_LISP ("float-output-format", &Vfloat_output_format, | |
687
e2b747dd6a6e
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
686
diff
changeset
|
1087 "The format descriptor string used to print floats.\n\ |
329 | 1088 This is a %-spec like those accepted by `printf' in C,\n\ |
1089 but with some restrictions. It must start with the two characters `%.'.\n\ | |
1090 After that comes an integer precision specification,\n\ | |
1091 and then a letter which controls the format.\n\ | |
1092 The letters allowed are `e', `f' and `g'.\n\ | |
1093 Use `e' for exponential notation \"DIG.DIGITSeEXPT\"\n\ | |
1094 Use `f' for decimal point notation \"DIGITS.DIGITS\".\n\ | |
1095 Use `g' to choose the shorter of those two formats for the number at hand.\n\ | |
1096 The precision in any of these cases is the number of digits following\n\ | |
1097 the decimal point. With `f', a precision of 0 means to omit the\n\ | |
4140
2738089e8383
* print.c (float_to_string): Distinguish between a precision of
Jim Blandy <jimb@redhat.com>
parents:
4003
diff
changeset
|
1098 decimal point. 0 is not allowed with `e' or `g'.\n\n\ |
4224
6cb1cfba6500
(float_to_string): Don't use uninitialized pointer `cp'.
Richard M. Stallman <rms@gnu.org>
parents:
4140
diff
changeset
|
1099 A value of nil means to use `%.17g'."); |
329 | 1100 Vfloat_output_format = Qnil; |
1101 Qfloat_output_format = intern ("float-output-format"); | |
1102 staticpro (&Qfloat_output_format); | |
1103 #endif /* LISP_FLOAT_TYPE */ | |
1104 | |
1105 DEFVAR_LISP ("print-length", &Vprint_length, | |
686
bd3068742807
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
621
diff
changeset
|
1106 "Maximum length of list to print before abbreviating.\n\ |
329 | 1107 A value of nil means no limit."); |
1108 Vprint_length = Qnil; | |
1109 | |
1110 DEFVAR_LISP ("print-level", &Vprint_level, | |
686
bd3068742807
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
621
diff
changeset
|
1111 "Maximum depth of list nesting to print before abbreviating.\n\ |
329 | 1112 A value of nil means no limit."); |
1113 Vprint_level = Qnil; | |
1114 | |
1115 DEFVAR_BOOL ("print-escape-newlines", &print_escape_newlines, | |
6802
7d69da13c140
(syms_of_print): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
6533
diff
changeset
|
1116 "Non-nil means print newlines in strings as backslash-n.\n\ |
5852
f2e341b1f908
(print): If print_escapes_newlines, print '\f' as "\\f".
Roland McGrath <roland@gnu.org>
parents:
5487
diff
changeset
|
1117 Also print formfeeds as backslash-f."); |
329 | 1118 print_escape_newlines = 0; |
1119 | |
1120 /* prin1_to_string_buffer initialized in init_buffer_once in buffer.c */ | |
1121 staticpro (&Vprin1_to_string_buffer); | |
1122 | |
1123 defsubr (&Sprin1); | |
1124 defsubr (&Sprin1_to_string); | |
1125 defsubr (&Sprinc); | |
1126 defsubr (&Sprint); | |
1127 defsubr (&Sterpri); | |
1128 defsubr (&Swrite_char); | |
1129 defsubr (&Sexternal_debugging_output); | |
1130 | |
1131 Qexternal_debugging_output = intern ("external-debugging-output"); | |
1132 staticpro (&Qexternal_debugging_output); | |
1133 | |
1134 #ifndef standalone | |
1135 defsubr (&Swith_output_to_temp_buffer); | |
1136 #endif /* not standalone */ | |
1137 } |