Trailing whitespace deleted.
[bpt/emacs.git] / src / lisp.h
index 3f23da8..ca4811e 100644 (file)
@@ -1,5 +1,5 @@
 /* Fundamental definitions for GNU Emacs Lisp interpreter.
-   Copyright (C) 1985,86,87,93,94,95,97,98,1999,2000, 2001
+   Copyright (C) 1985,86,87,93,94,95,97,98,1999,2000, 2001, 2002
      Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -76,7 +76,7 @@ extern void die P_((const char *, const char *, int));
 #endif
 
 /* Used for making sure that Emacs is compilable in all
-   conigurations.  */
+   configurations.  */
 
 #ifdef USE_LISP_UNION_TYPE
 #undef NO_UNION_TYPE
@@ -129,7 +129,7 @@ enum Lisp_Type
     Lisp_Type_Limit
   };
 
-/* This is the set of datatypes that share a common structure.
+/* This is the set of data types that share a common structure.
    The first member of the structure is a type code from this set.
    The enum values are arbitrary, but we'll use large numbers to make it
    more likely that we'll spot the error if a random word in memory is
@@ -146,6 +146,7 @@ enum Lisp_Misc_Type
     Lisp_Misc_Some_Buffer_Local_Value,
     Lisp_Misc_Overlay,
     Lisp_Misc_Kboard_Objfwd,
+    Lisp_Misc_Save_Value,
     /* Currently floats are not a misc type,
        but let's define this in case we want to change that.  */
     Lisp_Misc_Float,
@@ -162,26 +163,6 @@ enum Lisp_Misc_Type
 #define GCTYPEBITS 3
 #endif
 
-#if 0  /* This doesn't work on some systems that don't allow enumerators
-         > INT_MAX, and it won't work for long long EMACS_INT.  These
-         values are now found in emacs.c as EMACS_INT variables.  */
-
-/* Make these values available in GDB, which sees enums but not macros.  */
-
-enum gdb_lisp_params
-{
-  gdb_valbits = VALBITS,
-  gdb_gctypebits = GCTYPEBITS,
-  gdb_emacs_intbits = sizeof (EMACS_INT) * BITS_PER_CHAR,
-#ifdef DATA_SEG_BITS
-  gdb_data_seg_bits = DATA_SEG_BITS
-#else
-  gdb_data_seg_bits = 0
-#endif
-};
-
-#endif /* 0 */
-
 #ifndef NO_UNION_TYPE
 
 #ifndef WORDS_BIG_ENDIAN
@@ -248,6 +229,20 @@ Lisp_Object;
 
 #endif /* WORDS_BIG_ENDIAN */
 
+#ifdef __GNUC__
+static __inline__ Lisp_Object
+LISP_MAKE_RVALUE (Lisp_Object o)
+{
+    return o;
+}
+#else
+/* This isn't quite right - it keeps the argument as an lvalue.
+   Making it const via casting would help avoid code actually
+   modifying the location in question, but the casting could cover
+   other type-related bugs.  */
+#define LISP_MAKE_RVALUE(o) (o)
+#endif
+
 #endif /* NO_UNION_TYPE */
 
 
@@ -255,6 +250,7 @@ Lisp_Object;
 
 #ifdef NO_UNION_TYPE
 #define Lisp_Object EMACS_INT
+#define LISP_MAKE_RVALUE(o) (0+(o))
 #endif /* NO_UNION_TYPE */
 
 #ifndef VALMASK
@@ -308,7 +304,7 @@ enum pvec_type
   PVEC_BUFFER = 0x20000,
   PVEC_HASH_TABLE = 0x40000,
   PVEC_TYPE_MASK = 0x7fe00
-  
+
 #if 0 /* This is used to make the value of PSEUDOVECTOR_FLAG available to
         GDB.  It doesn't work on OS Alpha.  Moved to a variable in
         emacs.c.  */
@@ -327,7 +323,7 @@ enum pvec_type
 
 /* One need to override this if there must be high bits set in data space
    (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work
-    on all machines, but would penalise machines which don't need it)
+    on all machines, but would penalize machines which don't need it)
  */
 #ifndef XTYPE
 #define XTYPE(a) ((enum Lisp_Type) ((a) >> VALBITS))
@@ -357,26 +353,6 @@ enum pvec_type
 #define XUINT(a) ((EMACS_UINT) ((a) & VALMASK))
 #endif
 
-#ifndef XPNTR
-#ifdef HAVE_SHM
-/* In this representation, data is found in two widely separated segments.  */
-extern int pure_size;
-#define XPNTR(a) \
-  (XUINT (a) | (XUINT (a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS))
-#else /* not HAVE_SHM */
-#ifdef DATA_SEG_BITS
-/* This case is used for the rt-pc.
-   In the diffs I was given, it checked for ptr = 0
-   and did not adjust it in that case.
-   But I don't think that zero should ever be found
-   in a Lisp object whose data type says it points to something.  */
-#define XPNTR(a) (XUINT (a) | DATA_SEG_BITS)
-#else
-#define XPNTR(a) XUINT (a)
-#endif
-#endif /* not HAVE_SHM */
-#endif /* no XPNTR */
-
 #ifndef XSET
 #define XSET(var, type, ptr) \
    ((var) = ((EMACS_INT)(type) << VALBITS) + ((EMACS_INT) (ptr) & VALMASK))
@@ -442,7 +418,6 @@ extern int pure_size;
 #endif /* EXPLICIT_SIGN_EXTEND */
 
 #define XUINT(a) ((a).u.val)
-#define XPNTR(a) ((a).u.val)
 
 #define XSET(var, vartype, ptr) \
    (((var).s.val = ((EMACS_INT) (ptr))), ((var).s.type = ((char) (vartype))))
@@ -468,10 +443,42 @@ extern Lisp_Object make_number ();
 
 #endif /* NO_UNION_TYPE */
 
+#ifndef XPNTR
+#ifdef HAVE_SHM
+/* In this representation, data is found in two widely separated segments.  */
+extern size_t pure_size;
+#define XPNTR(a) \
+  (XUINT (a) | (XUINT (a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS))
+#else /* not HAVE_SHM */
+#ifdef DATA_SEG_BITS
+/* This case is used for the rt-pc.
+   In the diffs I was given, it checked for ptr = 0
+   and did not adjust it in that case.
+   But I don't think that zero should ever be found
+   in a Lisp object whose data type says it points to something.  */
+#define XPNTR(a) (XUINT (a) | DATA_SEG_BITS)
+#else
+#define XPNTR(a) XUINT (a)
+#endif
+#endif /* not HAVE_SHM */
+#endif /* no XPNTR */
+
+/* Largest and smallest representable fixnum values.  These are the C
+   values.  */
+
+#define MOST_NEGATIVE_FIXNUM   - ((EMACS_INT) 1 << (VALBITS - 1))
+#define MOST_POSITIVE_FIXNUM   (((EMACS_INT) 1 << (VALBITS - 1)) - 1)
+
+/* Value is non-zero if C integer I doesn't fit into a Lisp fixnum.  */
+
+#define FIXNUM_OVERFLOW_P(i) \
+  ((EMACS_INT)(i) > MOST_POSITIVE_FIXNUM \
+   || (EMACS_INT) (i) < MOST_NEGATIVE_FIXNUM)
+
 /* Extract a value or address from a Lisp_Object.  */
 
 #define XCONS(a) (eassert (GC_CONSP(a)),(struct Lisp_Cons *) XPNTR(a))
-#define XVECTOR(a) ((struct Lisp_Vector *) XPNTR(a))
+#define XVECTOR(a) (eassert (GC_VECTORLIKEP(a)),(struct Lisp_Vector *) XPNTR(a))
 #define XSTRING(a) (eassert (GC_STRINGP(a)),(struct Lisp_String *) XPNTR(a))
 #define XSYMBOL(a) (eassert (GC_SYMBOLP(a)),(struct Lisp_Symbol *) XPNTR(a))
 #define XFLOAT(a) (eassert (GC_FLOATP(a)),(struct Lisp_Float *) XPNTR(a))
@@ -488,6 +495,7 @@ extern Lisp_Object make_number ();
 #define XBUFFER_LOCAL_VALUE(a) (&(XMISC(a)->u_buffer_local_value))
 #define XOVERLAY(a) (&(XMISC(a)->u_overlay))
 #define XKBOARD_OBJFWD(a) (&(XMISC(a)->u_kboard_objfwd))
+#define XSAVE_VALUE(a) (&(XMISC(a)->u_save_value))
 
 /* Pseudovector types.  */
 
@@ -532,6 +540,20 @@ extern Lisp_Object make_number ();
 #define ASET(ARRAY, IDX, VAL)  (AREF ((ARRAY), (IDX)) = (VAL))
 #define ASIZE(ARRAY)           XVECTOR ((ARRAY))->size
 
+/* Convenience macros for dealing with Lisp strings.  */
+
+#define SREF(string, index)    (XSTRING (string)->data[index] + 0)
+#define SSET(string, index, new) (XSTRING (string)->data[index] = (new))
+#define SDATA(string)          (XSTRING (string)->data + 0)
+#define SCHARS(string)         (XSTRING (string)->size + 0)
+#define SBYTES(string)         (STRING_BYTES (XSTRING (string)) + 0)
+
+#define STRING_SET_CHARS(string, newsize) \
+    (XSTRING (string)->size = (newsize))
+
+#define STRING_COPYIN(string, index, new, count) \
+    bcopy (new, XSTRING (string)->data + index, count)
+
 \f
 /* Basic data type for use of intervals.  See the macros in intervals.h.  */
 
@@ -543,7 +565,7 @@ struct interval
   unsigned int position;       /* Cache of interval's character position.  */
                                /* This field is usually updated
                                   simultaneously with an interval
-                                  traversal, there is no guaranty
+                                  traversal, there is no guarantee
                                   that it is valid for a random
                                   interval.  */
   struct interval *left;       /* Intervals which precede me.  */
@@ -570,7 +592,7 @@ struct interval
      The first four are duplicates for things which can be on the list,
      for purposes of speed.  */
 
-  unsigned int write_protect : 1;    /* Non-zero means can't modify.  */
+  unsigned int write_protect : 1;   /* Non-zero means can't modify.  */
   unsigned int visible : 1;        /* Zero means don't display.  */
   unsigned int front_sticky : 1;    /* Non-zero means text inserted just
                                       before this interval goes into it.  */
@@ -586,7 +608,7 @@ struct interval
 typedef struct interval *INTERVAL;
 
 /* Complain if object is not string or buffer type */
-#define CHECK_STRING_OR_BUFFER(x, i) \
+#define CHECK_STRING_OR_BUFFER(x) \
   { if (!STRINGP ((x)) && !BUFFERP ((x))) \
       x = wrong_type_argument (Qbuffer_or_string_p, (x)); }
 \f
@@ -604,14 +626,38 @@ struct Lisp_Cons
   };
 
 /* Take the car or cdr of something known to be a cons cell.  */
+/* The _AS_LVALUE macros shouldn't be used outside of the minimal set
+   of code that has to know what a cons cell looks like.  Other code not
+   part of the basic lisp implementation should assume that the car and cdr
+   fields are not accessible as lvalues.  (What if we want to switch to
+   a copying collector someday?  Cached cons cell field addresses may be
+   invalidated at arbitrary points.)  */
 #ifdef HIDE_LISP_IMPLEMENTATION
-#define XCAR(c) (XCONS ((c))->car_)
-#define XCDR(c) (XCONS ((c))->cdr_)
+#define XCAR_AS_LVALUE(c) (XCONS ((c))->car_)
+#define XCDR_AS_LVALUE(c) (XCONS ((c))->cdr_)
 #else
-#define XCAR(c) (XCONS ((c))->car)
-#define XCDR(c) (XCONS ((c))->cdr)
+#define XCAR_AS_LVALUE(c) (XCONS ((c))->car)
+#define XCDR_AS_LVALUE(c) (XCONS ((c))->cdr)
 #endif
 
+/* Use these from normal code.  */
+#define XCAR(c)        LISP_MAKE_RVALUE(XCAR_AS_LVALUE(c))
+#define XCDR(c) LISP_MAKE_RVALUE(XCDR_AS_LVALUE(c))
+
+/* Use these to set the fields of a cons cell.
+
+   Note that both arguments may refer to the same object, so 'n'
+   should not be read after 'c' is first modified.  Also, neither
+   argument should be evaluated more than once; side effects are
+   especially common in the second argument.  */
+#define XSETCAR(c,n) (XCAR_AS_LVALUE(c) = (n))
+#define XSETCDR(c,n) (XCDR_AS_LVALUE(c) = (n))
+
+/* For performance: Fast storage of positive integers into the
+   fields of a cons cell.  See above caveats.  */
+#define XSETCARFASTINT(c,n)  XSETFASTINT(XCAR_AS_LVALUE(c),(n))
+#define XSETCDRFASTINT(c,n)  XSETFASTINT(XCDR_AS_LVALUE(c),(n))
+
 /* Take the car or cdr of something whose type is not known.  */
 #define CAR(c)                                 \
  (CONSP ((c)) ? XCAR ((c))                     \
@@ -642,8 +688,14 @@ extern int string_bytes P_ ((struct Lisp_String *));
 
 #endif /* not GC_CHECK_STRING_BYTES */
 
-/* Set the length in bytes of STR.  */
-#define SET_STRING_BYTES(STR, SIZE)  ((STR)->size_byte = (SIZE))
+/* Mark STR as a unibyte string.  */
+#define STRING_SET_UNIBYTE(STR)      (XSTRING (STR)->size_byte = -1)
+
+/* Get text properties.  */
+#define STRING_INTERVALS(STR)  (XSTRING (STR)->intervals + 0)
+
+/* Set text properties.  */
+#define STRING_SET_INTERVALS(STR, INT) (XSTRING (STR)->intervals = (INT))
 
 /* In a string or vector, the sign bit of the `size' is the gc mark bit */
 
@@ -788,18 +840,6 @@ struct Lisp_Bool_Vector
     unsigned char data[1];
   };
 
-/* In a symbol, the markbit of the plist is used as the gc mark bit */
-
-struct Lisp_Symbol
-  {
-    struct Lisp_String *name;
-    Lisp_Object value;
-    Lisp_Object function;
-    Lisp_Object plist;
-    Lisp_Object obarray;
-    struct Lisp_Symbol *next;  /* -> next symbol in this obarray bucket */
-  };
-
 /* This structure describes a built-in function.
    It is generated by the DEFUN macro only.
    defsubr makes it into a Lisp object.
@@ -819,6 +859,97 @@ struct Lisp_Subr
   };
 
 \f
+/***********************************************************************
+                              Symbols
+ ***********************************************************************/
+
+/* Interned state of a symbol.  */
+
+enum symbol_interned
+{
+  SYMBOL_UNINTERNED = 0,
+  SYMBOL_INTERNED = 1,
+  SYMBOL_INTERNED_IN_INITIAL_OBARRAY = 2
+};
+
+/* In a symbol, the markbit of the plist is used as the gc mark bit */
+
+struct Lisp_Symbol
+{
+  /* Non-zero means symbol serves as a variable alias.  The symbol
+     holding the real value is found in the value slot.  */
+  unsigned indirect_variable : 1;
+
+  /* Non-zero means symbol is constant, i.e. changing its value
+     should signal an error.  */
+  unsigned constant : 1;
+
+  /* Interned state of the symbol.  This is an enumerator from
+     enum symbol_interned.  */
+  unsigned interned : 2;
+
+  /* The symbol's name, as a Lisp string.
+
+     The name "xname" is used to intentionally break code referring to
+     the old field "name" of type pointer to struct Lisp_String.  */
+  Lisp_Object xname;
+
+  /* Value of the symbol or Qunbound if unbound.  If this symbol is a
+     defvaralias, `value' contains the symbol for which it is an
+     alias.  Use the SYMBOL_VALUE and SET_SYMBOL_VALUE macros to get
+     and set a symbol's value, to take defvaralias into account.  */
+  Lisp_Object value;
+
+  /* Function value of the symbol or Qunbound if not fboundp.  */
+  Lisp_Object function;
+
+  /* The symbol's property list.  */
+  Lisp_Object plist;
+
+  /* Next symbol in obarray bucket, if the symbol is interned.  */
+  struct Lisp_Symbol *next;
+};
+
+/* Value is name of symbol.  */
+
+#define SYMBOL_NAME(sym)  \
+     LISP_MAKE_RVALUE (XSYMBOL (sym)->xname)
+
+/* Value is non-zero if SYM is an interned symbol.  */
+
+#define SYMBOL_INTERNED_P(sym)  \
+     (XSYMBOL (sym)->interned != SYMBOL_UNINTERNED)
+
+/* Value is non-zero if SYM is interned in initial_obarray.  */
+
+#define SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P(sym) \
+     (XSYMBOL (sym)->interned == SYMBOL_INTERNED_IN_INITIAL_OBARRAY)
+
+/* Value is non-zero if symbol is considered a constant, i.e. its
+   value cannot be changed (there is an exception for keyword symbols,
+   whose value can be set to the keyword symbol itself).  */
+
+#define SYMBOL_CONSTANT_P(sym)   XSYMBOL (sym)->constant
+
+/* Value is the value of SYM, with defvaralias taken into
+   account.  */
+
+#define SYMBOL_VALUE(sym)                      \
+   (XSYMBOL (sym)->indirect_variable           \
+    ? XSYMBOL (indirect_variable (sym))->value \
+    : XSYMBOL (sym)->value)
+
+/* Set SYM's value to VAL, taking defvaralias into account.  */
+
+#define SET_SYMBOL_VALUE(sym, val)                             \
+     do {                                                      \
+       if (XSYMBOL (sym)->indirect_variable)                   \
+        XSYMBOL (indirect_variable ((sym)))->value = (val);    \
+       else                                                    \
+        XSYMBOL (sym)->value = (val);                          \
+     } while (0)
+
+\f
 /***********************************************************************
                             Hash Tables
  ***********************************************************************/
@@ -830,14 +961,14 @@ struct Lisp_Hash_Table
   /* Vector fields.  The hash table code doesn't refer to these.  */
   EMACS_INT size;
   struct Lisp_Vector *vec_next;
-  
+
   /* Function used to compare keys.  */
   Lisp_Object test;
 
   /* Nil if table is non-weak.  Otherwise a symbol describing the
      weakness of the table.  */
   Lisp_Object weak;
-  
+
   /* When the table is resized, and this is an integer, compute the
      new size by adding this to the old size.  If a float, compute the
      new size by multiplying the old size with this factor.  */
@@ -899,7 +1030,7 @@ struct Lisp_Hash_Table
 #define HASH_TABLE_P(OBJ)  PSEUDOVECTORP (OBJ, PVEC_HASH_TABLE)
 #define GC_HASH_TABLE_P(x) GC_PSEUDOVECTORP (x, PVEC_HASH_TABLE)
 
-#define CHECK_HASH_TABLE(x, i)                                 \
+#define CHECK_HASH_TABLE(x)                                    \
      do                                                                \
        {                                                       \
         if (!HASH_TABLE_P ((x)))                               \
@@ -907,6 +1038,32 @@ struct Lisp_Hash_Table
        }                                                       \
      while (0)
 
+/* Value is the key part of entry IDX in hash table H.  */
+
+#define HASH_KEY(H, IDX)   AREF ((H)->key_and_value, 2 * (IDX))
+
+/* Value is the value part of entry IDX in hash table H.  */
+
+#define HASH_VALUE(H, IDX) AREF ((H)->key_and_value, 2 * (IDX) + 1)
+
+/* Value is the index of the next entry following the one at IDX
+   in hash table H.  */
+
+#define HASH_NEXT(H, IDX)  AREF ((H)->next, (IDX))
+
+/* Value is the hash code computed for entry IDX in hash table H.  */
+
+#define HASH_HASH(H, IDX)  AREF ((H)->hash, (IDX))
+
+/* Value is the index of the element in hash table H that is the
+   start of the collision list at index IDX in the index vector of H.  */
+
+#define HASH_INDEX(H, IDX)  AREF ((H)->index, (IDX))
+
+/* Value is the size of hash table H.  */
+
+#define HASH_TABLE_SIZE(H) XVECTOR ((H)->next)->size
+
 /* Default size for hash tables if not specified.  */
 
 #define DEFAULT_HASH_SIZE 65
@@ -964,7 +1121,7 @@ struct Lisp_Intfwd
   {
     int type : 16;     /* = Lisp_Misc_Intfwd */
     int spacer : 16;
-    int *intvar;
+    EMACS_INT *intvar;
   };
 
 /* Boolean forwarding pointer to an int variable.
@@ -1009,7 +1166,7 @@ struct Lisp_Buffer_Objfwd
    one that corresponds to the loaded binding.  To read or set the
    variable, you must first make sure the right binding is loaded;
    then you can access the value in (or through) `realvalue'.
-   
+
    `buffer' and `frame' are the buffer and frame for which the loaded
    binding was found.  If those have changed, to make sure the right
    binding is loaded it is necessary to find which binding goes with
@@ -1077,6 +1234,16 @@ struct Lisp_Kboard_Objfwd
     int offset;
   };
 
+/* Hold a C pointer for later use.
+   This type of object is used in the arg to record_unwind_protect.  */
+struct Lisp_Save_Value
+  {
+    int type : 16;     /* = Lisp_Misc_Save_Value */
+    int spacer : 16;
+    void *pointer;
+    int integer;
+  };
+
 
 /* To get the type field of a union Lisp_Misc, use XMISCTYPE.
    It uses one of these struct subtypes to get the type field.  */
@@ -1092,6 +1259,7 @@ union Lisp_Misc
     struct Lisp_Buffer_Local_Value u_buffer_local_value;
     struct Lisp_Overlay u_overlay;
     struct Lisp_Kboard_Objfwd u_kboard_objfwd;
+    struct Lisp_Save_Value u_save_value;
   };
 \f
 /* Lisp floating point type */
@@ -1222,8 +1390,7 @@ typedef unsigned char UCHAR;
 #define GLYPH_FACE(f, g) (FAST_GLYPH_FACE (g))
 
 /* Return 1 iff GLYPH contains valid character code.  */
-#define GLYPH_CHAR_VALID_P(glyph) \
-  ((GLYPH) (FAST_GLYPH_CHAR (glyph)) <= MAX_CHAR)
+#define GLYPH_CHAR_VALID_P(glyph) CHAR_VALID_P (FAST_GLYPH_CHAR (glyph), 1)
 
 /* The ID of the mode line highlighting face.  */
 #define GLYPH_MODE_LINE_FACE 1
@@ -1313,34 +1480,37 @@ typedef unsigned char UCHAR;
 #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) \
+#define CHECK_LIST(x) \
   do { if (!CONSP ((x)) && !NILP (x)) x = wrong_type_argument (Qlistp, (x)); } while (0)
 
-#define CHECK_STRING(x, i) \
+#define CHECK_STRING(x) \
   do { if (!STRINGP ((x))) x = wrong_type_argument (Qstringp, (x)); } while (0)
 
-#define CHECK_CONS(x, i) \
+#define CHECK_STRING_CAR(x) \
+  do { if (!STRINGP (XCAR (x))) XSETCAR (x, wrong_type_argument (Qstringp, XCAR (x))); } while (0)
+
+#define CHECK_CONS(x) \
   do { if (!CONSP ((x))) x = wrong_type_argument (Qconsp, (x)); } while (0)
 
-#define CHECK_SYMBOL(x, i) \
+#define CHECK_SYMBOL(x) \
   do { if (!SYMBOLP ((x))) x = wrong_type_argument (Qsymbolp, (x)); } while (0)
 
-#define CHECK_CHAR_TABLE(x, i) \
+#define CHECK_CHAR_TABLE(x) \
   do { if (!CHAR_TABLE_P ((x)))        \
         x = wrong_type_argument (Qchar_table_p, (x)); } while (0)
 
-#define CHECK_VECTOR(x, i) \
+#define CHECK_VECTOR(x) \
   do { if (!VECTORP ((x))) x = wrong_type_argument (Qvectorp, (x)); } while (0)
 
-#define CHECK_VECTOR_OR_CHAR_TABLE(x, i)                               \
+#define CHECK_VECTOR_OR_CHAR_TABLE(x)                          \
   do { if (!VECTORP ((x)) && !CHAR_TABLE_P ((x)))                      \
         x = wrong_type_argument (Qvector_or_char_table_p, (x));        \
      } while (0)
 
-#define CHECK_BUFFER(x, i) \
+#define CHECK_BUFFER(x) \
   do { if (!BUFFERP ((x))) x = wrong_type_argument (Qbufferp, (x)); } while (0)
 
-#define CHECK_WINDOW(x, i) \
+#define CHECK_WINDOW(x) \
   do { if (!WINDOWP ((x))) x = wrong_type_argument (Qwindowp, (x)); } while (0)
 
 /* This macro rejects windows on the interior of the window tree as
@@ -1350,47 +1520,63 @@ typedef unsigned char UCHAR;
    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)                                \
+#define CHECK_LIVE_WINDOW(x)                           \
   do {                                                 \
     if (!WINDOWP ((x))                                 \
        || NILP (XWINDOW ((x))->buffer))                \
       x = wrong_type_argument (Qwindow_live_p, (x));   \
   } while (0)
 
-#define CHECK_PROCESS(x, i) \
+#define CHECK_PROCESS(x) \
   do { if (!PROCESSP ((x))) x = wrong_type_argument (Qprocessp, (x)); } while (0)
 
-#define CHECK_NUMBER(x, i) \
+#define CHECK_NUMBER(x) \
   do { if (!INTEGERP ((x))) x = wrong_type_argument (Qintegerp, (x)); } while (0)
 
-#define CHECK_NATNUM(x, i) \
+#define CHECK_NATNUM(x) \
   do { if (!NATNUMP (x)) x = wrong_type_argument (Qwholenump, (x)); } while (0)
 
-#define CHECK_MARKER(x, i) \
+#define CHECK_MARKER(x) \
   do { if (!MARKERP ((x))) x = wrong_type_argument (Qmarkerp, (x)); } while (0)
 
-#define CHECK_NUMBER_COERCE_MARKER(x, i) \
+#define CHECK_NUMBER_COERCE_MARKER(x) \
   do { if (MARKERP ((x))) XSETFASTINT (x, marker_position (x)); \
     else if (!INTEGERP ((x))) x = wrong_type_argument (Qinteger_or_marker_p, (x)); } while (0)
 
 #define XFLOATINT(n) extract_float((n))
 
-#define CHECK_FLOAT(x, i)              \
+#define CHECK_FLOAT(x)         \
   do { if (!FLOATP (x))                        \
     x = wrong_type_argument (Qfloatp, (x)); } while (0)
 
-#define CHECK_NUMBER_OR_FLOAT(x, i)    \
+#define CHECK_NUMBER_OR_FLOAT(x)       \
   do { if (!FLOATP (x) && !INTEGERP (x))       \
     x = wrong_type_argument (Qnumberp, (x)); } while (0)
 
-#define CHECK_NUMBER_OR_FLOAT_COERCE_MARKER(x, i) \
+#define CHECK_NUMBER_OR_FLOAT_COERCE_MARKER(x) \
   do { if (MARKERP (x)) XSETFASTINT (x, marker_position (x));  \
   else if (!INTEGERP (x) && !FLOATP (x))               \
     x = wrong_type_argument (Qnumber_or_marker_p, (x)); } while (0)
 
-#define CHECK_OVERLAY(x, i) \
+#define CHECK_OVERLAY(x) \
   do { if (!OVERLAYP ((x))) x = wrong_type_argument (Qoverlayp, (x));} while (0)
 
+/* Since we can't assign directly to the CAR or CDR fields of a cons
+   cell, use these when checking that those fields contain numbers.  */
+#define CHECK_NUMBER_CAR(x) \
+  do {                                 \
+    Lisp_Object tmp = XCAR (x);                \
+    CHECK_NUMBER (tmp);                        \
+    XSETCAR ((x), tmp);                        \
+  } while (0)
+
+#define CHECK_NUMBER_CDR(x) \
+  do {                                 \
+    Lisp_Object tmp = XCDR (x);                \
+    CHECK_NUMBER (tmp);                        \
+    XSETCDR ((x), tmp);                        \
+  } while (0)
+
 /* Cast pointers to this type to compare them.  Some machines want int.  */
 #ifndef PNTR_COMPARISON_TYPE
 #define PNTR_COMPARISON_TYPE EMACS_UINT
@@ -1420,6 +1606,7 @@ typedef unsigned char UCHAR;
 
 #if (!defined (__STDC__) && !defined (PROTOTYPES)) \
     || defined (USE_NONANSI_DEFUN)
+
 #define DEFUN(lname, fnname, sname, minargs, maxargs, prompt, doc)     \
   Lisp_Object fnname ();                                               \
   struct Lisp_Subr sname =                                             \
@@ -1464,9 +1651,9 @@ typedef unsigned char UCHAR;
       || (SYMBOLP (OBJ) && !NILP (Ffboundp (OBJ)))     \
       || COMPILEDP (OBJ)                               \
       || SUBRP (OBJ))
-     
+
 /* defsubr (Sname);
- is how we define the symbol for function `name' at start-up time.  */
  is how we define the symbol for function `name' at start-up time.  */
 extern void defsubr P_ ((struct Lisp_Subr *));
 
 #define MANY -2
@@ -1475,7 +1662,7 @@ extern void defsubr P_ ((struct Lisp_Subr *));
 extern void defvar_lisp P_ ((char *, Lisp_Object *));
 extern void defvar_lisp_nopro P_ ((char *, Lisp_Object *));
 extern void defvar_bool P_ ((char *, int *));
-extern void defvar_int P_ ((char *, int *));
+extern void defvar_int P_ ((char *, EMACS_INT *));
 extern void defvar_per_buffer P_ ((char *, Lisp_Object *, Lisp_Object, char *));
 extern void defvar_kboard P_ ((char *, int));
 
@@ -1492,6 +1679,8 @@ extern void defvar_kboard P_ ((char *, int));
  defvar_kboard (lname, \
                (int)((char *)(&current_kboard->vname) \
                      - (char *)current_kboard))
+
+
 \f
 /* Structure for recording Lisp call stack for backtrace purposes.  */
 
@@ -1507,12 +1696,15 @@ extern void defvar_kboard P_ ((char *, int));
       form.
 
    Otherwise, the element is a variable binding.
+
    If the symbol field is a symbol, it is an ordinary variable binding.
-   Otherwise, it should be a structure (SYMBOL BUFFER . BUFFER),
-   which represents having bound BUFFER's local value,
-   or (SYMBOL nil . BUFFER), which represents having bound the default
-   value when BUFFER was current (buffer not having any local binding
-   for SYMBOL).  */
+
+   Otherwise, it should be a structure (SYMBOL WHERE
+   . CURRENT-BUFFER), which means having bound a local value while
+   CURRENT-BUFFER was active.  If WHERE is nil this means we saw the
+   default value when binding SYMBOL.  WHERE being a buffer or frame
+   means we saw a buffer-local or frame-local value.  Other values of
+   WHERE mean an internal error.  */
 
 struct specbinding
   {
@@ -1525,12 +1717,20 @@ extern struct specbinding *specpdl;
 extern struct specbinding *specpdl_ptr;
 extern int specpdl_size;
 
-#define BINDING_STACK_SIZE()   (specpdl_ptr - specpdl)
+extern EMACS_INT max_specpdl_size;
+
+#define SPECPDL_INDEX()        (specpdl_ptr - specpdl)
 
 /* Everything needed to describe an active condition case.  */
 struct handler
   {
     /* The handler clauses and variable from the condition-case form.  */
+    /* For a handler set up in Lisp code, this is always a list.
+       For an internal handler set up by internal_condition_case*,
+       this can instead be the symbol t or `error'.
+       t: handle all conditions.
+       error: handle all conditions, and errors can run the debugger
+              or display a backtrace.  */
     Lisp_Object handler;
     Lisp_Object var;
     /* Fsignal stores here the condition-case clause that applies,
@@ -1633,7 +1833,7 @@ extern int consing_since_gc;
 
 /* Threshold for doing another gc.  */
 
-extern int gc_cons_threshold;
+extern EMACS_INT gc_cons_threshold;
 
 /* Structure for recording stack slots that need marking.  */
 
@@ -1653,13 +1853,13 @@ extern struct gcpro *gcprolist;
 struct gcpro
 {
   struct gcpro *next;
-  
+
   /* Address of first protected variable.  */
   volatile Lisp_Object *var;
-  
+
   /* Number of consecutive protected variables.  */
   int nvars;
-  
+
 #ifdef DEBUG_GCPRO
   int level;
 #endif
@@ -1686,11 +1886,19 @@ struct gcpro
 
 #if GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS
 
-#define GCPRO1(varname) ((void) 0)
-#define GCPRO2(varname1, varname2)((void) 0) 
-#define GCPRO3(varname1, varname2, varname3) ((void) 0) 
-#define GCPRO4(varname1, varname2, varname3, varname4) ((void) 0)
-#define GCPRO5(varname1, varname2, varname3, varname4, varname5) ((void) 0)
+/* Do something silly with gcproN vars just so gcc shuts up.  */
+/* You get warnings from MIPSPro...  */
+
+#define GCPRO1(varname) ((void) gcpro1)
+#define GCPRO2(varname1, varname2)(((void) gcpro2, (void) gcpro1))
+#define GCPRO3(varname1, varname2, varname3) \
+  (((void) gcpro3, (void) gcpro2, (void) gcpro1))
+#define GCPRO4(varname1, varname2, varname3, varname4) \
+  (((void) gcpro4, (void) gcpro3, (void) gcpro2, (void) gcpro1))
+#define GCPRO5(varname1, varname2, varname3, varname4, varname5) \
+  (((void) gcpro5, (void) gcpro4, (void) gcpro3, (void) gcpro2, (void) gcpro1))
+#define GCPRO6(varname1, varname2, varname3, varname4, varname5, varname6) \
+  (((void) gcpro6, (void) gcpro5, (void) gcpro4, (void) gcpro3, (void) gcpro2, (void) gcpro1))
 #define UNGCPRO ((void) 0)
 
 #else /* GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS */
@@ -1727,6 +1935,15 @@ struct gcpro
   gcpro5.next = &gcpro4; gcpro5.var = &varname5; gcpro5.nvars = 1; \
   gcprolist = &gcpro5; }
 
+#define GCPRO6(varname1, varname2, varname3, varname4, varname5, varname6) \
+ {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
+  gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
+  gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
+  gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
+  gcpro5.next = &gcpro4; gcpro5.var = &varname5; gcpro5.nvars = 1; \
+  gcpro6.next = &gcpro5; gcpro6.var = &varname6; gcpro6.nvars = 1; \
+  gcprolist = &gcpro6; }
+
 #define UNGCPRO (gcprolist = gcpro1.next)
 
 #else
@@ -1772,6 +1989,17 @@ extern int gcpro_level;
   gcpro5.level = gcpro_level++; \
   gcprolist = &gcpro5; }
 
+#define GCPRO6(varname1, varname2, varname3, varname4, varname5, varname6) \
+ {gcpro1.next = gcprolist; gcpro1.var = &varname1; gcpro1.nvars = 1; \
+  gcpro1.level = gcpro_level; \
+  gcpro2.next = &gcpro1; gcpro2.var = &varname2; gcpro2.nvars = 1; \
+  gcpro3.next = &gcpro2; gcpro3.var = &varname3; gcpro3.nvars = 1; \
+  gcpro4.next = &gcpro3; gcpro4.var = &varname4; gcpro4.nvars = 1; \
+  gcpro5.next = &gcpro4; gcpro5.var = &varname5; gcpro5.nvars = 1; \
+  gcpro6.next = &gcpro5; gcpro6.var = &varname6; gcpro6.nvars = 1; \
+  gcpro6.level = gcpro_level++; \
+  gcprolist = &gcpro6; }
+
 #define UNGCPRO                                        \
  ((--gcpro_level != gcpro1.level)              \
   ? (abort (), 0)                              \
@@ -1841,6 +2069,8 @@ extern Lisp_Object Qfloatp, Qinteger_or_floatp, Qinteger_or_float_or_marker_p;
 
 extern Lisp_Object Qframep;
 
+extern void circular_list_error P_ ((Lisp_Object));
+
 EXFUN (Feq, 2);
 EXFUN (Fnull, 1);
 EXFUN (Flistp, 1);
@@ -1921,6 +2151,7 @@ EXFUN (Fadd1, 1);
 EXFUN (Fsub1, 1);
 EXFUN (Fmake_variable_buffer_local, 1);
 
+extern Lisp_Object indirect_variable P_ ((Lisp_Object));
 extern Lisp_Object long_to_cons P_ ((unsigned long));
 extern unsigned long cons_to_long P_ ((Lisp_Object));
 extern void args_out_of_range P_ ((Lisp_Object, Lisp_Object));
@@ -1949,10 +2180,11 @@ EXFUN (Fcheck_coding_system, 1);
 EXFUN (Fread_coding_system, 2);
 EXFUN (Fread_non_nil_coding_system, 1);
 EXFUN (Ffind_operation_coding_system, MANY);
+EXFUN (Fupdate_coding_systems_internal, 0);
 EXFUN (Fencode_coding_string, 3);
 EXFUN (Fdecode_coding_string, 3);
-extern Lisp_Object detect_coding_system P_ ((unsigned char *, int, int, int));
-Lisp_Object code_convert_string_norecord P_ ((Lisp_Object, Lisp_Object, int));
+extern Lisp_Object detect_coding_system P_ ((const unsigned char *, int, int,
+                                            int));
 extern void init_coding P_ ((void));
 extern void init_coding_once P_ ((void));
 extern void syms_of_coding P_ ((void));
@@ -1960,13 +2192,13 @@ extern Lisp_Object code_convert_string_norecord P_ ((Lisp_Object, Lisp_Object,
                                                     int));
 
 /* Defined in charset.c */
-extern int nonascii_insert_offset;
+extern EMACS_INT nonascii_insert_offset;
 extern Lisp_Object Vnonascii_translation_table;
 EXFUN (Fchar_bytes, 1);
 EXFUN (Fchar_width, 1);
 EXFUN (Fstring, MANY);
-extern int chars_in_text P_ ((unsigned char *, int));
-extern int multibyte_chars_in_text P_ ((unsigned char *, int));
+extern int chars_in_text P_ ((const unsigned char *, int));
+extern int multibyte_chars_in_text P_ ((const unsigned char *, int));
 extern int unibyte_char_to_multibyte P_ ((int));
 extern int multibyte_char_to_unibyte P_ ((int, Lisp_Object));
 extern Lisp_Object Qcharset;
@@ -2056,9 +2288,8 @@ EXFUN (Fmapcar, 2);
 EXFUN (Fmapconcat, 3);
 EXFUN (Fy_or_n_p, 1);
 extern Lisp_Object do_yes_or_no_p P_ ((Lisp_Object));
-EXFUN (Ffeaturep, 1);
 EXFUN (Frequire, 3);
-EXFUN (Fprovide, 1);
+EXFUN (Fprovide, 2);
 extern Lisp_Object concat2 P_ ((Lisp_Object, Lisp_Object));
 extern Lisp_Object concat3 P_ ((Lisp_Object, Lisp_Object, Lisp_Object));
 extern Lisp_Object nconc2 P_ ((Lisp_Object, Lisp_Object));
@@ -2071,6 +2302,7 @@ extern Lisp_Object string_make_unibyte P_ ((Lisp_Object));
 EXFUN (Fcopy_alist, 1);
 EXFUN (Fplist_get, 2);
 EXFUN (Fplist_put, 3);
+EXFUN (Fplist_member, 2);
 EXFUN (Fset_char_table_parent, 2);
 EXFUN (Fchar_table_extra_slot, 2);
 EXFUN (Fset_char_table_extra_slot, 3);
@@ -2093,23 +2325,24 @@ extern void init_floatfns P_ ((void));
 extern void syms_of_floatfns P_ ((void));
 
 /* Defined in insdel.c */
+extern Lisp_Object Qinhibit_modification_hooks;
 extern void move_gap P_ ((int));
 extern void move_gap_both P_ ((int, int));
 extern void make_gap P_ ((int));
-extern int copy_text P_ ((unsigned char *, unsigned char *, int, int, int));
-extern int count_size_as_multibyte P_ ((unsigned char *, int));
-extern int count_combining_before P_ ((unsigned char *, int, int, int));
-extern int count_combining_after P_ ((unsigned char *, int, int, int));
-extern void insert P_ ((unsigned char *, int));
-extern void insert_and_inherit P_ ((unsigned char *, int));
-extern void insert_1 P_ ((unsigned char *, int, int, int, int));
-extern void insert_1_both P_ ((unsigned char *, int, int, int, int, int));
+extern int copy_text P_ ((const unsigned char *, unsigned char *, int, int, int));
+extern int count_size_as_multibyte P_ ((const unsigned char *, int));
+extern int count_combining_before P_ ((const unsigned char *, int, int, int));
+extern int count_combining_after P_ ((const unsigned char *, int, int, int));
+extern void insert P_ ((const unsigned char *, int));
+extern void insert_and_inherit P_ ((const unsigned char *, int));
+extern void insert_1 P_ ((const unsigned char *, int, int, int, int));
+extern void insert_1_both P_ ((const unsigned char *, int, int, int, int, int));
 extern void insert_from_string P_ ((Lisp_Object, int, int, int, int, int));
 extern void insert_from_buffer P_ ((struct buffer *, int, int, int));
 extern void insert_char P_ ((int));
-extern void insert_string P_ ((char *));
-extern void insert_before_markers P_ ((unsigned char *, int));
-extern void insert_before_markers_and_inherit P_ ((unsigned char *, int));
+extern void insert_string P_ ((const char *));
+extern void insert_before_markers P_ ((const unsigned char *, int));
+extern void insert_before_markers_and_inherit P_ ((const unsigned char *, int));
 extern void insert_from_string_before_markers P_ ((Lisp_Object, int, int, int, int, int));
 extern void del_range P_ ((int, int));
 extern Lisp_Object del_range_1 P_ ((int, int, int, int));
@@ -2121,12 +2354,14 @@ extern void prepare_to_modify_buffer P_ ((int, int, int *));
 extern void signal_before_change P_ ((int, int, int *));
 extern void signal_after_change P_ ((int, int, int));
 extern void adjust_after_replace P_ ((int, int, Lisp_Object, int, int));
+extern void adjust_after_replace_noundo P_ ((int, int, int, int, int, int));
 extern void adjust_after_insert P_ ((int, int, int, int, int));
 extern void replace_range P_ ((int, int, Lisp_Object, int, int, int));
 extern void syms_of_insdel P_ ((void));
 
 /* Defined in dispnew.c */
 extern Lisp_Object selected_frame;
+extern EMACS_INT baud_rate;
 EXFUN (Fding, 1);
 EXFUN (Fredraw_frame, 1);
 EXFUN (Fredraw_display, 0);
@@ -2135,11 +2370,12 @@ EXFUN (Fsit_for, 3);
 extern Lisp_Object sit_for P_ ((int, int, int, int, int));
 extern void init_display P_ ((void));
 extern void syms_of_display P_ ((void));
-extern void safe_bcopy P_ ((char *, char *, int));
+extern void safe_bcopy P_ ((const char *, char *, int));
 
 /* Defined in xdisp.c */
 extern Lisp_Object Qinhibit_point_motion_hooks;
 extern Lisp_Object Qinhibit_redisplay, Qdisplay;
+extern Lisp_Object Qinhibit_eval_during_redisplay;
 extern Lisp_Object Qmessage_truncate_lines;
 extern Lisp_Object Vmessage_log_max;
 extern int message_enable_multibyte;
@@ -2147,21 +2383,22 @@ extern Lisp_Object echo_area_buffer[2];
 extern void check_message_stack P_ ((void));
 extern void setup_echo_area_for_printing P_ ((int));
 extern int push_message P_ ((void));
-extern Lisp_Object push_message_unwind P_ ((Lisp_Object));
+extern Lisp_Object pop_message_unwind P_ ((Lisp_Object));
+extern Lisp_Object restore_message_unwind P_ ((Lisp_Object));
 extern void pop_message P_ ((void));
 extern void restore_message P_ ((void));
 extern Lisp_Object current_message P_ ((void));
-extern void set_message P_ ((char *s, Lisp_Object, int, int));
+extern void set_message P_ ((const char *s, Lisp_Object, int, int));
 extern void clear_message P_ ((int, int));
 extern void message P_ ((/* char *, ... */));
 extern void message_nolog P_ ((/* char *, ... */));
 extern void message1 P_ ((char *));
 extern void message1_nolog P_ ((char *));
-extern void message2 P_ ((char *, int, int));
-extern void message2_nolog P_ ((char *, int, int));
+extern void message2 P_ ((const char *, int, int));
+extern void message2_nolog P_ ((const char *, int, int));
 extern void message3 P_ ((Lisp_Object, int, int));
 extern void message3_nolog P_ ((Lisp_Object, int, int));
-extern void message_dolog P_ ((char *, int, int, int));
+extern void message_dolog P_ ((const char *, int, int, int));
 extern void message_with_string P_ ((char *, Lisp_Object, int));
 extern void message_log_maybe_newline P_ ((void));
 extern void update_echo_area P_ ((void));
@@ -2171,8 +2408,9 @@ extern int check_point_in_composition
        P_ ((struct buffer *, int, struct buffer *, int));
 extern void redisplay_preserve_echo_area P_ ((int));
 extern void mark_window_display_accurate P_ ((Lisp_Object, int));
-extern int invisible_p P_ ((Lisp_Object, Lisp_Object));
 extern void prepare_menu_bars P_ ((void));
+
+void set_frame_cursor_types P_ ((struct frame *, Lisp_Object));
 extern void syms_of_xdisp P_ ((void));
 extern void init_xdisp P_ ((void));
 extern Lisp_Object safe_eval P_ ((Lisp_Object));
@@ -2182,6 +2420,7 @@ extern int pos_visible_p P_ ((struct window *, int, int *, int));
 extern void memory_warnings P_ ((POINTER_TYPE *, void (*warnfun) ()));
 
 /* Defined in alloc.c */
+extern void check_pure_size P_ ((void));
 extern void allocate_string_data P_ ((struct Lisp_String *, int, int));
 extern void uninterrupt_malloc P_ ((void));
 extern void malloc_warning P_ ((char *));
@@ -2190,6 +2429,7 @@ extern void buffer_memory_full P_ ((void));
 extern int survives_gc_p P_ ((Lisp_Object));
 extern void mark_object P_ ((Lisp_Object *));
 extern Lisp_Object Vpurify_flag;
+extern Lisp_Object Vmemory_full;
 EXFUN (Fcons, 2);
 EXFUN (list2, 2);
 EXFUN (list3, 3);
@@ -2203,10 +2443,10 @@ EXFUN (Fvector, MANY);
 EXFUN (Fmake_symbol, 1);
 EXFUN (Fmake_marker, 0);
 EXFUN (Fmake_string, 2);
-extern Lisp_Object build_string P_ ((char *));
-extern Lisp_Object make_string P_ ((char *, int));
-extern Lisp_Object make_unibyte_string P_ ((char *, int));
-extern Lisp_Object make_multibyte_string P_ ((char *, int, int));
+extern Lisp_Object build_string P_ ((const char *));
+extern Lisp_Object make_string P_ ((const char *, int));
+extern Lisp_Object make_unibyte_string P_ ((const char *, int));
+extern Lisp_Object make_multibyte_string P_ ((const char *, int, int));
 extern Lisp_Object make_event_array P_ ((int, Lisp_Object *));
 extern Lisp_Object make_uninit_string P_ ((int));
 extern Lisp_Object make_uninit_multibyte_string P_ ((int, int));
@@ -2232,6 +2472,7 @@ extern int gc_in_progress;
 extern Lisp_Object make_float P_ ((double));
 extern void display_malloc_warning P_ ((void));
 extern int inhibit_garbage_collection P_ ((void));
+extern Lisp_Object make_save_value P_ ((void *, int));
 extern void free_marker P_ ((Lisp_Object));
 extern void free_cons P_ ((struct Lisp_Cons *));
 extern void init_alloc_once P_ ((void));
@@ -2250,14 +2491,14 @@ EXFUN (Fprint, 2);
 EXFUN (Ferror_message_string, 1);
 extern Lisp_Object Vstandard_output, Qstandard_output;
 extern Lisp_Object Qexternal_debugging_output;
-extern void temp_output_buffer_setup P_ ((char *));
+extern void temp_output_buffer_setup P_ ((const char *));
 extern int print_level, print_escape_newlines;
 extern Lisp_Object Qprint_escape_newlines;
 extern void write_string P_ ((char *, int));
 extern void write_string_1 P_ ((char *, int, Lisp_Object));
-extern void print_error_message P_ ((Lisp_Object, Lisp_Object));
+extern void print_error_message P_ ((Lisp_Object, Lisp_Object, char *, Lisp_Object));
 extern Lisp_Object internal_with_output_to_temp_buffer
-       P_ ((char *, Lisp_Object (*) (Lisp_Object), Lisp_Object));
+       P_ ((const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object));
 extern void float_to_string P_ ((unsigned char *, double));
 extern void syms_of_print P_ ((void));
 
@@ -2278,14 +2519,15 @@ EXFUN (Fread_char, 2);
 EXFUN (Fread_event, 2);
 extern Lisp_Object read_filtered_event P_ ((int, int, int, int));
 EXFUN (Feval_region, 4);
-extern Lisp_Object intern P_ ((char *));
+extern Lisp_Object intern P_ ((const char *));
 extern Lisp_Object make_symbol P_ ((char *));
-extern Lisp_Object oblookup P_ ((Lisp_Object, char *, int, int));
+extern Lisp_Object oblookup P_ ((Lisp_Object, const char *, int, int));
 #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;
-extern int openp P_ ((Lisp_Object, Lisp_Object, char *, Lisp_Object *, int));
+extern Lisp_Object Vload_history, Vload_suffixes;
+extern int openp P_ ((Lisp_Object, Lisp_Object, Lisp_Object,
+                     Lisp_Object *, Lisp_Object));
 extern int isfloat_string P_ ((char *));
 extern void map_obarray P_ ((Lisp_Object, void (*) (Lisp_Object, Lisp_Object),
                             Lisp_Object));
@@ -2298,7 +2540,6 @@ extern void syms_of_lread P_ ((void));
 /* 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;
 extern Lisp_Object Vdebug_on_error;
 extern Lisp_Object Vsignaling_function;
@@ -2339,7 +2580,7 @@ EXFUN (Funwind_protect, UNEVALLED);
 EXFUN (Fcondition_case, UNEVALLED);
 EXFUN (Fsignal, 2);
 EXFUN (Fautoload, 5);
-EXFUN (Fcommandp, 1);
+EXFUN (Fcommandp, 2);
 EXFUN (Feval, 1);
 EXFUN (Fapply, MANY);
 EXFUN (Ffuncall, MANY);
@@ -2372,6 +2613,7 @@ extern void init_eval P_ ((void));
 extern void syms_of_eval P_ ((void));
 
 /* Defined in editfns.c */
+EXFUN (Fpropertize, MANY);
 EXFUN (Fcurrent_message, 0);
 EXFUN (Fgoto_char, 1);
 EXFUN (Fpoint_min_marker, 0);
@@ -2398,7 +2640,7 @@ EXFUN (Fbolp, 0);
 EXFUN (Fbobp, 0);
 EXFUN (Fformat, MANY);
 EXFUN (Fmessage, MANY);
-extern Lisp_Object format1 P_ ((/* char *, ... */));
+extern Lisp_Object format2 P_ ((char *, Lisp_Object, Lisp_Object));
 extern Lisp_Object make_buffer_string P_ ((int, int, int));
 EXFUN (Fbuffer_substring, 2);
 EXFUN (Fbuffer_string, 0);
@@ -2423,7 +2665,8 @@ extern Lisp_Object Vinhibit_field_text_motion;
 EXFUN (Fconstrain_to_field, 5);
 EXFUN (Ffield_string, 1);
 EXFUN (Fdelete_field, 1);
-EXFUN (Ffield_beginning, 2);
+EXFUN (Ffield_beginning, 3);
+EXFUN (Ffield_end, 3);
 EXFUN (Ffield_string_no_properties, 1);
 extern void set_time_zone_rule P_ ((char *));
 
@@ -2509,9 +2752,9 @@ EXFUN (Ffile_directory_p, 1);
 EXFUN (Fwrite_region, 7);
 EXFUN (Ffile_readable_p, 1);
 EXFUN (Ffile_executable_p, 1);
-EXFUN (Fread_file_name, 5);
+EXFUN (Fread_file_name, 6);
 extern Lisp_Object close_file_unwind P_ ((Lisp_Object));
-extern void report_file_error P_ ((char *, Lisp_Object));
+extern void report_file_error P_ ((const char *, Lisp_Object));
 extern int internal_delete_file P_ ((Lisp_Object));
 extern void syms_of_fileio P_ ((void));
 EXFUN (Fmake_temp_name, 1);
@@ -2533,7 +2776,7 @@ EXFUN (Fmatch_beginning, 1);
 EXFUN (Fmatch_end, 1);
 EXFUN (Flooking_at, 1);
 extern int fast_string_match P_ ((Lisp_Object, Lisp_Object));
-extern int fast_c_string_match_ignore_case P_ ((Lisp_Object, char *));
+extern int fast_c_string_match_ignore_case P_ ((Lisp_Object, const char *));
 extern int scan_buffer P_ ((int, int, int, int, int *, int));
 extern int scan_newline P_ ((int, int, int, int, int, int));
 extern int find_next_newline P_ ((int, int));
@@ -2545,7 +2788,6 @@ extern void syms_of_search P_ ((void));
 
 extern Lisp_Object last_minibuf_string;
 extern void choose_minibuf_frame P_ ((void));
-extern int scmp P_ ((unsigned char *, unsigned char *, int));
 EXFUN (Fcompleting_read, 8);
 EXFUN (Fread_from_minibuffer, 7);
 EXFUN (Fread_variable, 2);
@@ -2555,7 +2797,7 @@ EXFUN (Feval_minibuffer, 2);
 EXFUN (Fread_string, 5);
 EXFUN (Fread_no_blanks_input, 3);
 extern Lisp_Object get_minibuffer P_ ((int));
-extern void temp_echo_area_glyphs P_ ((char *));
+extern void temp_echo_area_glyphs P_ ((const char *));
 extern void init_minibuf_once P_ ((void));
 extern void syms_of_minibuf P_ ((void));
 extern void keys_of_minibuf P_ ((void));
@@ -2589,11 +2831,16 @@ extern void syms_of_casetab P_ ((void));
 
 /* defined in keyboard.c */
 
+extern int echoing;
+extern Lisp_Object echo_message_buffer;
+extern struct kboard *echo_kboard;
+extern void cancel_echoing P_ ((void));
 extern Lisp_Object Qdisabled, QCfilter;
 extern Lisp_Object Vtty_erase_char, Vhelp_form, Vtop_level;
 extern int input_pending;
 EXFUN (Fdiscard_input, 0);
 EXFUN (Frecursive_edit, 0);
+EXFUN (Ftop_level, 0);
 EXFUN (Fcommand_execute, 4);
 EXFUN (Finput_pending_p, 0);
 extern Lisp_Object menu_bar_items P_ ((Lisp_Object));
@@ -2615,41 +2862,15 @@ extern void syms_of_keyboard P_ ((void));
 extern void keys_of_keyboard P_ ((void));
 extern char *push_key_description P_ ((unsigned int, char *, int));
 
-/* defined in keymap.c */
-
-#define KEYMAPP(m) (!NILP (get_keymap (m, 0, 0)))
-extern Lisp_Object Qkeymap, Qmenu_bar;
-extern Lisp_Object current_global_map;
-EXFUN (Fmake_sparse_keymap, 1);
-EXFUN (Fcopy_keymap, 1);
-EXFUN (Fdefine_key, 3);
-EXFUN (Flookup_key, 3);
-EXFUN (Fkey_binding, 2);
-EXFUN (Fkey_description, 1);
-EXFUN (Fsingle_key_description, 2);
-EXFUN (Fwhere_is_internal, 4);
-extern Lisp_Object access_keymap P_ ((Lisp_Object, Lisp_Object, int, int, int));
-extern Lisp_Object get_keyelt P_ ((Lisp_Object, int));
-extern Lisp_Object get_keymap P_ ((Lisp_Object, int, int));
-extern void describe_vector P_ ((Lisp_Object, Lisp_Object,
-                                void (*) (Lisp_Object), int,
-                                Lisp_Object, Lisp_Object, int *, int));
-extern void describe_map_tree P_ ((Lisp_Object, int, Lisp_Object, Lisp_Object,
-                                  char *, int, int, int));
-extern int current_minor_maps P_ ((Lisp_Object **, Lisp_Object **));
-extern void initial_define_key P_ ((Lisp_Object, int, char *));
-extern void initial_define_lispy_key P_ ((Lisp_Object, char *, char *));
-extern void syms_of_keymap P_ ((void));
-extern void keys_of_keymap P_ ((void));
 
 /* defined in indent.c */
 EXFUN (Fvertical_motion, 2);
 EXFUN (Findent_to, 2);
 EXFUN (Fcurrent_column, 0);
 EXFUN (Fmove_to_column, 2);
-extern int current_column P_ ((void));
+extern double current_column P_ ((void));
 extern void invalidate_current_column P_ ((void));
-extern int indented_beyond_p P_ ((int, int, int));
+extern int indented_beyond_p P_ ((int, int, double));
 extern void syms_of_indent P_ ((void));
 
 /* defined in window.c */
@@ -2661,6 +2882,7 @@ EXFUN (Fnext_window, 3);
 EXFUN (Fdelete_window, 1);
 EXFUN (Fselect_window, 1);
 EXFUN (Fset_window_buffer, 2);
+EXFUN (Fwindow_buffer, 1);
 EXFUN (Fget_buffer_window, 2);
 EXFUN (Fsave_window_excursion, UNEVALLED);
 EXFUN (Fsplit_window, 3);
@@ -2679,6 +2901,7 @@ EXFUN (Fset_window_start, 3);
 extern void temp_output_buffer_show P_ ((Lisp_Object));
 extern void replace_buffer_in_all_windows P_ ((Lisp_Object));
 extern void init_window_once P_ ((void));
+extern void init_window P_ ((void));
 extern void syms_of_window P_ ((void));
 extern void keys_of_window P_ ((void));
 
@@ -2720,12 +2943,11 @@ extern void frames_discard_buffer P_ ((Lisp_Object));
 extern void set_frame_buffer_list P_ ((Lisp_Object, Lisp_Object));
 extern void frames_bury_buffer P_ ((Lisp_Object));
 extern void syms_of_frame P_ ((void));
-extern void keys_of_frame P_ ((void));
 
 /* defined in emacs.c */
 extern Lisp_Object decode_env_path P_ ((char *, char *));
 extern Lisp_Object Vinvocation_name, Vinvocation_directory;
-extern Lisp_Object Vinstallation_directory;
+extern Lisp_Object Vinstallation_directory, empty_string;
 EXFUN (Fkill_emacs, 1);
 #if HAVE_SETLOCALE
 void fixup_locale P_ ((void));
@@ -2766,7 +2988,8 @@ extern void init_process P_ ((void));
 extern void syms_of_process P_ ((void));
 
 /* defined in callproc.c */
-extern Lisp_Object Vexec_path, Vexec_directory, Vdata_directory;
+extern Lisp_Object Vexec_path, Vexec_suffixes,
+                   Vexec_directory, Vdata_directory;
 extern Lisp_Object Vdoc_directory;
 EXFUN (Fcall_process, MANY);
 extern int child_setup P_ ((int, int, int, char **, int, Lisp_Object));
@@ -2795,10 +3018,9 @@ extern void unmark_byte_stack P_ ((void));
 
 /* defined in macros.c */
 extern Lisp_Object Qexecute_kbd_macro;
-EXFUN (Fexecute_kbd_macro, 2);
+EXFUN (Fexecute_kbd_macro, 3);
 extern void init_macros P_ ((void));
 extern void syms_of_macros P_ ((void));
-extern void keys_of_macros P_ ((void));
 
 /* defined in undo.c */
 extern Lisp_Object Qinhibit_read_only;
@@ -2863,10 +3085,10 @@ extern int set_window_size P_ ((int, int, int));
 extern void create_process P_ ((Lisp_Object, char **, Lisp_Object));
 extern int tabs_safe_p P_ ((void));
 extern void init_baud_rate P_ ((void));
-extern int emacs_open P_ ((char *, int, int));
+extern int emacs_open P_ ((const char *, int, int));
 extern int emacs_close P_ ((int));
 extern int emacs_read P_ ((int, char *, unsigned int));
-extern int emacs_write P_ ((int, char *, unsigned int));
+extern int emacs_write P_ ((int, const char *, unsigned int));
 
 /* defined in filelock.c */
 EXFUN (Funlock_buffer, 0);
@@ -2893,9 +3115,6 @@ extern void syms_of_ccl P_ ((void));
 EXFUN (Ffile_attributes, 1);
 extern void syms_of_dired P_ ((void));
 
-/* Defined in mocklisp.c */
-extern void syms_of_mocklisp P_ ((void));
-
 /* Defined in term.c */
 extern void syms_of_term P_ ((void));
 extern void fatal () NO_RETURN;
@@ -2917,9 +3136,14 @@ extern int getloadavg P_ ((double *, int));
 extern void syms_of_xfns P_ ((void));
 extern void init_xfns P_ ((void));
 extern Lisp_Object Vx_resource_name;
+extern Lisp_Object Vx_resource_class;
 EXFUN (Fxw_display_color_p, 1);
+EXFUN (Fx_file_dialog, 4);
 #endif /* HAVE_X_WINDOWS */
 
+/* Defined in xsmfns.c */
+extern void syms_of_xsmfns P_ ((void));
+
 /* Defined in xselect.c */
 extern void syms_of_xselect P_ ((void));
 
@@ -2939,7 +3163,7 @@ extern POINTER_TYPE *xmalloc P_ ((size_t));
 extern POINTER_TYPE *xrealloc P_ ((POINTER_TYPE *, size_t));
 extern void xfree P_ ((POINTER_TYPE *));
 
-extern char *xstrdup P_ ((char *));
+extern char *xstrdup P_ ((const char *));
 
 #ifndef USE_CRT_DLL
 extern char *egetenv P_ ((char *));
@@ -2978,3 +3202,48 @@ extern Lisp_Object Vdirectory_sep_char;
 #else
 #define SWITCH_ENUM_CAST(x) (x)
 #endif
+
+/* Loop over Lisp list LIST.  Signal an error if LIST is not a proper
+   list, or if it contains circles.
+
+   HARE and TORTOISE should be the names of Lisp_Object variables, and
+   N should be the name of an EMACS_INT variable declared in the
+   function where the macro is used.  Each nested loop should use
+   its own variables.
+
+   In the loop body, HARE is set to each cons of LIST, and N is the
+   length of the list processed so far.  */
+
+#define LIST_END_P(list, obj)                          \
+  (NILP (obj)                                          \
+   ? 1                                                 \
+   : (CONSP (obj)                                      \
+      ? 0                                              \
+      : (wrong_type_argument (Qlistp, (list))), 1))
+
+#define FOREACH(hare, list, tortoise, n)               \
+  for (tortoise = hare = (list), n = 0;                        \
+       !LIST_END_P (list, hare);                       \
+       (hare = XCDR (hare), ++n,                       \
+       ((n & 1) != 0                                   \
+        ? (tortoise = XCDR (tortoise),                 \
+           (EQ (hare, tortoise)                        \
+            && (circular_list_error ((list)), 1)))     \
+        : 0)))
+
+/* The ubiquitous min and max macros.  */
+
+#ifdef max
+#undef max
+#undef min
+#endif
+#define min(a, b)      ((a) < (b) ? (a) : (b))
+#define max(a, b)      ((a) > (b) ? (a) : (b))
+
+/* Return a fixnum or float, depending on whether VAL fits in a Lisp
+   fixnum.  */
+
+#define make_fixnum_or_float(val) \
+   (FIXNUM_OVERFLOW_P (val) \
+    ? make_float (val) \
+    : make_number ((EMACS_INT)(val)))