* lisp.h (Ffield_end): Declare.
[bpt/emacs.git] / src / lisp.h
index 0a14388..6d46be8 100644 (file)
@@ -26,11 +26,13 @@ Boston, MA 02111-1307, USA.  */
 #define P_(proto) ()
 #endif
 
+#if 0
 /* Define this temporarily to hunt a bug.  If defined, the size of
    strings is redundantly recorded in sdata structures so that it can
    be compared to the sizes recorded in Lisp strings.  */
 
 #define GC_CHECK_STRING_BYTES 1
+#endif /* 0*/
 
 
 /* These are default choices for the types to use.  */
@@ -74,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
@@ -127,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
@@ -325,7 +327,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))
@@ -358,7 +360,7 @@ enum pvec_type
 #ifndef XPNTR
 #ifdef HAVE_SHM
 /* In this representation, data is found in two widely separated segments.  */
-extern int pure_size;
+extern size_t pure_size;
 #define XPNTR(a) \
   (XUINT (a) | (XUINT (a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS))
 #else /* not HAVE_SHM */
@@ -466,10 +468,21 @@ extern Lisp_Object make_number ();
 
 #endif /* NO_UNION_TYPE */
 
+/* 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) \
+  ((i) > MOST_POSITIVE_FIXNUM || (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))
@@ -786,18 +799,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.
@@ -817,6 +818,90 @@ 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.  This should become a Lisp_Object
+     some day; there's no need for the Lisp_String pointer nowadays.  */
+  struct Lisp_String *name;
+
+  /* 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 fcoundp.  */
+  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 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
  ***********************************************************************/
@@ -1220,8 +1305,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
@@ -1505,12 +1589,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
   {
@@ -1919,6 +2006,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));
@@ -2091,6 +2179,7 @@ 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));
@@ -2138,6 +2227,7 @@ extern void safe_bcopy P_ ((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;
@@ -2180,6 +2270,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 *));
@@ -2422,6 +2513,7 @@ EXFUN (Fconstrain_to_field, 5);
 EXFUN (Ffield_string, 1);
 EXFUN (Fdelete_field, 1);
 EXFUN (Ffield_beginning, 2);
+EXFUN (Ffield_end, 2);
 EXFUN (Ffield_string_no_properties, 1);
 extern void set_time_zone_rule P_ ((char *));
 
@@ -2587,6 +2679,10 @@ 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;
@@ -2914,6 +3010,7 @@ extern int getloadavg P_ ((double *, int));
 /* Defined in xfns.c */
 extern void syms_of_xfns P_ ((void));
 extern void init_xfns P_ ((void));
+extern Lisp_Object Vx_resource_name;
 EXFUN (Fxw_display_color_p, 1);
 #endif /* HAVE_X_WINDOWS */
 
@@ -2975,3 +3072,31 @@ 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), 0)), 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)))