(detect_coding_iso2022): Do not exclude posibility of
[bpt/emacs.git] / src / buffer.h
index 1949bf3..4f96dd0 100644 (file)
@@ -15,7 +15,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 
 #ifdef USE_TEXT_PROPERTIES
@@ -59,6 +60,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 /* Modification count.  */
 #define MODIFF (current_buffer->text->modiff)
 
+/* Overlay modification count.  */
+#define OVERLAY_MODIFF (current_buffer->text->overlay_modiff)
+
 /* Modification count as of last visit or save.  */
 #define SAVE_MODIFF (current_buffer->text->save_modiff)
 
@@ -66,10 +70,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define BEG_ADDR (current_buffer->text->beg)
 
 /* Address of beginning of accessible range of buffer.  */ 
-#define BEGV_ADDR (&FETCH_CHAR (current_buffer->begv))
+#define BEGV_ADDR (POS_ADDR (current_buffer->begv))
 
 /* Address of point in buffer.  */ 
-#define PT_ADDR (&FETCH_CHAR (current_buffer->pt))
+#define PT_ADDR (POS_ADDR (current_buffer->pt))
 
 /* Address of beginning of gap in buffer.  */ 
 #define GPT_ADDR (current_buffer->text->beg + current_buffer->text->gpt - 1)
@@ -78,7 +82,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define GAP_END_ADDR (current_buffer->text->beg + current_buffer->text->gpt + current_buffer->text->gap_size - 1)
 
 /* Address of end of accessible range of buffer.  */ 
-#define ZV_ADDR (&FETCH_CHAR (current_buffer->zv))
+#define ZV_ADDR (POS_ADDR (current_buffer->zv))
+
+/* Address of end of buffer.  */ 
+#define Z_ADDR (current_buffer->text->beg + current_buffer->text->gap_size + current_buffer->text->z - 1)
 
 /* Size of gap.  */
 #define GAP_SIZE (current_buffer->text->gap_size)
@@ -114,6 +121,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 /* Modification count as of last visit or save.  */
 #define BUF_SAVE_MODIFF(buf) ((buf)->text->save_modiff)
 
+/* Overlay modification count.  */
+#define BUF_OVERLAY_MODIFF(buf) ((buf)->text->overlay_modiff)
+
 /* Interval tree of buffer.  */
 #define BUF_INTERVALS(buf) ((buf)->text->intervals)
 
@@ -123,6 +133,12 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 /* Address of beginning of buffer.  */
 #define BUF_BEG_ADDR(buf) ((buf)->text->beg)
 
+/* Address of beginning of gap of buffer.  */
+#define BUF_GPT_ADDR(buf) ((buf)->text->beg + (buf)->text->gpt - 1)
+
+/* Address of end of buffer.  */
+#define BUF_Z_ADDR(buf) ((buf)->text->beg + (buf)->text->gap_size + (buf)->text->z - 1)
+
 /* Macro for setting the value of BUF_ZV (BUF) to VALUE,
    by varying the end of the accessible region.  */
 #define SET_BUF_ZV(buf, value) ((buf)->zv = (value))
@@ -163,6 +179,8 @@ struct buffer_text
     int save_modiff;           /* Previous value of modiff, as of last
                                   time buffer visited or saved a file.  */
 
+    int overlay_modiff;                /* Counts modifications to overlays.  */
+
     /* Properties of this buffer's text -- conditionally compiled.  */
     DECLARE_INTERVALS
 
@@ -226,6 +244,9 @@ struct buffer
        the last time this buffer was displayed.  */
     int last_window_start;
 
+    /* Set nonzero whenever the narrowing is changed in this buffer.  */
+    int clip_changed;
+
     /* If the long line scan cache is enabled (i.e. the buffer-local
        variable cache-long-line-scans is non-nil), newline_cache
        points to the newline cache, and width_run_cache points to the
@@ -291,6 +312,8 @@ struct buffer
     Lisp_Object abbrev_table;
     /* This buffer's syntax table.  */
     Lisp_Object syntax_table;
+    /* This buffer's category table.  */
+    Lisp_Object category_table;
 
     /* Values of several buffer-local variables */
     /* tab-width is buffer-local so that redisplay can find it
@@ -303,21 +326,27 @@ struct buffer
     Lisp_Object auto_fill_function;
     /* nil: text, t: binary.
        This value is meaningful only on certain operating systems.  */
+    /* Actually, we don't need this flag any more because end-of-line
+       is handled correctly according to the buffer-file-coding-system
+       of the buffer.  Just keeping it for backward compatibility.  */
     Lisp_Object buffer_file_type;
 
-    /* String of length 256 mapping each char to its lower-case version.  */
+    /* Case table for case-conversion in this buffer.
+       This char-table maps each char into its lower-case version.  */
     Lisp_Object downcase_table;
-    /* String of length 256 mapping each char to its upper-case version.  */
+    /* Char-table mapping each char to its upper-case version.  */
     Lisp_Object upcase_table;
-    /* Translate table for case-folding search.  */
+    /* Char-table for conversion for case-folding search.  */
     Lisp_Object case_canon_table;
-    /* Inverse translate (equivalence class) table for case-folding search.  */
+    /* Char-table of equivalences for case-folding search.  */
     Lisp_Object case_eqv_table;
 
     /* Non-nil means do not display continuation lines.  */
     Lisp_Object truncate_lines;
     /* Non-nil means display ctl chars with uparrow.  */
     Lisp_Object ctl_arrow;
+    /* Non-nil means display text from right to left.  */
+    Lisp_Object direction_reversed;
     /* Non-nil means do selective display;
        see doc string in syms_of_buffer (buffer.c) for details.  */
     Lisp_Object selective_display;
@@ -356,7 +385,15 @@ struct buffer
     /* Position where the overlay lists are centered.  */
     Lisp_Object overlay_center;
 
-    /* Lisp of symbols naming the file format used for visited file. */
+    /* Non-nil means the buffer contents are regarded as multi-byte
+       form of characters, not a binary code.  */
+    Lisp_Object enable_multibyte_characters;
+
+    /* Coding system to be used for encoding the buffer contents on
+       saving.  */
+    Lisp_Object buffer_file_coding_system;
+
+    /* List of symbols naming the file format used for visited file. */
     Lisp_Object file_format;
 
     /* True if the newline position cache and width run cache are
@@ -398,6 +435,17 @@ struct buffer
        A list => `invisible' property means invisible
                  if it is memq in that list.  */
     Lisp_Object invisibility_spec;
+
+    /* This is the last window that was selected with this buffer in it,
+       or nil if that window no longer displays this buffer.  */
+    Lisp_Object last_selected_window;
+
+    /* Incremented each time the buffer is displayed in a window.  */
+    Lisp_Object display_count;
+    /* These are so we don't have to recompile everything
+       the next few times we add a new slot.  */
+    Lisp_Object extra2, extra3;
   };
 \f
 /* This points to the current buffer.  */
@@ -443,17 +491,36 @@ extern struct buffer buffer_local_symbols;
    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->pt + 0)
+/* Return the address of position N.  No range checking.  */
+#define POS_ADDR(n) (((n)>= GPT ? GAP_SIZE : 0) + (n) + BEG_ADDR - 1)
+
+/* Return the byte at position N.  No range checking.  */
+#define FETCH_BYTE(n) *(POS_ADDR ((n)))
+
+/* Variables used locally in FETCH_MULTIBYTE_CHAR.  */
+extern unsigned char *_fetch_multibyte_char_p;
+extern int _fetch_multibyte_char_len;
+
+/* Return character code of multi-byte form at position POS.  If POS
+   doesn't point the head of valid multi-byte form, only the byte at
+   POS is returned.  No range checking.  */
+
+#define FETCH_MULTIBYTE_CHAR(pos)                                      \
+  (_fetch_multibyte_char_p = (((pos) >= GPT ? GAP_SIZE : 0)            \
+                              + (pos) + BEG_ADDR - 1),                 \
+   _fetch_multibyte_char_len = ((pos) >= GPT ? ZV : GPT) - (pos),      \
+   STRING_CHAR (_fetch_multibyte_char_p, _fetch_multibyte_char_len))
 
-/* Return character at position n.  No range checking.  */
-#define FETCH_CHAR(n) *(((n)>= GPT ? GAP_SIZE : 0) + (n) + BEG_ADDR - 1)
+/* Return character at position POS.  No range checking.  */
+#define FETCH_CHAR(pos)                                        \
+  (!NILP (current_buffer->enable_multibyte_characters) \
+   ? FETCH_MULTIBYTE_CHAR ((pos))                      \
+   : FETCH_BYTE ((pos)))
 
 /* BUFFER_CEILING_OF (resp. BUFFER_FLOOR_OF), when applied to n, return
    the max (resp. min) p such that
 
-   &FETCH_CHAR (p) - &FETCH_CHAR (n) == p - n       */
+   POS_ADDR (p) - POS_ADDR (n) == p - n       */
 
 #define BUFFER_CEILING_OF(n) (((n) < GPT && GPT < ZV ? GPT : ZV) - 1)
 #define BUFFER_FLOOR_OF(n) (BEGV <= GPT && GPT <= (n) ? GPT : BEGV)
@@ -464,6 +531,7 @@ extern void evaporate_overlays ();
 extern Lisp_Object Fbuffer_name ();
 extern Lisp_Object Fget_file_buffer ();
 extern Lisp_Object Fnext_overlay_change ();
+extern Lisp_Object Fdelete_overlay ();
 
 /* Functions to call before and after each text change.  */
 extern Lisp_Object Vbefore_change_function;
@@ -471,6 +539,8 @@ extern Lisp_Object Vafter_change_function;
 extern Lisp_Object Vbefore_change_functions;
 extern Lisp_Object Vafter_change_functions;
 extern Lisp_Object Vfirst_change_hook;
+extern Lisp_Object Qbefore_change_functions;
+extern Lisp_Object Qafter_change_functions;
 extern Lisp_Object Qfirst_change_hook;
 
 extern Lisp_Object Vdeactivate_mark;