*** empty log message ***
[bpt/emacs.git] / src / lisp.h
CommitLineData
3cfe6dfd 1/* Fundamental definitions for GNU Emacs Lisp interpreter.
4746118a 2 Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
3cfe6dfd
JB
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
4746118a 8the Free Software Foundation; either version 2, or (at your option)
3cfe6dfd
JB
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21/* Define the fundamental Lisp data structures */
22
23/* This is the set of Lisp data types */
24
25enum Lisp_Type
26 {
27 /* Integer. XINT(obj) is the integer value. */
28 Lisp_Int,
29
30 /* Symbol. XSYMBOL (object) points to a struct Lisp_Symbol. */
31 Lisp_Symbol,
32
33 /* Marker (buffer ptr). XMARKER(object) points to a struct Lisp_Marker. */
34 Lisp_Marker,
35
36 /* String. XSTRING (object) points to a struct Lisp_String.
37 The length of the string, and its contents, are stored therein. */
38 Lisp_String,
39
40 /* Vector of Lisp objects. XVECTOR(object) points to a struct Lisp_Vector.
41 The length of the vector, and its contents, are stored therein. */
42 Lisp_Vector,
43
44 /* Cons. XCONS (object) points to a struct Lisp_Cons. */
45 Lisp_Cons,
46
47 /* Byte-compiled function. A vector of 4 to 6 elements which are the
48 arglist, bytecode-string, constant vector, stack size,
49 (optional) doc string, and (optional) interactive spec. */
50 Lisp_Compiled,
51
52 /* Editor buffer. XBUFFER(obj) points to a struct buffer. */
53 Lisp_Buffer,
54
55 /* Built-in function. XSUBR(obj) points to a struct Lisp_Subr
56 which describes how to call the function, and its documentation,
57 as well as pointing to the code. */
58 Lisp_Subr,
59
60 /* Internal value return by subroutines of read.
61 The user never sees this data type.
62 Its value is just a number. */
63 Lisp_Internal,
64
65 /* Forwarding pointer to an int variable.
66 This is allowed only in the value cell of a symbol,
67 and it means that the symbol's value really lives in the
68 specified int variable.
69 XINTPTR(obj) points to the int variable. */
70 Lisp_Intfwd,
71
72 /* Boolean forwarding pointer to an int variable.
73 This is like Lisp_Intfwd except that the ostensible
74 "value" of the symbol is t if the int variable is nonzero,
75 nil if it is zero. XINTPTR(obj) points to the int variable. */
76 Lisp_Boolfwd,
77
78 /* Object describing a connection to a subprocess.
79 It points to storage of type struct Lisp_Process */
80 Lisp_Process,
81
82 /* Forwarding pointer to a Lisp_Object variable.
83 This is allowed only in the value cell of a symbol,
84 and it means that the symbol's value really lives in the
85 specified variable.
86 XOBJFWD(obj) points to the Lisp_Object variable. */
87 Lisp_Objfwd,
88
89 /* Pointer to a vector-like object describing a display screen
90 on which Emacs can display a window hierarchy. */
91 Lisp_Screen,
92
93 /* Used when a FILE * value needs to be passed
94 in an argument of type Lisp_Object.
95 You must do *(FILE **) XPNTR(obj) to get the value.
96 The user will never see this data type. */
97 Lisp_Internal_Stream,
98
99 /* Used in a symbol value cell when the symbol's value is per-buffer.
100 The actual contents are a cons cell which starts a list like this:
101 (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE)).
102
103 BUFFER is the last buffer for which this symbol's value was
104 made up to date.
105
106 CURRENT-ALIST-ELEMENT is a pointer to an element of BUFFER's
107 b_local_var_alist, that being the element whose car is this variable.
108 Or it can be a pointer to the (CURRENT-ALIST-ELEMENT . DEFAULT-VALUE), if BUFFER
109 does not have an element in its alist for this variable
110 (that is, if BUFFER sees the default value of this variable).
111
112 If we want to examine or set the value and BUFFER is current,
113 we just examine or set REALVALUE.
114 If BUFFER is not current, we store the current REALVALUE value into
115 CURRENT-ALIST-ELEMENT, then find the appropriate alist element for
116 the buffer now current and set up CURRENT-ALIST-ELEMENT.
117 Then we set REALVALUE out of that element, and store into BUFFER.
118
119 If we are setting the variable and the current buffer does not have
120 an alist entry for this variable, an alist entry is created.
121
122 Note that REALVALUE can be a forwarding pointer.
123 Each time it is examined or set, forwarding must be done. */
124 Lisp_Buffer_Local_Value,
125
126 /* Like Lisp_Buffer_Local_Value with one difference:
127 merely setting the variable while some buffer is current
128 does not cause that buffer to have its own local value of this variable.
129 Only make-local-variable does that. */
130 Lisp_Some_Buffer_Local_Value,
131
132
133 /* Like Lisp_Objfwd except that value lives in a slot
134 in the current buffer. Value is byte index of slot within buffer */
135 Lisp_Buffer_Objfwd,
136
137 /* In symbol value cell, means var is unbound.
138 In symbol function cell, means function name is undefined. */
139 Lisp_Void,
140
141 /* Window used for Emacs display.
142 Data inside looks like a Lisp_Vector. */
143 Lisp_Window,
144
145 /* Used by save,set,restore-window-configuration */
146 Lisp_Window_Configuration
147
148#ifdef LISP_FLOAT_TYPE
149 ,
150 Lisp_Float
151#endif /* LISP_FLOAT_TYPE */
152 };
153
154#ifndef NO_UNION_TYPE
155
156#ifndef BIG_ENDIAN
157
158/* Definition of Lisp_Object for little-endian machines. */
159
160typedef
161union Lisp_Object
162 {
163 /* Used for comparing two Lisp_Objects;
164 also, positive integers can be accessed fast this way. */
165 int i;
166
167 struct
168 {
169 int val: 24;
170 char type;
171 } s;
172 struct
173 {
174 unsigned int val: 24;
175 char type;
176 } u;
177 struct
178 {
179 unsigned int val: 24;
180 enum Lisp_Type type: 7;
181 /* The markbit is not really part of the value of a Lisp_Object,
182 and is always zero except during garbage collection. */
183 unsigned int markbit: 1;
184 } gu;
185 }
186Lisp_Object;
187
188#else /* If BIG_ENDIAN */
189
190typedef
191union Lisp_Object
192 {
193 /* Used for comparing two Lisp_Objects;
194 also, positive integers can be accessed fast this way. */
195 int i;
196
197 struct
198 {
199 char type;
200 int val: 24;
201 } s;
202 struct
203 {
204 char type;
205 unsigned int val: 24;
206 } u;
207 struct
208 {
209 /* The markbit is not really part of the value of a Lisp_Object,
210 and is always zero except during garbage collection. */
211 unsigned int markbit: 1;
212 enum Lisp_Type type: 7;
213 unsigned int val: 24;
214 } gu;
215 }
216Lisp_Object;
217
218#endif /* BIG_ENDIAN */
219
220#endif /* NO_UNION_TYPE */
221
222
223/* If union type is not wanted, define Lisp_Object as just a number
224 and define the macros below to extract fields by shifting */
225
226#ifdef NO_UNION_TYPE
227
228#define Lisp_Object int
229
230/* These values are overridden by the m- file on some machines. */
231#ifndef VALBITS
232#define VALBITS 24
233#endif
234
235#ifndef GCTYPEBITS
236#define GCTYPEBITS 7
237#endif
238
239#ifndef VALMASK
240#define VALMASK ((1<<VALBITS) - 1)
241#endif
242#define GCTYPEMASK ((1<<GCTYPEBITS) - 1)
243#define MARKBIT (1 << (VALBITS + GCTYPEBITS))
244
245#endif /* NO_UNION_TYPE */
246\f
247/* These macros extract various sorts of values from a Lisp_Object.
248 For example, if tem is a Lisp_Object whose type is Lisp_Cons,
249 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */
250
251#ifdef NO_UNION_TYPE
252
253/* One need to override this if there must be high bits set in data space
254 (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work
255 on all machines, but would penalise machines which don't need it)
256 */
257#ifndef XTYPE
258#define XTYPE(a) ((enum Lisp_Type) ((a) >> VALBITS))
259#endif
260
261#ifndef XSETTYPE
262#define XSETTYPE(a, b) ((a) = XUINT (a) | ((int)(b) << VALBITS))
263#endif
264
265/* Use XFASTINT for fast retrieval and storage of integers known
266 to be positive. This takes advantage of the fact that Lisp_Int is 0. */
267#define XFASTINT(a) (a)
268
269/* Extract the value of a Lisp_Object as a signed integer. */
270
271#ifndef XINT /* Some machines need to do this differently. */
e065a56e 272#define XINT(a) (((a) << (INTBITS-VALBITS)) >> (INTBITS-VALBITS))
3cfe6dfd
JB
273#endif
274
275/* Extract the value as an unsigned integer. This is a basis
276 for extracting it as a pointer to a structure in storage. */
277
278#ifndef XUINT
279#define XUINT(a) ((a) & VALMASK)
280#endif
281
282#ifndef XPNTR
283#ifdef HAVE_SHM
284/* In this representation, data is found in two widely separated segments. */
29eab336 285extern int pure_size;
3cfe6dfd 286#define XPNTR(a) \
29eab336 287 (XUINT (a) | (XUINT (a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS))
3cfe6dfd
JB
288#else /* not HAVE_SHM */
289#ifdef DATA_SEG_BITS
290/* This case is used for the rt-pc.
291 In the diffs I was given, it checked for ptr = 0
292 and did not adjust it in that case.
293 But I don't think that zero should ever be found
294 in a Lisp object whose data type says it points to something. */
295#define XPNTR(a) (XUINT (a) | DATA_SEG_BITS)
296#else
297#define XPNTR(a) XUINT (a)
298#endif
299#endif /* not HAVE_SHM */
300#endif /* no XPNTR */
301
302#ifndef XSETINT
303#define XSETINT(a, b) ((a) = ((a) & ~VALMASK) | ((b) & VALMASK))
304#endif
305
306#ifndef XSETUINT
307#define XSETUINT(a, b) XSETINT (a, b)
308#endif
309
310#ifndef XSETPNTR
311#define XSETPNTR(a, b) XSETINT (a, b)
312#endif
313
314#ifndef XSET
315#define XSET(var, type, ptr) \
316 ((var) = ((int)(type) << VALBITS) + ((int) (ptr) & VALMASK))
317#endif
318
319/* During garbage collection, XGCTYPE must be used for extracting types
320 so that the mark bit is ignored. XMARKBIT accesses the markbit.
321 Markbits are used only in particular slots of particular structure types.
322 Other markbits are always zero.
323 Outside of garbage collection, all mark bits are always zero. */
324
325#ifndef XGCTYPE
326#define XGCTYPE(a) ((enum Lisp_Type) (((a) >> VALBITS) & GCTYPEMASK))
327#endif
328
329#if VALBITS + GCTYPEBITS == INTBITS - 1
330/* Make XMARKBIT faster if mark bit is sign bit. */
331#ifndef XMARKBIT
332#define XMARKBIT(a) ((a) < 0)
333#endif
334#endif /* markbit is sign bit */
335
336#ifndef XMARKBIT
337#define XMARKBIT(a) ((a) & MARKBIT)
338#endif
339
340#ifndef XSETMARKBIT
341#define XSETMARKBIT(a,b) ((a) = ((a) & ~MARKBIT) | ((b) ? MARKBIT : 0))
342#endif
343
344#ifndef XMARK
345#define XMARK(a) ((a) |= MARKBIT)
346#endif
347
348#ifndef XUNMARK
349#define XUNMARK(a) ((a) &= ~MARKBIT)
350#endif
351
352#endif /* NO_UNION_TYPE */
353
354#ifndef NO_UNION_TYPE
355
356#define XTYPE(a) ((enum Lisp_Type) (a).u.type)
357#define XSETTYPE(a, b) ((a).u.type = (char) (b))
358
359/* Use XFASTINT for fast retrieval and storage of integers known
360 to be positive. This takes advantage of the fact that Lisp_Int is 0. */
361#define XFASTINT(a) ((a).i)
362
363#ifdef EXPLICIT_SIGN_EXTEND
364/* Make sure we sign-extend; compilers have been known to fail to do so. */
365#define XINT(a) (((a).i << 8) >> 8)
366#else
367#define XINT(a) ((a).s.val)
368#endif /* EXPLICIT_SIGN_EXTEND */
369
370#define XUINT(a) ((a).u.val)
371#define XPNTR(a) ((a).u.val)
372#define XSETINT(a, b) ((a).s.val = (int) (b))
373#define XSETUINT(a, b) ((a).s.val = (int) (b))
374#define XSETPNTR(a, b) ((a).s.val = (int) (b))
375
376#define XSET(var, vartype, ptr) \
377 (((var).s.type = ((char) (vartype))), ((var).s.val = ((int) (ptr))))
378
379/* During garbage collection, XGCTYPE must be used for extracting types
380 so that the mark bit is ignored. XMARKBIT access the markbit.
381 Markbits are used only in particular slots of particular structure types.
382 Other markbits are always zero.
383 Outside of garbage collection, all mark bits are always zero. */
384
385#define XGCTYPE(a) ((a).gu.type)
386#define XMARKBIT(a) ((a).gu.markbit)
387#define XSETMARKBIT(a,b) (XMARKBIT(a) = (b))
388#define XMARK(a) (XMARKBIT(a) = 1)
389#define XUNMARK(a) (XMARKBIT(a) = 0)
390
391#endif /* NO_UNION_TYPE */
392
393
394#define XCONS(a) ((struct Lisp_Cons *) XPNTR(a))
395#define XBUFFER(a) ((struct buffer *) XPNTR(a))
396#define XVECTOR(a) ((struct Lisp_Vector *) XPNTR(a))
397#define XSUBR(a) ((struct Lisp_Subr *) XPNTR(a))
398#define XSTRING(a) ((struct Lisp_String *) XPNTR(a))
399#define XSYMBOL(a) ((struct Lisp_Symbol *) XPNTR(a))
400#define XFUNCTION(a) ((Lisp_Object (*)()) XPNTR(a))
401#define XMARKER(a) ((struct Lisp_Marker *) XPNTR(a))
402#define XOBJFWD(a) ((Lisp_Object *) XPNTR(a))
403#define XINTPTR(a) ((int *) XPNTR(a))
404#define XWINDOW(a) ((struct window *) XPNTR(a))
405#define XPROCESS(a) ((struct Lisp_Process *) XPNTR(a))
406#define XFLOAT(a) ((struct Lisp_Float *) XPNTR(a))
407
408#define XSETCONS(a, b) XSETPNTR(a, (int) (b))
409#define XSETBUFFER(a, b) XSETPNTR(a, (int) (b))
410#define XSETVECTOR(a, b) XSETPNTR(a, (int) (b))
411#define XSETSUBR(a, b) XSETPNTR(a, (int) (b))
412#define XSETSTRING(a, b) XSETPNTR(a, (int) (b))
413#define XSETSYMBOL(a, b) XSETPNTR(a, (int) (b))
414#define XSETFUNCTION(a, b) XSETPNTR(a, (int) (b))
415#define XSETMARKER(a, b) XSETPNTR(a, (int) (b))
416#define XSETOBJFWD(a, b) XSETPNTR(a, (int) (b))
417#define XSETINTPTR(a, b) XSETPNTR(a, (int) (b))
418#define XSETWINDOW(a, b) XSETPNTR(a, (int) (b))
419#define XSETPROCESS(a, b) XSETPNTR(a, (int) (b))
420#define XSETFLOAT(a, b) XSETPNTR(a, (int) (b))
421\f
422/* In a cons, the markbit of the car is the gc mark bit */
423
424struct Lisp_Cons
425 {
426 Lisp_Object car, cdr;
427 };
428
429/* Like a cons, but records info on where the text lives that it was read from */
430/* This is not really in use now */
431
432struct Lisp_Buffer_Cons
433 {
434 Lisp_Object car, cdr;
435 struct buffer *buffer;
436 int bufpos;
437 };
438
439/* In a string or vector, the sign bit of the `size' is the gc mark bit */
440
441struct Lisp_String
442 {
443 int size;
444 unsigned char data[1];
445 };
446
447struct Lisp_Vector
448 {
449 int size;
450 struct Lisp_Vector *next;
451 Lisp_Object contents[1];
452 };
453
454/* In a symbol, the markbit of the plist is used as the gc mark bit */
455
456struct Lisp_Symbol
457 {
458 struct Lisp_String *name;
459 Lisp_Object value;
460 Lisp_Object function;
461 Lisp_Object plist;
462 struct Lisp_Symbol *next; /* -> next symbol in this obarray bucket */
463 };
464
465struct Lisp_Subr
466 {
467 Lisp_Object (*function) ();
468 short min_args, max_args;
469 char *symbol_name;
470 char *prompt;
471 char *doc;
472 };
473
474/* In a marker, the markbit of the chain field is used as the gc mark bit */
475
476struct Lisp_Marker
477 {
478 struct buffer *buffer;
479 Lisp_Object chain;
480 int bufpos;
481 int modified;
482 };
483
484#ifdef LISP_FLOAT_TYPE
485/* Optional Lisp floating point type */
486struct Lisp_Float
487 {
488 Lisp_Object type; /* essentially used for mark-bit
489 and chaining when on free-list */
490 double data;
491 };
492#endif /* LISP_FLOAT_TYPE */
493
494/* A character, declared with the following typedef, is a member
495 of some character set associated with the current buffer. */
496typedef unsigned char UCHAR;
497
498/* Meanings of slots in a Lisp_Compiled: */
499
500#define COMPILED_ARGLIST 0
501#define COMPILED_BYTECODE 1
502#define COMPILED_CONSTANTS 2
503#define COMPILED_STACK_DEPTH 3
504#define COMPILED_DOC_STRING 4
505#define COMPILED_INTERACTIVE 5
506\f
507/* Data type checking */
508
efb859b4 509#define NILP(x) (XFASTINT (x) == XFASTINT (Qnil))
3cfe6dfd 510
4746118a
JB
511#ifdef LISP_FLOAT_TYPE
512#define NUMBERP(x) (XTYPE (x) == Lisp_Int || XTYPE (x) == Lisp_Float)
513#else
514#define NUMBERP(x) (XTYPE (x) == Lisp_Int)
515#endif
516
3cfe6dfd
JB
517/* #define LISTP(x) (XTYPE ((x)) == Lisp_Cons)*/
518#define CONSP(x) (XTYPE ((x)) == Lisp_Cons)
519#define EQ(x, y) (XFASTINT (x) == XFASTINT (y))
520
4746118a 521
3cfe6dfd 522#define CHECK_LIST(x, i) \
efb859b4 523 { if ((XTYPE ((x)) != Lisp_Cons) && !NILP (x)) x = wrong_type_argument (Qlistp, (x)); }
3cfe6dfd
JB
524
525#define CHECK_STRING(x, i) \
526 { if (XTYPE ((x)) != Lisp_String) x = wrong_type_argument (Qstringp, (x)); }
527
528#define CHECK_CONS(x, i) \
529 { if (XTYPE ((x)) != Lisp_Cons) x = wrong_type_argument (Qconsp, (x)); }
530
531#define CHECK_SYMBOL(x, i) \
532 { if (XTYPE ((x)) != Lisp_Symbol) x = wrong_type_argument (Qsymbolp, (x)); }
533
534#define CHECK_VECTOR(x, i) \
535 { if (XTYPE ((x)) != Lisp_Vector) x = wrong_type_argument (Qvectorp, (x)); }
536
537#define CHECK_BUFFER(x, i) \
538 { if (XTYPE ((x)) != Lisp_Buffer) x = wrong_type_argument (Qbufferp, (x)); }
539
540#define CHECK_WINDOW(x, i) \
541 { if (XTYPE ((x)) != Lisp_Window) x = wrong_type_argument (Qwindowp, (x)); }
542
543#define CHECK_PROCESS(x, i) \
544 { if (XTYPE ((x)) != Lisp_Process) x = wrong_type_argument (Qprocessp, (x)); }
545
546#define CHECK_NUMBER(x, i) \
547 { if (XTYPE ((x)) != Lisp_Int) x = wrong_type_argument (Qintegerp, (x)); }
548
549#define CHECK_NATNUM(x, i) \
550 { if (XTYPE ((x)) != Lisp_Int || XINT ((x)) < 0) \
551 x = wrong_type_argument (Qnatnump, (x)); }
552
553#define CHECK_MARKER(x, i) \
554 { if (XTYPE ((x)) != Lisp_Marker) x = wrong_type_argument (Qmarkerp, (x)); }
555
556#define CHECK_NUMBER_COERCE_MARKER(x, i) \
557 { if (XTYPE ((x)) == Lisp_Marker) XFASTINT (x) = marker_position (x); \
558 else if (XTYPE ((x)) != Lisp_Int) x = wrong_type_argument (Qinteger_or_marker_p, (x)); }
559
560#ifdef LISP_FLOAT_TYPE
561
562#ifndef DBL_DIG
563#define DBL_DIG 20
564#endif
565
566#define XFLOATINT(n) extract_float((n))
567
568#define CHECK_FLOAT(x, i) \
569{ if (XTYPE (x) != Lisp_Float) \
570 x = wrong_type_argument (Qfloatp, (x)); }
571
572#define CHECK_NUMBER_OR_FLOAT(x, i) \
573{ if (XTYPE (x) != Lisp_Float && XTYPE (x) != Lisp_Int) \
574 x = wrong_type_argument (Qinteger_or_floatp, (x)); }
575
576#define CHECK_NUMBER_OR_FLOAT_COERCE_MARKER(x, i) \
577{ if (XTYPE (x) == Lisp_Marker) XFASTINT (x) = marker_position (x); \
578 else if (XTYPE (x) != Lisp_Int && XTYPE (x) != Lisp_Float) \
579 x = wrong_type_argument (Qinteger_or_float_or_marker_p, (x)); }
580
581#else /* Not LISP_FLOAT_TYPE */
582
583#define CHECK_NUMBER_OR_FLOAT CHECK_NUMBER
584
585#define CHECK_NUMBER_OR_FLOAT_COERCE_MARKER CHECK_NUMBER_COERCE_MARKER
586
587#define XFLOATINT(n) XINT((n))
588#endif /* LISP_FLOAT_TYPE */
589
3cfe6dfd
JB
590/* Cast pointers to this type to compare them. Some machines want int. */
591#ifndef PNTR_COMPARISON_TYPE
592#define PNTR_COMPARISON_TYPE unsigned int
593#endif
594\f
595/* Define a built-in function for calling from Lisp.
596 `lname' should be the name to give the function in Lisp,
597 as a null-terminated C string.
598 `fnname' should be the name of the function in C.
599 By convention, it starts with F.
600 `sname' should be the name for the C constant structure
601 that records information on this function for internal use.
602 By convention, it should be the same as `fnname' but with S instead of F.
603 It's too bad that C macros can't compute this from `fnname'.
604 `minargs' should be a number, the minimum number of arguments allowed.
605 `maxargs' should be a number, the maximum number of arguments allowed,
606 or else MANY or UNEVALLED.
607 MANY means pass a vector of evaluated arguments,
608 in the form of an integer number-of-arguments
609 followed by the address of a vector of Lisp_Objects
610 which contains the argument values.
611 UNEVALLED means pass the list of unevaluated arguments
612 `prompt' says how to read arguments for an interactive call.
613 This can be zero or a C string.
614 Zero means that interactive calls are not allowed.
615 A string is interpreted in a hairy way:
616 it should contain one line for each argument to be read, terminated by \n.
617 The first character of the line controls the type of parsing:
618 s -- read a string.
619 S -- read a symbol.
620 k -- read a key sequence and return it as a string.
621 a -- read a function name (symbol) with completion.
622 C -- read a command name (symbol) with completion.
623 v -- read a variable name (symbol) with completion.
624 b -- read a buffer name (a string) with completion.
625 B -- buffer name, may be existing buffer or may not be.
626 f -- read a file name, file must exist.
627 F -- read a file name, file need not exist.
628 n -- read a number.
629 c -- read a character and return it as a number.
630 p -- use the numeric value of the prefix argument.
631 P -- use raw value of prefix - can be nil, -, (NUMBER) or NUMBER.
632 x -- read a Lisp object from the minibuffer.
633 X -- read a Lisp form from the minibuffer and use its value.
634 A null string means call interactively with no arguments.
635 `doc' is documentation for the user.
636*/
637
638#define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc) \
639 Lisp_Object fnname (); \
640 struct Lisp_Subr sname = {fnname, minargs, maxargs, lname, prompt, 0}; \
641 Lisp_Object fnname
642
643/* defsubr (Sname);
644 is how we define the symbol for function `name' at start-up time. */
645extern void defsubr ();
646
647#define MANY -2
648#define UNEVALLED -1
649
650extern void defvar_lisp ();
651extern void defvar_bool ();
652extern void defvar_int ();
653
654/* Macros we use to define forwarded Lisp variables.
655 These are used in the syms_of_FILENAME functions. */
656
657#define DEFVARLISP(lname, vname, doc) defvar_lisp (lname, vname)
658#define DEFVARBOOL(lname, vname, doc) defvar_bool (lname, vname)
659#define DEFVARINT(lname, vname, doc) defvar_int (lname, vname)
660#define DEFVARPERBUFFER(lname, vname, doc) \
661 defvar_per_buffer (lname, vname)
662
663#define DEFVAR_LISP(lname, vname, doc) defvar_lisp (lname, vname)
664#define DEFVAR_LISP_NOPRO(lname, vname, doc) defvar_lisp_nopro (lname, vname)
665#define DEFVAR_BOOL(lname, vname, doc) defvar_bool (lname, vname)
666#define DEFVAR_INT(lname, vname, doc) defvar_int (lname, vname)
667#define DEFVAR_PER_BUFFER(lname, vname, doc) \
668 defvar_per_buffer (lname, vname)
669\f
670/* Structure for recording Lisp call stack for backtrace purposes */
671
672struct specbinding
673 {
674 Lisp_Object symbol, old_value;
675 Lisp_Object (*func) ();
676 Lisp_Object unused; /* Dividing by 16 is faster than by 12 */
677 };
678
679extern struct specbinding *specpdl;
680extern struct specbinding *specpdl_ptr;
681extern int specpdl_size;
682
683struct handler
684 {
685 Lisp_Object handler;
686 Lisp_Object var;
687 int poll_suppress_count; /* No error should exit a piece of code
688 in which polling is suppressed. */
689 struct catchtag *tag;
690 struct handler *next;
691 };
692
693extern struct handler *handlerlist;
694
695extern struct catchtag *catchlist;
696extern struct backtrace *backtrace_list;
697
698/* An address near the bottom of the stack.
699 Tells GC how to save a copy of the stack. */
700extern char *stack_bottom;
701
702/* Check quit-flag and quit if it is non-nil. */
703
704#define QUIT \
efb859b4 705 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) \
3cfe6dfd
JB
706 { Vquit_flag = Qnil; Fsignal (Qquit, Qnil); }
707
708/* Nonzero if ought to quit now. */
709
efb859b4 710#define QUITP (!NILP (Vquit_flag) && NILP (Vinhibit_quit))
3cfe6dfd
JB
711\f
712/* 1 if CH is upper case. */
713
7b15897a
JB
714#define UPPERCASEP(CH) \
715 (XSTRING (current_buffer->downcase_table)->data[CH] != (CH))
3cfe6dfd
JB
716
717/* 1 if CH is lower case. */
718
719#define LOWERCASEP(CH) \
7b15897a
JB
720 (!UPPERCASEP (CH) \
721 && XSTRING (current_buffer->upcase_table)->data[CH] != (CH))
3cfe6dfd
JB
722
723/* 1 if CH is neither upper nor lower case. */
724
725#define NOCASEP(CH) (XSTRING (current_buffer->upcase_table)->data[CH] == (CH))
726
727/* Upcase a character, or make no change if that cannot be done. */
728
7b15897a
JB
729#define UPCASE(CH) \
730 (XSTRING (current_buffer->downcase_table)->data[CH] == (CH) \
731 ? UPCASE1 (CH) : (CH))
3cfe6dfd
JB
732
733/* Upcase a character known to be not upper case. */
734
735#define UPCASE1(CH) (XSTRING (current_buffer->upcase_table)->data[CH])
736
737/* Downcase a character, or make no change if that cannot be done. */
738
739#define DOWNCASE(CH) (XSTRING (current_buffer->downcase_table)->data[CH])
740
741/* Current buffer's map from characters to lower-case characters. */
742
743#define DOWNCASE_TABLE XSTRING (current_buffer->downcase_table)->data
744
745/* Table mapping each char to the next char with the same lowercase version.
746 This mapping is a no-op only for characters that don't have case. */
747#define UPCASE_TABLE XSTRING (current_buffer->upcase_table)->data
748
749extern Lisp_Object Vascii_downcase_table, Vascii_upcase_table;
750\f
751/* number of bytes of structure consed since last GC */
752
753extern int consing_since_gc;
754
755/* threshold for doing another gc */
756
757extern int gc_cons_threshold;
758
759/* Structure for recording stack slots that need marking */
760
761/* This is a chain of structures, each of which points at a Lisp_Object variable
762 whose value should be marked in garbage collection.
763 Normally every link of the chain is an automatic variable of a function,
764 and its `val' points to some argument or local variable of the function.
765 On exit to the function, the chain is set back to the value it had on entry.
766 This way, no link remains in the chain when the stack frame containing the link disappears.
767
768 Every function that can call Feval must protect in this fashion all
769 Lisp_Object variables whose contents will be used again. */
770
771extern struct gcpro *gcprolist;
772
773struct gcpro
774 {
775 struct gcpro *next;
776 Lisp_Object *var; /* Address of first protected variable */
777 int nvars; /* Number of consecutive protected variables */
778 };
779
780#define GCPRO1(varname) \
781 {gcpro1.next = gcprolist; gcpro1.var = &varname; gcpro1.nvars = 1; \
782 gcprolist = &gcpro1; }
783
784#define GCPRO2(varname1, varname2) \
785 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
786 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
787 gcprolist = &gcpro2; }
788
789#define GCPRO3(varname1, varname2, varname3) \
790 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
791 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
792 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
793 gcprolist = &gcpro3; }
794
795#define GCPRO4(varname1, varname2, varname3, varname4) \
796 {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
797 gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
798 gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
799 gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
800 gcprolist = &gcpro4; }
801
802/* Call staticpro (&var) to protect static variable `var'. */
803
804void staticpro();
805
806#define UNGCPRO (gcprolist = gcpro1.next)
807
808/* Evaluate expr, UNGCPRO, and then return the value of expr. */
809#define RETURN_UNGCPRO(expr) \
810 do \
811 { \
812 Lisp_Object ret_ungc_val; \
813 ret_ungc_val = (expr); \
814 UNGCPRO; \
815 return ret_ungc_val; \
816 } \
817 while (0)
818\f
819/* Defined in data.c */
820extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound;
821extern Lisp_Object Qerror_conditions, Qerror_message, Qtop_level;
822extern Lisp_Object Qerror, Qquit, Qwrong_type_argument, Qargs_out_of_range;
823extern Lisp_Object Qvoid_variable, Qvoid_function;
824extern Lisp_Object Qsetting_constant, Qinvalid_read_syntax;
825extern Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch;
826extern Lisp_Object Qend_of_file, Qarith_error;
827extern Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only;
828
829extern Lisp_Object Qintegerp, Qnatnump, Qsymbolp, Qlistp, Qconsp;
830extern Lisp_Object Qstringp, Qarrayp, Qsequencep, Qbufferp;
831extern Lisp_Object Qchar_or_string_p, Qmarkerp, Qvectorp;
832extern Lisp_Object Qinteger_or_marker_p, Qboundp, Qfboundp;
833extern Lisp_Object Qcdr;
834
835#ifdef LISP_FLOAT_TYPE
836extern Lisp_Object Qfloatp, Qinteger_or_floatp, Qinteger_or_float_or_marker_p;
837#endif /* LISP_FLOAT_TYPE */
838
839extern Lisp_Object Qscreenp;
840
841extern Lisp_Object Feq (), Fnull (), Flistp (), Fconsp (), Fatom (), Fnlistp ();
842extern Lisp_Object Fintegerp (), Fnatnump (), Fsymbolp ();
843extern Lisp_Object Fvectorp (), Fstringp (), Farrayp (), Fsequencep ();
844extern Lisp_Object Fbufferp (), Fmarkerp (), Fsubrp (), Fchar_or_string_p ();
845extern Lisp_Object Finteger_or_marker_p ();
846#ifdef LISP_FLOAT_TYPE
847extern Lisp_Object Ffloatp(), Finteger_or_floatp();
848extern Lisp_Object Finteger_or_float_or_marker_p(), Ftruncate();
849#endif /* LISP_FLOAT_TYPE */
850
851extern Lisp_Object Fcar (), Fcar_safe(), Fcdr (), Fcdr_safe();
852extern Lisp_Object Fsetcar (), Fsetcdr ();
853extern Lisp_Object Fboundp (), Ffboundp (), Fmakunbound (), Ffmakunbound ();
854extern Lisp_Object Fsymbol_function (), Fsymbol_plist (), Fsymbol_name ();
855extern Lisp_Object Ffset (), Fsetplist ();
760cbdd3 856extern Lisp_Object Fsymbol_value (), find_symbol_value (), Fset ();
3cfe6dfd
JB
857extern Lisp_Object Fdefault_value (), Fset_default ();
858
859extern Lisp_Object Faref (), Faset (), Farray_length ();
860
861extern Lisp_Object Fstring_to_int (), Fint_to_string ();
862extern Lisp_Object Feqlsign (), Fgtr (), Flss (), Fgeq (), Fleq (), Fneq (), Fzerop ();
863extern Lisp_Object Fplus (), Fminus (), Ftimes (), Fquo (), Frem (), Fmax (), Fmin ();
864extern Lisp_Object Flogand (), Flogior (), Flogxor (), Flognot (), Flsh (), Fash ();
865extern Lisp_Object Fadd1 (), Fsub1 ();
866
867extern Lisp_Object make_number ();
868extern void args_out_of_range ();
869extern void args_out_of_range_3 ();
870extern Lisp_Object wrong_type_argument ();
871#ifdef LISP_FLOAT_TYPE
872extern Lisp_Object Ffloat_to_int(), Fint_to_float();
873extern double extract_float();
874#endif /* LISP_FLOAT_TYPE */
875
876/* Defined in fns.c */
877extern Lisp_Object Qstring_lessp;
878extern Lisp_Object Vfeatures;
879extern Lisp_Object Fidentity (), Frandom ();
880extern Lisp_Object Flength ();
881extern Lisp_Object Fappend (), Fconcat (), Fvconcat (), Fcopy_sequence ();
882extern Lisp_Object Fsubstring ();
883extern Lisp_Object Fnthcdr (), Fmemq (), Fassq (), Fassoc ();
884extern Lisp_Object Frassq (), Fdelq (), Fsort ();
885extern Lisp_Object Freverse (), Fnreverse (), Fget (), Fput (), Fequal ();
886extern Lisp_Object Ffillarray (), Fnconc (), Fmapcar (), Fmapconcat ();
887extern Lisp_Object Fy_or_n_p (), do_yes_or_no_p ();
888extern Lisp_Object Ffeaturep (), Frequire () , Fprovide ();
889extern Lisp_Object concat2 (), nconc2 ();
890extern Lisp_Object assq_no_quit ();
891
892/* Defined in alloc.c */
893extern Lisp_Object Vpurify_flag;
894extern Lisp_Object Fcons (), Flist(), Fmake_list ();
895extern Lisp_Object Fmake_vector (), Fvector (), Fmake_symbol (), Fmake_marker ();
896extern Lisp_Object Fmake_string (), build_string (), make_string ();
9453ea7b 897extern Lisp_Object make_array (), make_uninit_string ();
3cfe6dfd
JB
898extern Lisp_Object Fpurecopy (), make_pure_string ();
899extern Lisp_Object pure_cons (), make_pure_vector ();
900extern Lisp_Object Fgarbage_collect ();
901
902/* Defined in print.c */
903extern Lisp_Object Vprin1_to_string_buffer;
904extern Lisp_Object Fprin1 (), Fprin1_to_string (), Fprinc ();
905extern Lisp_Object Fterpri (), Fprint ();
906extern Lisp_Object Vstandard_output, Qstandard_output;
9453ea7b 907extern Lisp_Object Qexternal_debugging_output;
3cfe6dfd
JB
908extern void temp_output_buffer_setup (), temp_output_buffer_show ();
909extern int print_level, print_escape_newlines;
910extern Lisp_Object Qprint_escape_newlines;
911
912/* Defined in lread.c */
913extern Lisp_Object Qvariable_documentation, Qstandard_input;
914extern Lisp_Object Vobarray, Vstandard_input;
915extern Lisp_Object Fread (), Fread_from_string ();
916extern Lisp_Object Fintern (), Fintern_soft (), Fload ();
917extern Lisp_Object Fget_file_char (), Fread_char ();
918extern Lisp_Object Feval_current_buffer (), Feval_region ();
919extern Lisp_Object intern (), oblookup ();
920
921/* Defined in eval.c */
922extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qdefun, Qmacro;
ad236261 923extern Lisp_Object Vinhibit_quit, Qinhibit_quit, Vquit_flag;
3cfe6dfd
JB
924extern Lisp_Object Vmocklisp_arguments, Qmocklisp, Qmocklisp_arguments;
925extern Lisp_Object Vautoload_queue;
926extern Lisp_Object Vrun_hooks;
927extern Lisp_Object Fand (), For (), Fif (), Fprogn (), Fprog1 (), Fprog2 ();
928extern Lisp_Object Fsetq (), Fquote ();
929extern Lisp_Object Fuser_variable_p (), Finteractive_p ();
930extern Lisp_Object Fdefun (), Flet (), FletX (), Fwhile ();
931extern Lisp_Object Fcatch (), Fthrow (), Funwind_protect ();
932extern Lisp_Object Fcondition_case (), Fsignal ();
933extern Lisp_Object Ffunction_type (), Fautoload (), Fcommandp ();
934extern Lisp_Object Feval (), Fapply (), Ffuncall ();
935extern Lisp_Object Fglobal_set (), Fglobal_value (), Fbacktrace ();
936extern Lisp_Object apply1 (), call0 (), call1 (), call2 (), call3 ();
937extern Lisp_Object apply_lambda ();
938extern Lisp_Object internal_catch ();
939extern Lisp_Object internal_condition_case ();
940extern Lisp_Object unbind_to ();
941extern void error ();
942extern Lisp_Object un_autoload ();
943
944/* Defined in editfns.c */
945extern Lisp_Object Vprefix_arg, Qminus, Vcurrent_prefix_arg;
946extern Lisp_Object Fgoto_char ();
947extern Lisp_Object Fpoint_min_marker (), Fpoint_max_marker ();
948extern Lisp_Object Fpoint_min (), Fpoint_max ();
949extern Lisp_Object Fpoint (), Fpoint_marker (), Fmark_marker ();
760cbdd3
JB
950extern Lisp_Object Ffollowing_char (), Fprevious_char (), Fchar_after ();
951extern Lisp_Object Finsert ();
3cfe6dfd
JB
952extern Lisp_Object Feolp (), Feobp (), Fbolp (), Fbobp ();
953extern Lisp_Object Fformat (), format1 ();
954extern Lisp_Object Fbuffer_substring (), Fbuffer_string ();
955extern Lisp_Object Fstring_equal (), Fstring_lessp (), Fbuffer_substring_lessp ();
956extern Lisp_Object save_excursion_save (), save_restriction_save ();
957extern Lisp_Object save_excursion_restore (), save_restriction_restore ();
958extern Lisp_Object Fchar_to_string ();
959
960/* defined in buffer.c */
961extern Lisp_Object Vbuffer_alist;
962extern Lisp_Object Fget_buffer (), Fget_buffer_create (), Fset_buffer ();
963extern Lisp_Object Fbarf_if_buffer_read_only ();
964extern Lisp_Object Fcurrent_buffer (), Fswitch_to_buffer (), Fpop_to_buffer ();
965extern Lisp_Object Fother_buffer ();
966extern struct buffer *all_buffers;
967
968/* defined in marker.c */
969
970extern Lisp_Object Fmarker_position (), Fmarker_buffer ();
971extern Lisp_Object Fcopy_marker ();
972
973/* Defined in fileio.c */
974
975extern Lisp_Object Qfile_error;
976extern Lisp_Object Ffile_name_as_directory ();
977extern Lisp_Object Fexpand_file_name (), Ffile_name_nondirectory ();
978extern Lisp_Object Fsubstitute_in_file_name ();
979extern Lisp_Object Ffile_symlink_p ();
980
981/* Defined in abbrev.c */
982
983extern Lisp_Object Vfundamental_mode_abbrev_table;
984
985/* defined in search.c */
986extern Lisp_Object Fstring_match ();
987extern Lisp_Object Fscan_buffer ();
988
989/* defined in minibuf.c */
990
991extern Lisp_Object last_minibuf_string;
992extern Lisp_Object read_minibuf (), Fcompleting_read ();
993extern Lisp_Object Fread_from_minibuffer ();
994extern Lisp_Object Fread_variable (), Fread_buffer (), Fread_key_sequence ();
995extern Lisp_Object Fread_minibuffer (), Feval_minibuffer ();
996extern Lisp_Object Fread_string (), Fread_file_name ();
997extern Lisp_Object Fread_no_blanks_input ();
998
999/* Defined in callint.c */
1000
1001extern Lisp_Object Vcommand_history;
1002extern Lisp_Object Qcall_interactively;
1003extern Lisp_Object Fcall_interactively ();
1004extern Lisp_Object Fprefix_numeric_value ();
1005
1006/* defined in casefiddle.c */
1007
1008extern Lisp_Object Fdowncase (), Fupcase (), Fcapitalize ();
1009
1010/* defined in keyboard.c */
1011
1012extern Lisp_Object Qdisabled;
1013extern Lisp_Object Vhelp_form, Vtop_level;
1014extern Lisp_Object Fdiscard_input (), Frecursive_edit ();
1015extern Lisp_Object Fcommand_execute (), Finput_pending_p ();
3cfe6dfd
JB
1016
1017/* defined in keymap.c */
1018
1019extern Lisp_Object Qkeymap;
1020extern Lisp_Object current_global_map;
1021extern Lisp_Object Fkey_description (), Fsingle_key_description ();
1022extern Lisp_Object Fwhere_is_internal ();
1023extern Lisp_Object access_keymap (), store_in_keymap ();
1024extern Lisp_Object get_keyelt (), get_keymap();
1025
1026/* defined in indent.c */
1027extern Lisp_Object Fvertical_motion (), Findent_to (), Fcurrent_column ();
1028
1029/* defined in window.c */
1030extern Lisp_Object Qwindowp;
1031extern Lisp_Object Fget_buffer_window ();
1032extern Lisp_Object Fsave_window_excursion ();
1033extern Lisp_Object Fset_window_configuration (), Fcurrent_window_configuration ();
9453ea7b
JB
1034extern Lisp_Object Fcoordinates_in_window_p ();
1035extern Lisp_Object Fwindow_at ();
3cfe6dfd
JB
1036
1037/* defined in screen.c */
1038extern Lisp_Object Fscreenp ();
1039extern Lisp_Object Fselect_screen ();
1040extern Lisp_Object Ffocus_screen ();
1041extern Lisp_Object Funfocus_screen ();
1042extern Lisp_Object Fselected_screen ();
1043extern Lisp_Object Fwindow_screen ();
1044extern Lisp_Object Fscreen_root_window ();
1045extern Lisp_Object Fscreen_selected_window ();
1046extern Lisp_Object Fscreen_list ();
1047extern Lisp_Object Fnext_screen ();
1048extern Lisp_Object Fdelete_screen ();
1049extern Lisp_Object Fread_mouse_position ();
1050extern Lisp_Object Fset_mouse_position ();
1051extern Lisp_Object Fmake_screen_visible ();
1052extern Lisp_Object Fmake_screen_invisible ();
1053extern Lisp_Object Ficonify_screen ();
1054extern Lisp_Object Fdeiconify_screen ();
1055extern Lisp_Object Fscreen_visible_p ();
1056extern Lisp_Object Fvisible_screen_list ();
1057extern Lisp_Object Fscreen_parameters ();
1058extern Lisp_Object Fmodify_screen_parameters ();
1059extern Lisp_Object Fscreen_pixel_size ();
1060extern Lisp_Object Fscreen_height ();
1061extern Lisp_Object Fscreen_width ();
1062extern Lisp_Object Fset_screen_height ();
1063extern Lisp_Object Fset_screen_width ();
1064extern Lisp_Object Fset_screen_size ();
1065extern Lisp_Object Fset_screen_position ();
3cfe6dfd
JB
1066#ifndef HAVE_X11
1067extern Lisp_Object Frubber_band_rectangle ();
1068#endif /* HAVE_X11 */
1069
1070/* defined in emacs.c */
1071extern Lisp_Object decode_env_path ();
1072/* Nonzero means don't do interactive redisplay and don't change tty modes */
1073extern int noninteractive;
1074/* Nonzero means don't do use window-system-specific display code */
1075extern int inhibit_window_system;
1076
1077/* defined in process.c */
1078extern Lisp_Object Fget_process (), Fget_buffer_process (), Fprocessp ();
1079extern Lisp_Object Fprocess_status (), Fkill_process ();
1080
1081/* defined in callproc.c */
9453ea7b 1082extern Lisp_Object Vexec_path, Vexec_directory, Vdata_directory;
3cfe6dfd 1083
3cfe6dfd
JB
1084/* defined in doc.c */
1085extern Lisp_Object Vdoc_file_name;
1086extern Lisp_Object Fsubstitute_command_keys ();
1087extern Lisp_Object Fdocumentation (), Fdocumentation_property ();
1088
1089/* defined in bytecode.c */
1090extern Lisp_Object Qbytecode;
1091
1092/* defined in macros.c */
1093extern Lisp_Object Qexecute_kbd_macro;
1094extern Lisp_Object Fexecute_kbd_macro ();
1095
1096/* Nonzero means Emacs has already been initialized.
1097 Used during startup to detect startup of dumped Emacs. */
1098extern int initialized;
1099
1100extern int immediate_quit; /* Nonzero means ^G can quit instantly */
1101
1102extern void debugger ();
1103
1104extern char *malloc (), *realloc (), *getenv (), *ctime (), *getwd ();
1105extern long *xmalloc (), *xrealloc ();
1106
efb859b4 1107extern char *egetenv ();