declare init_system_name (replaces get_system_name).
[bpt/emacs.git] / src / lisp.h
index c7dd070..a66c1c9 100644 (file)
@@ -1,5 +1,5 @@
 /* Fundamental definitions for GNU Emacs Lisp interpreter.
-   Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1987, 1993, 1994 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -86,9 +86,13 @@ enum Lisp_Type
        XOBJFWD(obj) points to the Lisp_Object variable. */
     Lisp_Objfwd,
 
-    /* Pointer to a vector-like object describing a display screen
-       on which Emacs can display a window hierarchy.  */
-    Lisp_Screen,
+#ifdef MULTI_FRAME
+    /* Pointer to a vector-like object describing a display frame
+       on which Emacs can display a window hierarchy.  We don't define
+       this unless MULTI_FRAME is defined; this helps the compiler catch
+       code that won't work on a non-MULTI_FRAME configuration.  */
+    Lisp_Frame,
+#endif
 
     /* Used when a FILE * value needs to be passed
        in an argument of type Lisp_Object.
@@ -97,36 +101,42 @@ enum Lisp_Type
     Lisp_Internal_Stream,
 
     /* Used in a symbol value cell when the symbol's value is per-buffer.
-        The actual contents are a cons cell which starts a list like this:
-        (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE)).
-
-       BUFFER is the last buffer for which this symbol's value was
-       made up to date.
-
-        CURRENT-ALIST-ELEMENT is a pointer to an element of BUFFER's
-       b_local_var_alist, that being the element whose car is this variable.
-        Or it can be a pointer to the (CURRENT-ALIST-ELEMENT . DEFAULT-VALUE), if BUFFER
-       does not have an element in its alist for this variable
-       (that is, if BUFFER sees the default value of this variable).
-
-       If we want to examine or set the value and BUFFER is current,
-       we just examine or set REALVALUE.
-       If BUFFER is not current, we store the current REALVALUE value into
-       CURRENT-ALIST-ELEMENT, then find the appropriate alist element for
-       the buffer now current and set up CURRENT-ALIST-ELEMENT.
-       Then we set REALVALUE out of that element, and store into BUFFER.
-
-       If we are setting the variable and the current buffer does not have
-       an alist entry for this variable, an alist entry is created.
-
-       Note that REALVALUE can be a forwarding pointer.
-       Each time it is examined or set, forwarding must be done.  */
+       The actual contents are a cons cell which starts a list like this:
+       (REALVALUE BUFFER CURRENT-ALIST-ELEMENT . DEFAULT-VALUE).
+
+       BUFFER is the last buffer for which this symbol's value was
+       made up to date.
+
+       CURRENT-ALIST-ELEMENT is a pointer to an element of BUFFER's
+       local_var_alist, that being the element whose car is this
+       variable.  Or it can be a pointer to the
+       (CURRENT-ALIST-ELEMENT . DEFAULT-VALUE),
+       if BUFFER does not have an element in its alist for this
+       variable (that is, if BUFFER sees the default value of this
+       variable).
+
+       If we want to examine or set the value and BUFFER is current,
+       we just examine or set REALVALUE. If BUFFER is not current, we
+       store the current REALVALUE value into CURRENT-ALIST-ELEMENT,
+       then find the appropriate alist element for the buffer now
+       current and set up CURRENT-ALIST-ELEMENT.  Then we set
+       REALVALUE out of that element, and store into BUFFER.
+
+       If we are setting the variable and the current buffer does not
+       have an alist entry for this variable, an alist entry is
+       created.
+
+       Note that REALVALUE can be a forwarding pointer.  Each time it
+       is examined or set, forwarding must be done.  Each time we
+       switch buffers, buffer-local variables which forward into C
+       variables are swapped immediately, so the C code can assume
+       that they are always up to date.  */
     Lisp_Buffer_Local_Value,
 
     /* Like Lisp_Buffer_Local_Value with one difference:
-       merely setting the variable while some buffer is current
-       does not cause that buffer to have its own local value of this variable.
-       Only make-local-variable does that.  */
+       merely setting the variable while some buffer is current
+       does not cause that buffer to have its own local value of this variable.
+       Only make-local-variable does that.  */
     Lisp_Some_Buffer_Local_Value,
 
 
@@ -143,17 +153,24 @@ enum Lisp_Type
     Lisp_Window,
 
     /* Used by save,set,restore-window-configuration */
-    Lisp_Window_Configuration
+    Lisp_Window_Configuration,
 
 #ifdef LISP_FLOAT_TYPE
-      ,
-    Lisp_Float
+    Lisp_Float,
 #endif /* LISP_FLOAT_TYPE */
+
+    /* The overlay type.
+       An overlay values is actually a retagged cons, the first in a
+       list of the form
+           ((START . END) nil . PLIST)
+       where START and END are markers in the overlay's buffer, and
+       PLIST is the overlay's property list.  */
+    Lisp_Overlay
   };
 
 #ifndef NO_UNION_TYPE
 
-#ifndef BIG_ENDIAN
+#ifndef WORDS_BIG_ENDIAN
 
 /* Definition of Lisp_Object for little-endian machines.  */
 
@@ -185,7 +202,7 @@ union Lisp_Object
   }
 Lisp_Object;
 
-#else /* If BIG_ENDIAN */
+#else /* If WORDS_BIG_ENDIAN */
 
 typedef
 union Lisp_Object
@@ -215,7 +232,7 @@ union Lisp_Object
   }
 Lisp_Object;
 
-#endif /* BIG_ENDIAN */
+#endif /* WORDS_BIG_ENDIAN */
 
 #endif /* NO_UNION_TYPE */
 
@@ -240,8 +257,32 @@ Lisp_Object;
 #define VALMASK ((1<<VALBITS) - 1)
 #endif
 #define GCTYPEMASK ((1<<GCTYPEBITS) - 1)
+
+/* Two flags that are set during GC.  On some machines, these flags
+   are defined differently by the m- file.  */
+
+/* This is set in the car of a cons and in the plist slot of a symbol
+   to indicate it is marked.  Likewise in the plist slot of an interval,
+   the chain slot of a marker, the type slot of a float, and the name
+   slot of a buffer.
+
+   In strings, this bit in the size field indicates that the string
+   is a "large" one, one which was separately malloc'd
+   rather than being part of a string block.  */
+
 #define MARKBIT (1 << (VALBITS + GCTYPEBITS))
 
+/* In the size word of a vector, this bit means the vector has been marked.
+   In the size word of a large string, likewise.  */
+
+#ifndef ARRAY_MARK_FLAG
+#define ARRAY_MARK_FLAG ((MARKBIT >> 1) & ~MARKBIT)
+#endif /* no ARRAY_MARK_FLAG */
+
+#if ARRAY_MARK_FLAG == MARKBIT
+you lose
+#endif
+
 #endif /* NO_UNION_TYPE */
 \f
 /* These macros extract various sorts of values from a Lisp_Object.
@@ -269,7 +310,7 @@ Lisp_Object;
 /* Extract the value of a Lisp_Object as a signed integer.  */
 
 #ifndef XINT   /* Some machines need to do this differently.  */
-#define XINT(a) (((a) << INTBITS-VALBITS) >> INTBITS-VALBITS)
+#define XINT(a) (((a) << (INTBITS-VALBITS)) >> (INTBITS-VALBITS))
 #endif
 
 /* Extract the value as an unsigned integer.  This is a basis
@@ -419,6 +460,74 @@ extern int pure_size;
 #define XSETPROCESS(a, b) XSETPNTR(a, (int) (b))
 #define XSETFLOAT(a, b) XSETPNTR(a, (int) (b))
 \f
+#ifdef USE_TEXT_PROPERTIES
+/* Basic data type for use of intervals.  See the macros in intervals.h */
+
+struct interval
+{
+  /* The first group of entries deal with the tree structure. */
+
+  unsigned int total_length;   /* Length of myself and both children. */
+  unsigned int position;       /* Cache of interval's character position  */
+  struct interval *left;       /* Intervals which precede me. */
+  struct interval *right;      /* Intervals which succeed me. */
+
+  /* Parent in the tree, or the Lisp_Object containing this interval tree.
+
+     The mark bit on the root interval of an interval tree says
+     whether we have started (and possibly finished) marking the
+     tree.  If GC comes across an interval tree whose root's parent
+     field has its markbit set, it leaves the tree alone.
+
+     You'd think we could store this information in the parent object
+     somewhere (after all, that should be visited once and then
+     ignored too, right?), but strings are GC'd strangely.  */
+  struct interval *parent;
+
+  /* The remaining components are `properties' of the interval.
+     The first four are duplicates for things which can be on the list,
+     for purposes of speed. */
+
+  unsigned char write_protect;     /* Non-zero means can't modify.  */
+  unsigned char visible;           /* Zero means don't display. */
+  unsigned char front_sticky;      /* Non-zero means text inserted just
+                                      before this interval goes into it. */
+  unsigned char rear_sticky;       /* Likewise for just after it. */
+
+  /* Properties of this interval.
+     The mark bit on this field says whether this particular interval
+     tree node has been visited.  Since intervals should never be
+     shared, GC aborts if it seems to have visited an interval twice.  */
+  Lisp_Object plist;
+};
+
+typedef struct interval *INTERVAL;
+
+/* Complain if object is not string or buffer type */
+#define CHECK_STRING_OR_BUFFER(x, i) \
+  { if (XTYPE ((x)) != Lisp_String && XTYPE ((x)) != Lisp_Buffer) \
+      x = wrong_type_argument (Qbuffer_or_string_p, (x)); }
+
+/* Macro used to conditionally compile intervals into certain data
+   structures.  See, e.g., struct Lisp_String below. */
+#define DECLARE_INTERVALS INTERVAL intervals;
+
+/* Macro used to conditionally compile interval initialization into
+   certain code.  See, e.g., alloc.c. */
+#define INITIALIZE_INTERVAL(ptr,val) ptr->intervals = val
+
+#else  /* No text properties */
+
+/* If no intervals are used, make the above definitions go away. */
+
+#define CHECK_STRING_OR_BUFFER(x, i)
+
+#define INTERVAL
+#define DECLARE_INTERVALS
+#define INITIALIZE_INTERVAL(ptr,val)
+
+#endif /* USE_TEXT_PROPERTIES */
+\f
 /* In a cons, the markbit of the car is the gc mark bit */
 
 struct Lisp_Cons
@@ -441,6 +550,7 @@ struct Lisp_Buffer_Cons
 struct Lisp_String
   {
     int size;
+    DECLARE_INTERVALS          /* `data' field must be last. */
     unsigned char data[1];
   };
 
@@ -493,7 +603,10 @@ struct Lisp_Float
 
 /* A character, declared with the following typedef, is a member
    of some character set associated with the current buffer. */
+#ifndef _UCHAR_T  /* Protect against something in ctab.h on AIX.  */
+#define _UCHAR_T
 typedef unsigned char UCHAR;
+#endif
 
 /* Meanings of slots in a Lisp_Compiled:  */
 
@@ -503,10 +616,88 @@ typedef unsigned char UCHAR;
 #define COMPILED_STACK_DEPTH 3
 #define COMPILED_DOC_STRING 4
 #define COMPILED_INTERACTIVE 5
+
+/* Flag bits in a character.  These also get used in termhooks.h.
+   Richard Stallman <rms@gnu.ai.mit.edu> thinks that MULE
+   (MUlti-Lingual Emacs) might need 18 bits for the character value
+   itself, so we probably shouldn't use any bits lower than 0x040000.  */
+#define CHAR_ALT   (0x040000)
+#define CHAR_SUPER (0x080000)
+#define CHAR_HYPER (0x100000)
+#define CHAR_SHIFT (0x200000)
+#define CHAR_CTL   (0x400000)
+#define CHAR_META  (0x800000)
+
+#ifdef USE_X_TOOLKIT
+#ifdef NO_UNION_TYPE
+/* Use this for turning a (void *) into a Lisp_Object, as when the
+   Lisp_Object is passed into a toolkit callback function.  */
+#define VOID_TO_LISP(larg,varg) \
+  do { ((larg) = ((Lisp_Object) (varg))); } while (0)
+#define CVOID_TO_LISP VOID_TO_LISP
+
+/* Use this for turning a Lisp_Object into a  (void *), as when the
+   Lisp_Object is passed into a toolkit callback function.  */
+#define LISP_TO_VOID(larg) ((void *) (larg))
+#define LISP_TO_CVOID(varg) ((const void *) (larg))
+
+#else /* not NO_UNION_TYPE */
+/* Use this for turning a (void *) into a Lisp_Object, as when the
+  Lisp_Object is passed into a toolkit callback function.  */
+#define VOID_TO_LISP(larg,varg) \
+  do { ((larg).v = (void *) (varg)); } while (0)
+#define CVOID_TO_LISP(larg,varg) \
+  do { ((larg).cv = (const void *) (varg)); } while (0)
+
+/* Use this for turning a Lisp_Object into a  (void *), as when the
+   Lisp_Object is passed into a toolkit callback function.  */
+#define LISP_TO_VOID(larg) ((larg).v)
+#define LISP_TO_CVOID(larg) ((larg).cv)
+#endif /* not NO_UNION_TYPE */
+#endif /* USE_X_TOOLKIT */
+
+\f
+/* The glyph datatype, used to represent characters on the display.  */
+
+/* The low eight bits are the character code, and the bits above them
+   are the numeric face ID.  If FID is the face ID of a glyph on a
+   frame F, then F->display.x->faces[FID] contains the description of
+   that face.  This is an int instead of a short, so we can support a
+   good bunch of face ID's; given that we have no mechanism for
+   tossing unused frame face ID's yet, we'll probably run out of 255
+   pretty quickly.  */
+#define GLYPH unsigned int
+
+#ifdef HAVE_X_WINDOWS
+/* The FAST macros assume that we already know we're in an X window.  */
+
+/* Given a character code and a face ID, return the appropriate glyph.  */
+#define FAST_MAKE_GLYPH(char, face) ((char) | ((face) << 8))
+
+/* Return a glyph's character code.  */
+#define FAST_GLYPH_CHAR(glyph) ((glyph) & 0xff)
+
+/* Return a glyph's face ID.  */
+#define FAST_GLYPH_FACE(glyph) (((glyph) >> 8) & ((1 << 24) - 1))
+
+/* Slower versions that test the frame type first.  */
+#define MAKE_GLYPH(f, char, face) (FRAME_TERMCAP_P (f) ? (char) \
+                                  : FAST_MAKE_GLYPH (char, face))
+#define GLYPH_CHAR(f, g) (FRAME_TERMCAP_P (f) ? (g) : FAST_GLYPH_CHAR (g))
+#define GLYPH_FACE(f, g) (FRAME_TERMCAP_P (f) ? (0) : FAST_GLYPH_FACE (g))
+#else
+#define MAKE_GLYPH(f, char, face) (char)
+#define GLYPH_CHAR(f, g) (g)
+#define GLYPH_FACE(f, g) (g)
+#endif
+
+/* The ID of the mode line highlighting face.  */
+#define GLYPH_MODE_LINE_FACE 1
 \f
 /* Data type checking */
 
 #define NILP(x)  (XFASTINT (x) == XFASTINT (Qnil))
+#define GC_NILP(x) GC_EQ (x, Qnil)
 
 #ifdef LISP_FLOAT_TYPE
 #define NUMBERP(x) (XTYPE (x) == Lisp_Int || XTYPE (x) == Lisp_Float)
@@ -514,48 +705,80 @@ typedef unsigned char UCHAR;
 #define NUMBERP(x) (XTYPE (x) == Lisp_Int)
 #endif
 
-/* #define LISTP(x) (XTYPE ((x)) == Lisp_Cons)*/
+#define INTEGERP(x) (XTYPE ((x)) == Lisp_Int)
+#define SYMBOLP(x) (XTYPE ((x)) == Lisp_Symbol)
+#define MARKERP(x) (XTYPE ((x)) == Lisp_Marker)
+#define STRINGP(x) (XTYPE ((x)) == Lisp_String)
+#define VECTORP(x) (XTYPE ((x)) == Lisp_Vector)
 #define CONSP(x) (XTYPE ((x)) == Lisp_Cons)
-#define EQ(x, y) (XFASTINT (x) == XFASTINT (y))
+#define COMPILEDP(x) (XTYPE ((x)) == Lisp_Compiled)
+#define BUFFERP(x) (XTYPE ((x)) == Lisp_Buffer)
+#define SUBRP(x) (XTYPE ((x)) == Lisp_Subr)
+#define PROCESSP(x) (XTYPE ((x)) == Lisp_Process)
+#define FRAMEP(x) (XTYPE ((x)) == Lisp_Frame)
+#define WINDOWP(x) (XTYPE ((x)) == Lisp_Window)
+#define WINDOW_CONFIGURATIONP(x) (XTYPE ((x)) == Lisp_Window_Configuration)
+#ifdef LISP_FLOAT_TYPE
+#define FLOATP(x) (XTYPE ((x)) == Lisp_Float)
+#else
+#define FLOATP(x) (0)
+#endif
+#define OVERLAYP(x) (XTYPE ((x)) == Lisp_Overlay)
 
+#define EQ(x, y) (XFASTINT (x) == XFASTINT (y))
+#define GC_EQ(x, y) (XGCTYPE (x) == XGCTYPE (y) && XPNTR (x) == XPNTR (y))
 
 #define CHECK_LIST(x, i) \
-  { if ((XTYPE ((x)) != Lisp_Cons) && !NILP (x)) x = wrong_type_argument (Qlistp, (x)); }
+  do { if ((XTYPE ((x)) != Lisp_Cons) && !NILP (x)) x = wrong_type_argument (Qlistp, (x)); } while (0)
 
 #define CHECK_STRING(x, i) \
-  { if (XTYPE ((x)) != Lisp_String) x = wrong_type_argument (Qstringp, (x)); }
+  do { if (XTYPE ((x)) != Lisp_String) x = wrong_type_argument (Qstringp, (x)); } while (0)
 
 #define CHECK_CONS(x, i) \
-  { if (XTYPE ((x)) != Lisp_Cons) x = wrong_type_argument (Qconsp, (x)); }
+  do { if (XTYPE ((x)) != Lisp_Cons) x = wrong_type_argument (Qconsp, (x)); } while (0)
 
 #define CHECK_SYMBOL(x, i) \
-  { if (XTYPE ((x)) != Lisp_Symbol) x = wrong_type_argument (Qsymbolp, (x)); }
+  do { if (XTYPE ((x)) != Lisp_Symbol) x = wrong_type_argument (Qsymbolp, (x)); } while (0)
 
 #define CHECK_VECTOR(x, i) \
-  { if (XTYPE ((x)) != Lisp_Vector) x = wrong_type_argument (Qvectorp, (x)); }
+  do { if (XTYPE ((x)) != Lisp_Vector) x = wrong_type_argument (Qvectorp, (x)); } while (0)
 
 #define CHECK_BUFFER(x, i) \
-  { if (XTYPE ((x)) != Lisp_Buffer) x = wrong_type_argument (Qbufferp, (x)); }
+  do { if (XTYPE ((x)) != Lisp_Buffer) x = wrong_type_argument (Qbufferp, (x)); } while (0)
 
 #define CHECK_WINDOW(x, i) \
-  { if (XTYPE ((x)) != Lisp_Window) x = wrong_type_argument (Qwindowp, (x)); }
+  do { if (XTYPE ((x)) != Lisp_Window) x = wrong_type_argument (Qwindowp, (x)); } while (0)
+
+/* This macro rejects windows on the interior of the window tree as
+   "dead", which is what we want; this is an argument-checking macro, and 
+   the user should never get access to interior windows.
+
+   A window of any sort, leaf or interior, is dead iff the buffer,
+   vchild, and hchild members are all nil.  */
+
+#define CHECK_LIVE_WINDOW(x, i)                                \
+  do {                                                 \
+    if (XTYPE ((x)) != Lisp_Window                     \
+       || NILP (XWINDOW ((x))->buffer))                \
+      x = wrong_type_argument (Qwindow_live_p, (x));   \
+  } while (0)
 
 #define CHECK_PROCESS(x, i) \
-  { if (XTYPE ((x)) != Lisp_Process) x = wrong_type_argument (Qprocessp, (x)); }
+  do { if (XTYPE ((x)) != Lisp_Process) x = wrong_type_argument (Qprocessp, (x)); } while (0)
 
 #define CHECK_NUMBER(x, i) \
-  { if (XTYPE ((x)) != Lisp_Int) x = wrong_type_argument (Qintegerp, (x)); }
+  do { if (XTYPE ((x)) != Lisp_Int) x = wrong_type_argument (Qintegerp, (x)); } while (0)
 
 #define CHECK_NATNUM(x, i) \
-  { if (XTYPE ((x)) != Lisp_Int || XINT ((x)) < 0)     \
-      x = wrong_type_argument (Qnatnump, (x)); }
+  do { if (XTYPE ((x)) != Lisp_Int || XINT ((x)) < 0)  \
+      x = wrong_type_argument (Qwholenump, (x)); } while (0)
 
 #define CHECK_MARKER(x, i) \
-  { if (XTYPE ((x)) != Lisp_Marker) x = wrong_type_argument (Qmarkerp, (x)); }
+  do { if (XTYPE ((x)) != Lisp_Marker) x = wrong_type_argument (Qmarkerp, (x)); } while (0)
 
 #define CHECK_NUMBER_COERCE_MARKER(x, i) \
-  { if (XTYPE ((x)) == Lisp_Marker) XFASTINT (x) = marker_position (x); \
-    else if (XTYPE ((x)) != Lisp_Int) x = wrong_type_argument (Qinteger_or_marker_p, (x)); }
+  do { if (XTYPE ((x)) == Lisp_Marker) XFASTINT (x) = marker_position (x); \
+    else if (XTYPE ((x)) != Lisp_Int) x = wrong_type_argument (Qinteger_or_marker_p, (x)); } while (0)
 
 #ifdef LISP_FLOAT_TYPE
 
@@ -566,17 +789,17 @@ typedef unsigned char UCHAR;
 #define XFLOATINT(n) extract_float((n))
 
 #define CHECK_FLOAT(x, i)              \
-{ if (XTYPE (x) != Lisp_Float) \
-    x = wrong_type_argument (Qfloatp, (x)); }
+  do { if (XTYPE (x) != Lisp_Float)    \
+    x = wrong_type_argument (Qfloatp, (x)); } while (0)
 
 #define CHECK_NUMBER_OR_FLOAT(x, i)    \
-{ if (XTYPE (x) != Lisp_Float && XTYPE (x) != Lisp_Int)        \
-    x = wrong_type_argument (Qinteger_or_floatp, (x)); }
+  do { if (XTYPE (x) != Lisp_Float && XTYPE (x) != Lisp_Int)   \
+    x = wrong_type_argument (Qnumberp, (x)); } while (0)
 
 #define CHECK_NUMBER_OR_FLOAT_COERCE_MARKER(x, i) \
-{ if (XTYPE (x) == Lisp_Marker) XFASTINT (x) = marker_position (x);    \
+  do { if (XTYPE (x) == Lisp_Marker) XFASTINT (x) = marker_position (x);       \
   else if (XTYPE (x) != Lisp_Int && XTYPE (x) != Lisp_Float)           \
-    x = wrong_type_argument (Qinteger_or_float_or_marker_p, (x)); }
+    x = wrong_type_argument (Qnumber_or_marker_p, (x)); } while (0)
 
 #else  /* Not LISP_FLOAT_TYPE */
 
@@ -587,6 +810,9 @@ typedef unsigned char UCHAR;
 #define XFLOATINT(n) XINT((n))
 #endif /* LISP_FLOAT_TYPE */
 
+#define CHECK_OVERLAY(x, i) \
+  do { if (XTYPE ((x)) != Lisp_Overlay) x = wrong_type_argument (Qoverlayp, (x));} while (0)
+
 /* Cast pointers to this type to compare them.  Some machines want int.  */
 #ifndef PNTR_COMPARISON_TYPE
 #define PNTR_COMPARISON_TYPE unsigned int
@@ -635,11 +861,38 @@ typedef unsigned char UCHAR;
  `doc' is documentation for the user.
 */
 
+#ifndef __STDC__
 #define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc) \
   Lisp_Object fnname (); \
   struct Lisp_Subr sname = {fnname, minargs, maxargs, lname, prompt, 0}; \
   Lisp_Object fnname
 
+#else
+
+/* This version of DEFUN declares a function prototype with the right
+   arguments, so we can catch errors with maxargs at compile-time. */
+#define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc) \
+  Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
+  struct Lisp_Subr sname = {fnname, minargs, maxargs, lname, prompt, 0}; \
+  Lisp_Object fnname
+
+/* Note that the weird token-substitution semantics of ANSI C makes
+   this work for MANY and UNEVALLED. */
+#define DEFUN_ARGS_MANY                (int, Lisp_Object *)
+#define DEFUN_ARGS_UNEVALLED   (Lisp_Object)
+#define DEFUN_ARGS_0   (void)
+#define DEFUN_ARGS_1   (Lisp_Object)
+#define DEFUN_ARGS_2   (Lisp_Object, Lisp_Object)
+#define DEFUN_ARGS_3   (Lisp_Object, Lisp_Object, Lisp_Object)
+#define DEFUN_ARGS_4   (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)
+#define DEFUN_ARGS_5   (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \
+                        Lisp_Object)
+#define DEFUN_ARGS_6   (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \
+                        Lisp_Object, Lisp_Object)
+#define DEFUN_ARGS_7   (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \
+                        Lisp_Object, Lisp_Object, Lisp_Object)
+#endif
+
 /* defsubr (Sname);
  is how we define the symbol for function `name' at start-up time. */
 extern void defsubr ();
@@ -654,21 +907,27 @@ extern void defvar_int ();
 /* Macros we use to define forwarded Lisp variables.
    These are used in the syms_of_FILENAME functions.  */
 
-#define DEFVARLISP(lname, vname, doc) defvar_lisp (lname, vname)
-#define DEFVARBOOL(lname, vname, doc) defvar_bool (lname, vname)
-#define DEFVARINT(lname, vname, doc) defvar_int (lname, vname)
-#define DEFVARPERBUFFER(lname, vname, doc)  \
- defvar_per_buffer (lname, vname)
-
 #define DEFVAR_LISP(lname, vname, doc) defvar_lisp (lname, vname)
 #define DEFVAR_LISP_NOPRO(lname, vname, doc) defvar_lisp_nopro (lname, vname)
 #define DEFVAR_BOOL(lname, vname, doc) defvar_bool (lname, vname)
 #define DEFVAR_INT(lname, vname, doc) defvar_int (lname, vname)
-#define DEFVAR_PER_BUFFER(lname, vname, doc)  \
- defvar_per_buffer (lname, vname)
+#define DEFVAR_PER_BUFFER(lname, vname, type, doc)  \
+ defvar_per_buffer (lname, vname, type, 0)
 \f
-/* Structure for recording Lisp call stack for backtrace purposes */
-
+/* Structure for recording Lisp call stack for backtrace purposes.  */
+
+/* The special binding stack holds the outer values of variables while
+   they are bound by a function application or a let form, stores the
+   code to be executed for Lisp unwind-protect forms, and stores the C
+   functions to be called for record_unwind_protect.
+
+   If func is non-zero, undoing this binding applies func to old_value;
+      This implements record_unwind_protect.
+   If func is zero and symbol is nil, undoing this binding evaluates
+      the list of forms in old_value; this implements Lisp's unwind-protect
+      form.
+   Otherwise, undoing this binding stores old_value as symbol's value; this
+      undoes the bindings made by a let form or function call.  */
 struct specbinding
   {
     Lisp_Object symbol, old_value;
@@ -680,13 +939,20 @@ extern struct specbinding *specpdl;
 extern struct specbinding *specpdl_ptr;
 extern int specpdl_size;
 
+/* Everything needed to describe an active condition case.  */
 struct handler
   {
+    /* The handler clauses and variable from the condition-case form.  */
     Lisp_Object handler;
     Lisp_Object var;
-    int poll_suppress_count;   /* No error should exit a piece of code
-                                  in which polling is suppressed.  */
+    /* Fsignal stores here the condition-case clause that applies,
+       and Fcondition_case thus knows which clause to run.  */
+    Lisp_Object chosen_clause;
+
+    /* Used to effect the longjump out to the handler.  */
     struct catchtag *tag;
+
+    /* The next enclosing handler.  */
     struct handler *next;
   };
 
@@ -695,6 +961,8 @@ extern struct handler *handlerlist;
 extern struct catchtag *catchlist;
 extern struct backtrace *backtrace_list;
 
+extern Lisp_Object memory_signal_data;
+
 /* An address near the bottom of the stack.
    Tells GC how to save a copy of the stack.  */
 extern char *stack_bottom;
@@ -747,6 +1015,7 @@ extern char *stack_bottom;
 #define UPCASE_TABLE XSTRING (current_buffer->upcase_table)->data
 
 extern Lisp_Object Vascii_downcase_table, Vascii_upcase_table;
+extern Lisp_Object Vascii_canon_table, Vascii_eqv_table;
 \f
 /* number of bytes of structure consed since last GC */
 
@@ -763,7 +1032,8 @@ extern int gc_cons_threshold;
  Normally every link of the chain is an automatic variable of a function,
  and its `val' points to some argument or local variable of the function.
  On exit to the function, the chain is set back to the value it had on entry.
- This way, no link remains in the chain when the stack frame containing the link disappears.
+ This way, no link remains in the chain when the stack frame containing the
+ link disappears.
 
  Every function that can call Feval must protect in this fashion all
  Lisp_Object variables whose contents will be used again. */
@@ -805,16 +1075,17 @@ void staticpro();
   
 #define UNGCPRO (gcprolist = gcpro1.next)
 
-/* Evaluate expr, UNGCPRO, and then return the value of expr.  */
+/* Evaluate expr, UNGCPRO, and then return the value of expr.  I used
+   to have a `do ... while' clause around this to make it interact
+   with semicolons correctly, but this makes some compilers complain
+   that the while is never reached.  */
 #define RETURN_UNGCPRO(expr)           \
-  do                                   \
     {                                  \
       Lisp_Object ret_ungc_val;                \
       ret_ungc_val = (expr);           \
       UNGCPRO;                         \
       return ret_ungc_val;             \
-    }                                  \
-  while (0)
+    }
 \f
 /* Defined in data.c */
 extern Lisp_Object Qnil, Qt, Qquote, Qlambda, Qsubr, Qunbound;
@@ -825,18 +1096,25 @@ extern Lisp_Object Qsetting_constant, Qinvalid_read_syntax;
 extern Lisp_Object Qinvalid_function, Qwrong_number_of_arguments, Qno_catch;
 extern Lisp_Object Qend_of_file, Qarith_error;
 extern Lisp_Object Qbeginning_of_buffer, Qend_of_buffer, Qbuffer_read_only;
+extern Lisp_Object Qmark_inactive;
 
-extern Lisp_Object Qintegerp, Qnatnump, Qsymbolp, Qlistp, Qconsp;
+extern Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error;
+extern Lisp_Object Qoverflow_error, Qunderflow_error;
+
+extern Lisp_Object Qintegerp, Qnumberp, Qnatnump, Qwholenump;
+extern Lisp_Object Qsymbolp, Qlistp, Qconsp;
 extern Lisp_Object Qstringp, Qarrayp, Qsequencep, Qbufferp;
 extern Lisp_Object Qchar_or_string_p, Qmarkerp, Qvectorp;
-extern Lisp_Object Qinteger_or_marker_p, Qboundp, Qfboundp;
+extern Lisp_Object Qinteger_or_marker_p, Qnumber_or_marker_p;
+extern Lisp_Object Qboundp, Qfboundp;
+extern Lisp_Object Qbuffer_or_string_p;
 extern Lisp_Object Qcdr;
 
 #ifdef LISP_FLOAT_TYPE
 extern Lisp_Object Qfloatp, Qinteger_or_floatp, Qinteger_or_float_or_marker_p;
 #endif /* LISP_FLOAT_TYPE */
 
-extern Lisp_Object Qscreenp;
+extern Lisp_Object Qframep;
 
 extern Lisp_Object Feq (), Fnull (), Flistp (), Fconsp (), Fatom (), Fnlistp ();
 extern Lisp_Object Fintegerp (), Fnatnump (), Fsymbolp ();
@@ -852,25 +1130,34 @@ extern Lisp_Object Fcar (), Fcar_safe(), Fcdr (), Fcdr_safe();
 extern Lisp_Object Fsetcar (), Fsetcdr ();
 extern Lisp_Object Fboundp (), Ffboundp (), Fmakunbound (), Ffmakunbound ();
 extern Lisp_Object Fsymbol_function (), Fsymbol_plist (), Fsymbol_name ();
+extern Lisp_Object indirect_function (), Findirect_function ();
 extern Lisp_Object Ffset (), Fsetplist ();
 extern Lisp_Object Fsymbol_value (), find_symbol_value (), Fset ();
-extern Lisp_Object Fdefault_value (), Fset_default ();
+extern Lisp_Object Fdefault_value (), Fset_default (), Fdefault_boundp ();
 
 extern Lisp_Object Faref (), Faset (), Farray_length ();
 
-extern Lisp_Object Fstring_to_int (), Fint_to_string ();
-extern Lisp_Object Feqlsign (), Fgtr (), Flss (), Fgeq (), Fleq (), Fneq (), Fzerop ();
-extern Lisp_Object Fplus (), Fminus (), Ftimes (), Fquo (), Frem (), Fmax (), Fmin ();
-extern Lisp_Object Flogand (), Flogior (), Flogxor (), Flognot (), Flsh (), Fash ();
+extern Lisp_Object Fstring_to_number (), Fnumber_to_string ();
+extern Lisp_Object Feqlsign (), Fgtr (), Flss (), Fgeq (), Fleq ();
+extern Lisp_Object Fneq (), Fzerop ();
+extern Lisp_Object Fplus (), Fminus (), Ftimes (), Fquo (), Frem ();
+extern Lisp_Object Fmax (), Fmin ();
+extern Lisp_Object Flogand (), Flogior (), Flogxor (), Flognot ();
+extern Lisp_Object Flsh (), Fash ();
+
 extern Lisp_Object Fadd1 (), Fsub1 ();
 
 extern Lisp_Object make_number ();
+extern Lisp_Object   long_to_cons ();
+extern unsigned long cons_to_long ();
 extern void args_out_of_range ();
 extern void args_out_of_range_3 ();
 extern Lisp_Object wrong_type_argument ();
 #ifdef LISP_FLOAT_TYPE
 extern Lisp_Object Ffloat_to_int(), Fint_to_float();
 extern double extract_float();
+extern Lisp_Object make_float ();
+extern Lisp_Object Ffloat ();
 #endif /* LISP_FLOAT_TYPE */
 
 /* Defined in fns.c */
@@ -880,7 +1167,7 @@ extern Lisp_Object Fidentity (), Frandom ();
 extern Lisp_Object Flength ();
 extern Lisp_Object Fappend (), Fconcat (), Fvconcat (), Fcopy_sequence ();
 extern Lisp_Object Fsubstring ();
-extern Lisp_Object Fnthcdr (), Fmemq (), Fassq (), Fassoc ();
+extern Lisp_Object Fnth (), Fnthcdr (), Fmemq (), Fassq (), Fassoc ();
 extern Lisp_Object Frassq (), Fdelq (), Fsort ();
 extern Lisp_Object Freverse (), Fnreverse (), Fget (), Fput (), Fequal ();
 extern Lisp_Object Ffillarray (), Fnconc (), Fmapcar (), Fmapconcat ();
@@ -888,16 +1175,19 @@ extern Lisp_Object Fy_or_n_p (), do_yes_or_no_p ();
 extern Lisp_Object Ffeaturep (), Frequire () , Fprovide ();
 extern Lisp_Object concat2 (), nconc2 ();
 extern Lisp_Object assq_no_quit ();
+extern Lisp_Object Fcopy_alist ();
 
 /* Defined in alloc.c */
 extern Lisp_Object Vpurify_flag;
 extern Lisp_Object Fcons (), Flist(), Fmake_list ();
 extern Lisp_Object Fmake_vector (), Fvector (), Fmake_symbol (), Fmake_marker ();
 extern Lisp_Object Fmake_string (), build_string (), make_string ();
-extern Lisp_Object make_array (), make_uninit_string ();
+extern Lisp_Object make_event_array (), make_uninit_string ();
 extern Lisp_Object Fpurecopy (), make_pure_string ();
 extern Lisp_Object pure_cons (), make_pure_vector ();
 extern Lisp_Object Fgarbage_collect ();
+extern Lisp_Object Fmake_byte_code ();
+extern int gc_in_progress;
 
 /* Defined in print.c */
 extern Lisp_Object Vprin1_to_string_buffer;
@@ -915,14 +1205,22 @@ extern Lisp_Object Vobarray, Vstandard_input;
 extern Lisp_Object Fread (), Fread_from_string ();
 extern Lisp_Object Fintern (), Fintern_soft (), Fload ();
 extern Lisp_Object Fget_file_char (), Fread_char ();
+extern Lisp_Object read_filtered_event ();
 extern Lisp_Object Feval_current_buffer (), Feval_region ();
 extern Lisp_Object intern (), oblookup ();
+#define LOADHIST_ATTACH(x) \
+ if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list)
+extern Lisp_Object Vcurrent_load_list;
+extern Lisp_Object Vload_history;
 
 /* Defined in eval.c */
 extern Lisp_Object Qautoload, Qexit, Qinteractive, Qcommandp, Qdefun, Qmacro;
 extern Lisp_Object Vinhibit_quit, Qinhibit_quit, Vquit_flag;
 extern Lisp_Object Vmocklisp_arguments, Qmocklisp, Qmocklisp_arguments;
 extern Lisp_Object Vautoload_queue;
+/* To run a normal hook, do
+   if (!NILP (Vrun_hooks))
+     call1 (Vrun_hooks, Qmy_funny_hook);  */
 extern Lisp_Object Vrun_hooks;
 extern Lisp_Object Fand (), For (), Fif (), Fprogn (), Fprog1 (), Fprog2 ();
 extern Lisp_Object Fsetq (), Fquote ();
@@ -937,6 +1235,7 @@ extern Lisp_Object apply1 (), call0 (), call1 (), call2 (), call3 ();
 extern Lisp_Object apply_lambda ();
 extern Lisp_Object internal_catch ();
 extern Lisp_Object internal_condition_case ();
+extern Lisp_Object internal_condition_case_1 ();
 extern Lisp_Object unbind_to ();
 extern void error ();
 extern Lisp_Object un_autoload ();
@@ -951,18 +1250,21 @@ extern Lisp_Object Ffollowing_char (), Fprevious_char (), Fchar_after ();
 extern Lisp_Object Finsert ();
 extern Lisp_Object Feolp (), Feobp (), Fbolp (), Fbobp ();
 extern Lisp_Object Fformat (), format1 ();
-extern Lisp_Object Fbuffer_substring (), Fbuffer_string ();
+extern Lisp_Object make_buffer_string (), Fbuffer_substring ();
+extern Lisp_Object Fbuffer_string ();
 extern Lisp_Object Fstring_equal (), Fstring_lessp (), Fbuffer_substring_lessp ();
 extern Lisp_Object save_excursion_save (), save_restriction_save ();
 extern Lisp_Object save_excursion_restore (), save_restriction_restore ();
 extern Lisp_Object Fchar_to_string ();
 
 /* defined in buffer.c */
-extern Lisp_Object Vbuffer_alist;
+extern Lisp_Object Vbuffer_alist, Vinhibit_read_only;
 extern Lisp_Object Fget_buffer (), Fget_buffer_create (), Fset_buffer ();
 extern Lisp_Object Fbarf_if_buffer_read_only ();
 extern Lisp_Object Fcurrent_buffer (), Fswitch_to_buffer (), Fpop_to_buffer ();
 extern Lisp_Object Fother_buffer ();
+extern Lisp_Object Foverlay_get ();
+extern Lisp_Object Qoverlayp;
 extern struct buffer *all_buffers;
 
 /* defined in marker.c */
@@ -973,10 +1275,17 @@ extern Lisp_Object Fcopy_marker ();
 /* Defined in fileio.c */
 
 extern Lisp_Object Qfile_error;
+extern Lisp_Object Ffind_file_name_handler ();
 extern Lisp_Object Ffile_name_as_directory ();
 extern Lisp_Object Fexpand_file_name (), Ffile_name_nondirectory ();
 extern Lisp_Object Fsubstitute_in_file_name ();
 extern Lisp_Object Ffile_symlink_p ();
+extern Lisp_Object Fverify_visited_file_modtime ();
+extern Lisp_Object Ffile_exists_p ();
+extern Lisp_Object Fdirectory_file_name ();
+extern Lisp_Object Ffile_name_directory ();
+extern Lisp_Object expand_and_dir_to_file ();
+extern Lisp_Object Ffile_accessible_directory_p ();
 
 /* Defined in abbrev.c */
 
@@ -1013,10 +1322,11 @@ extern Lisp_Object Qdisabled;
 extern Lisp_Object Vhelp_form, Vtop_level;
 extern Lisp_Object Fdiscard_input (), Frecursive_edit ();
 extern Lisp_Object Fcommand_execute (), Finput_pending_p ();
+extern Lisp_Object Qvertical_scroll_bar;
 
 /* defined in keymap.c */
 
-extern Lisp_Object Qkeymap;
+extern Lisp_Object Qkeymap, Qmenu_bar;
 extern Lisp_Object current_global_map;
 extern Lisp_Object Fkey_description (), Fsingle_key_description ();
 extern Lisp_Object Fwhere_is_internal ();
@@ -1027,48 +1337,53 @@ extern Lisp_Object get_keyelt (), get_keymap();
 extern Lisp_Object Fvertical_motion (), Findent_to (), Fcurrent_column ();
 
 /* defined in window.c */
-extern Lisp_Object Qwindowp;
+extern Lisp_Object Qwindowp, Qwindow_live_p;
 extern Lisp_Object Fget_buffer_window ();
 extern Lisp_Object Fsave_window_excursion ();
 extern Lisp_Object Fset_window_configuration (), Fcurrent_window_configuration ();
 extern Lisp_Object Fcoordinates_in_window_p ();
 extern Lisp_Object Fwindow_at ();
-
-/* defined in screen.c */
-extern Lisp_Object Fscreenp ();
-extern Lisp_Object Fselect_screen ();
-extern Lisp_Object Ffocus_screen ();
-extern Lisp_Object Funfocus_screen ();
-extern Lisp_Object Fselected_screen ();
-extern Lisp_Object Fwindow_screen ();
-extern Lisp_Object Fscreen_root_window ();
-extern Lisp_Object Fscreen_selected_window ();
-extern Lisp_Object Fscreen_list ();
-extern Lisp_Object Fnext_screen ();
-extern Lisp_Object Fdelete_screen ();
+extern int window_internal_height (), window_internal_width ();
+
+/* defined in frame.c */
+extern Lisp_Object Qvisible;
+extern Lisp_Object Fframep ();
+extern Lisp_Object Fselect_frame ();
+extern Lisp_Object Ffocus_frame ();
+extern Lisp_Object Funfocus_frame ();
+extern Lisp_Object Fselected_frame ();
+extern Lisp_Object Fwindow_frame ();
+extern Lisp_Object Fframe_root_window ();
+extern Lisp_Object Fframe_selected_window ();
+extern Lisp_Object Fframe_list ();
+extern Lisp_Object Fnext_frame ();
+extern Lisp_Object Fdelete_frame ();
 extern Lisp_Object Fread_mouse_position ();
 extern Lisp_Object Fset_mouse_position ();
-extern Lisp_Object Fmake_screen_visible ();
-extern Lisp_Object Fmake_screen_invisible ();
-extern Lisp_Object Ficonify_screen ();
-extern Lisp_Object Fdeiconify_screen ();
-extern Lisp_Object Fscreen_visible_p ();
-extern Lisp_Object Fvisible_screen_list ();
-extern Lisp_Object Fscreen_parameters ();
-extern Lisp_Object Fmodify_screen_parameters ();
-extern Lisp_Object Fscreen_pixel_size ();
-extern Lisp_Object Fscreen_height ();
-extern Lisp_Object Fscreen_width ();
-extern Lisp_Object Fset_screen_height ();
-extern Lisp_Object Fset_screen_width ();
-extern Lisp_Object Fset_screen_size ();
-extern Lisp_Object Fset_screen_position ();
+extern Lisp_Object Fmake_frame_visible ();
+extern Lisp_Object Fmake_frame_invisible ();
+extern Lisp_Object Ficonify_frame ();
+extern Lisp_Object Fdeiconify_frame ();
+extern Lisp_Object Fframe_visible_p ();
+extern Lisp_Object Fvisible_frame_list ();
+extern Lisp_Object Fframe_parameters ();
+extern Lisp_Object Fmodify_frame_parameters ();
+extern Lisp_Object Fframe_pixel_size ();
+extern Lisp_Object Fframe_height ();
+extern Lisp_Object Fframe_width ();
+extern Lisp_Object Fset_frame_height ();
+extern Lisp_Object Fset_frame_width ();
+extern Lisp_Object Fset_frame_size ();
+extern Lisp_Object Fset_frame_position ();
 #ifndef HAVE_X11
 extern Lisp_Object Frubber_band_rectangle ();
 #endif /* HAVE_X11 */
 
 /* defined in emacs.c */
 extern Lisp_Object decode_env_path ();
+extern Lisp_Object Vinvocation_name, Vinvocation_directory;
+extern Lisp_Object Vinstallation_directory;
+void shut_down_emacs ( /* int signal, int no_x, Lisp_Object stuff */ );
 /* Nonzero means don't do interactive redisplay and don't change tty modes */
 extern int noninteractive;
 /* Nonzero means don't do use window-system-specific display code */
@@ -1077,9 +1392,11 @@ extern int inhibit_window_system;
 /* defined in process.c */
 extern Lisp_Object Fget_process (), Fget_buffer_process (), Fprocessp ();
 extern Lisp_Object Fprocess_status (), Fkill_process ();
+extern Lisp_Object Fprocess_send_eof ();
 
 /* defined in callproc.c */
 extern Lisp_Object Vexec_path, Vexec_directory, Vdata_directory;
+extern Lisp_Object Vdoc_directory;
 
 /* defined in doc.c */
 extern Lisp_Object Vdoc_file_name;
@@ -1088,11 +1405,22 @@ extern Lisp_Object Fdocumentation (), Fdocumentation_property ();
 
 /* defined in bytecode.c */
 extern Lisp_Object Qbytecode;
+extern Lisp_Object Fbyte_code ();
 
 /* defined in macros.c */
 extern Lisp_Object Qexecute_kbd_macro;
 extern Lisp_Object Fexecute_kbd_macro ();
 
+/* defined in undo.c */
+extern Lisp_Object Fundo_boundary ();
+extern Lisp_Object truncate_undo_list ();
+
+/* defined in textprop.c */
+extern Lisp_Object Qmodification_hooks;
+extern Lisp_Object Qinsert_in_front_hooks, Qinsert_behind_hooks;
+extern Lisp_Object Fnext_property_change ();
+extern Lisp_Object Fnext_single_property_change ();
+
 /* Nonzero means Emacs has already been initialized.
    Used during startup to detect startup of dumped Emacs.  */
 extern int initialized;
@@ -1101,7 +1429,11 @@ extern int immediate_quit;           /* Nonzero means ^G can quit instantly */
 
 extern void debugger ();
 
-extern char *malloc (), *realloc (), *getenv (), *ctime (), *getwd ();
+extern char *getenv (), *ctime (), *getwd ();
 extern long *xmalloc (), *xrealloc ();
+extern void xfree ();
 
 extern char *egetenv ();
+/* Set up the name of the machine we're running on.  */
+extern void init_system_name ();