]> code.delx.au - gnu-emacs/blobdiff - src/buffer.h
Don't declare logb if it is a macro.
[gnu-emacs] / src / buffer.h
index a1d838c037d85173ac70b9099891146061f231a8..499a8629afa2b93b0187fbf822954cf17ef074bc 100644 (file)
@@ -1,11 +1,11 @@
 /* Header file for the buffer manipulation primitives.
-   Copyright (C) 1985, 1986, 1990 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1993, 1994 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
+the Free Software Foundation; either version 2, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -18,12 +18,21 @@ along with GNU Emacs; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 
-#ifdef lint
-#include "undo.h"
-#endif /* lint */
+#ifdef USE_TEXT_PROPERTIES
+#define SET_PT(position) (set_point ((position), current_buffer))
+#define TEMP_SET_PT(position) (temp_set_point ((position), current_buffer))
 
+#define BUF_SET_PT(buffer, position) (set_point ((position), (buffer)))
+#define BUF_TEMP_SET_PT(buffer, position) (temp_set_point ((position), (buffer)))
+
+#else  /* don't support text properties */
 
 #define SET_PT(position) (current_buffer->text.pt = (position))
+#define TEMP_SET_PT(position) (current_buffer->text.pt = (position))
+
+#define BUF_SET_PT(buffer, position) (buffer->text.pt = (position))
+#define BUF_TEMP_SET_PT(buffer, position) (buffer->text.pt = (position))
+#endif /* don't support text properties */
 
 /* Character position of beginning of buffer.  */ 
 #define BEG (1)
@@ -44,6 +53,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 /* Character position of end of buffer.  */ 
 #define Z (current_buffer->text.z)
 
+/* Is the current buffer narrowed? */
+#define NARROWED       ((BEGV != BEG) || (ZV != Z))
+
 /* Modification count.  */
 #define MODIFF (current_buffer->text.modiff)
 
@@ -89,6 +101,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 /* Character position of end of buffer.  */ 
 #define BUF_Z(buf) ((buf)->text.z)
 
+/* Is this buffer narrowed? */
+#define BUF_NARROWED(buf) ((BUF_BEGV(buf) != BUF_BEG(buf)) \
+                          || (BUF_ZV(buf) != BUF_Z(buf)))
+
 /* Modification count.  */
 #define BUF_MODIFF(buf) ((buf)->text.modiff)
 
@@ -156,10 +172,16 @@ struct buffer
     int modtime;
     /* the value of text.modiff at the last auto-save. */
     int auto_save_modified;
+    /* The time at which we detected a failure to auto-save,
+       Or -1 if we didn't have a failure.  */
+    int auto_save_failure_time;
     /* Position in buffer at which display started
        the last time this buffer was displayed */
     int last_window_start;
 
+    /* Properties of this buffer's text -- conditionally compiled. */
+    DECLARE_INTERVALS
+
     /* This is a special exception -- as this slot should not be
        marked by gc_sweep, and as it is not lisp-accessible as
        a local variable -- so we regard it as not really being of type
@@ -182,7 +204,7 @@ struct buffer
     Lisp_Object filename;
     /* Dir for expanding relative pathnames */
     Lisp_Object directory;
-    /* true iff this buffer has been been backed
+    /* true iff this buffer has been backed
        up (if you write to its associated file
        and it hasn't been backed up, then a
        backup will be made) */
@@ -225,6 +247,10 @@ struct buffer
     Lisp_Object left_margin;
     /* Function to call when insert space past fill column */
     Lisp_Object auto_fill_function;
+#ifdef MSDOS
+    /* nil: text, t: binary.  */
+    Lisp_Object buffer_file_type;
+#endif
 
     /* String of length 256 mapping each char to its lower-case version.  */
     Lisp_Object downcase_table;
@@ -244,7 +270,8 @@ struct buffer
 #endif
     /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */
     Lisp_Object minor_modes;
-    /* t if "self-insertion" should overwrite */
+    /* t if "self-insertion" should overwrite; `binary' if it should also
+       overwrite newlines and tabs - for editing executables and the like.  */
     Lisp_Object overwrite_mode;
     /* non-nil means abbrev mode is on.  Expand abbrevs automatically. */
     Lisp_Object abbrev_mode;
@@ -257,15 +284,27 @@ struct buffer
     /* Changes in the buffer are recorded here for undo.
        t means don't record anything.  */
     Lisp_Object undo_list;
+    /* t means the mark and region are currently active.  */
+    Lisp_Object mark_active;
+
+    /* List of overlays that end at or before the current center,
+       in order of end-position.  */
+    Lisp_Object overlays_before;
+
+    /* List of overlays that end after  the current center,
+       in order of start-position.  */
+    Lisp_Object overlays_after;
 
-    /* List of fields in this buffer.  */
-    Lisp_Object fieldlist;
+    /* Position where the overlay lists are centered.  */
+    Lisp_Object overlay_center;
 };
+\f
+/* This points to the current buffer.  */
 
 extern struct buffer *current_buffer;
 
 /* This structure holds the default values of the buffer-local variables
-   defined with DefBufferLispVar, that have special slots in each buffer.
+   that have special slots in each buffer.
    The default value occupies the same slot in this structure
    as an individual buffer's value occupies in that buffer.
    Setting the default value also goes through the alist of buffers
@@ -283,7 +322,7 @@ extern struct buffer buffer_defaults;
    is turned on in the buffer's local_var_flags slot.
 
    If a slot in this structure is zero, then even though there may
-   be a DefBufferLispVar for the slot, there is no default valuefeor it;
+   be a Lisp-level local variable for the slot, it has no default value,
    and the corresponding slot in buffer_defaults is not used.  */
 
 extern struct buffer buffer_local_flags;
@@ -294,11 +333,20 @@ extern struct buffer buffer_local_flags;
 
 extern struct buffer buffer_local_symbols;
 
-/* Point in the current buffer. */
-
+/* This structure holds the required types for the values in the
+   buffer-local slots.  If a slot contains Qnil, then the
+   corresponding buffer slot may contain a value of any type.  If a
+   slot contains an integer, then prospective values' tags must be
+   equal to that integer.  When a tag does not match, the function
+   buffer_slot_type_mismatch will signal an error.  The value Qnil may
+   always be safely stored in any slot.  */
+extern struct buffer buffer_local_types;
+\f
+/* Point in the current buffer.  This is an obsolete alias
+   and should be eliminated.  */
 #define point (current_buffer->text.pt + 0)
 
-/* Return character at position n.  No range checking */
+/* Return character at position n.  No range checking */
 #define FETCH_CHAR(n) *(((n)>= GPT ? GAP_SIZE : 0) + (n) + BEG_ADDR - 1)
 
 /* BUFFER_CEILING_OF (resp. BUFFER_FLOOR_OF), when applied to n, return
@@ -311,35 +359,39 @@ extern struct buffer buffer_local_symbols;
 
 extern void reset_buffer ();
 
+extern Lisp_Object Fbuffer_name ();
+extern Lisp_Object Fget_file_buffer ();
+
 /* Functions to call before and after each text change. */
 extern Lisp_Object Vbefore_change_function;
 extern Lisp_Object Vafter_change_function;
-extern Lisp_Object Vfirst_change_function;
+extern Lisp_Object Vbefore_change_functions;
+extern Lisp_Object Vafter_change_functions;
+extern Lisp_Object Vfirst_change_hook;
+extern Lisp_Object Qfirst_change_hook;
 
-/* Fields.
+extern Lisp_Object Vdeactivate_mark;
+extern Lisp_Object Vtransient_mark_mode;
+\f
+/* Overlays */
+
+/* 1 if the OV is an overlay object.  */
+#define OVERLAY_VALID(OV) (OVERLAYP (OV))
 
-A field is like a marker but it defines a region rather than a
-point.  Like a marker, a field is asocated with a buffer.
-The field mechanism uses the marker mechanism in the
-sense that its start and end points are maintained as markers
-updated in the usual way as the buffer changes.
+/* Return the marker that stands for where OV starts in the buffer.  */
+#define OVERLAY_START(OV) (XCONS (XCONS ((OV))->car)->car)
 
-A field can be protected or unprotected.  If it is protected,
-no modifications can be made that affect the field in its buffer,
-when protected field checking is enabled.
+/* Return the marker that stands for where OV ends in the buffer.  */
+#define OVERLAY_END(OV) (XCONS (XCONS ((OV))->car)->cdr)
 
-Each field also contains an alist, in which you can store
-whatever you like.  */
+/* Return the actual buffer position for the marker P.
+   We assume you know which buffer it's pointing into.  */
 
-/* Slots in a field:  */
+#define OVERLAY_POSITION(P)                                    \
+ (XGCTYPE ((P)) == Lisp_Marker ? marker_position ((P)) : (abort (), 0))
 
-#define FIELD_BUFFER(f) (XVECTOR(f)->contents[1])
-#define FIELD_START_MARKER(f) (XVECTOR(f)->contents[2])
-#define FIELD_END_MARKER(f) (XVECTOR(f)->contents[3])
-#define FIELD_PROTECTED_FLAG(f) (XVECTOR(f)->contents[4])
-#define FIELD_ALIST(f) (XVECTOR(f)->contents[5])
+/* Allocation of buffer text.  */
 
-/* Allocation of buffer data. */
 #ifdef REL_ALLOC
 #define BUFFER_ALLOC(data,size) ((unsigned char *) r_alloc (&data, (size)))
 #define BUFFER_REALLOC(data,size) ((unsigned char *) r_re_alloc (&data, (size)))
@@ -351,6 +403,3 @@ whatever you like.  */
 #define BUFFER_FREE(data) (free ((data)))
 #define R_ALLOC_DECLARE(var,data)
 #endif
-
-/* A search buffer, with a fastmap allocated and ready to go.  */
-extern struct re_pattern_buffer searchbuf;