(linenum→info "unix/slp.c:2238")

emacs/22.1/src/buffer.h

    1: /* Header file for the buffer manipulation primitives.
    2:    Copyright (C) 1985, 1986, 1993, 1994, 1995, 1997, 1998, 1999, 2000, 2001,
    3:                  2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
    4: 
    5: This file is part of GNU Emacs.
    6: 
    7: GNU Emacs is free software; you can redistribute it and/or modify
    8: it under the terms of the GNU General Public License as published by
    9: the Free Software Foundation; either version 2, or (at your option)
   10: any later version.
   11: 
   12: GNU Emacs is distributed in the hope that it will be useful,
   13: but WITHOUT ANY WARRANTY; without even the implied warranty of
   14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15: GNU General Public License for more details.
   16: 
   17: You should have received a copy of the GNU General Public License
   18: along with GNU Emacs; see the file COPYING.  If not, write to
   19: the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   20: Boston, MA 02110-1301, USA.  */
   21: 
   22: 
   23: /* Accessing the parameters of the current buffer.  */
   24: 
   25: /* These macros come in pairs, one for the char position
   26:    and one for the byte position.  */
   27: 
   28: /* Position of beginning of buffer.  */
   29: #define BEG (1)
   30: #define BEG_BYTE (BEG)
   31: 
   32: /* Position of beginning of accessible range of buffer.  */
   33: #define BEGV (current_buffer->begv)
   34: #define BEGV_BYTE (current_buffer->begv_byte)
   35: 
   36: /* Position of point in buffer.  The "+ 0" makes this
   37:    not an l-value, so you can't assign to it.  Use SET_PT instead.  */
   38: #define PT (current_buffer->pt + 0)
   39: #define PT_BYTE (current_buffer->pt_byte + 0)
   40: 
   41: /* Position of gap in buffer.  */
   42: #define GPT (current_buffer->text->gpt)
   43: #define GPT_BYTE (current_buffer->text->gpt_byte)
   44: 
   45: /* Position of end of accessible range of buffer.  */
   46: #define ZV (current_buffer->zv)
   47: #define ZV_BYTE (current_buffer->zv_byte)
   48: 
   49: /* Position of end of buffer.  */
   50: #define Z (current_buffer->text->z)
   51: #define Z_BYTE (current_buffer->text->z_byte)
   52: 
   53: /* Macros for the addresses of places in the buffer.  */
   54: 
   55: /* Address of beginning of buffer.  */
   56: #define BEG_ADDR (current_buffer->text->beg)
   57: 
   58: /* Address of beginning of accessible range of buffer.  */
   59: #define BEGV_ADDR (BYTE_POS_ADDR (current_buffer->begv_byte))
   60: 
   61: /* Address of point in buffer.  */
   62: #define PT_ADDR (BYTE_POS_ADDR (current_buffer->pt_byte))
   63: 
   64: /* Address of beginning of gap in buffer.  */
   65: #define GPT_ADDR (current_buffer->text->beg + current_buffer->text->gpt_byte - BEG_BYTE)
   66: 
   67: /* Address of end of gap in buffer.  */
   68: #define GAP_END_ADDR (current_buffer->text->beg + current_buffer->text->gpt_byte + current_buffer->text->gap_size - BEG_BYTE)
   69: 
   70: /* Address of end of accessible range of buffer.  */
   71: #define ZV_ADDR (BYTE_POS_ADDR (current_buffer->zv_byte))
   72: 
   73: /* Address of end of buffer.  */
   74: #define Z_ADDR (current_buffer->text->beg + current_buffer->text->gap_size + current_buffer->text->z_byte - BEG_BYTE)
   75: 
   76: /* Size of gap.  */
   77: #define GAP_SIZE (current_buffer->text->gap_size)
   78: 
   79: /* Is the current buffer narrowed?  */
   80: #define NARROWED        ((BEGV != BEG) || (ZV != Z))
   81: 
   82: /* Modification count.  */
   83: #define MODIFF (current_buffer->text->modiff)
   84: 
   85: /* Character modification count.  */
   86: #define CHARS_MODIFF (current_buffer->text->chars_modiff)
   87: 
   88: /* Overlay modification count.  */
   89: #define OVERLAY_MODIFF (current_buffer->text->overlay_modiff)
   90: 
   91: /* Modification count as of last visit or save.  */
   92: #define SAVE_MODIFF (current_buffer->text->save_modiff)
   93: 
   94: /* BUFFER_CEILING_OF (resp. BUFFER_FLOOR_OF), when applied to n, return
   95:    the max (resp. min) p such that
   96: 
   97:    BYTE_POS_ADDR (p) - BYTE_POS_ADDR (n) == p - n       */
   98: 
   99: #define BUFFER_CEILING_OF(BYTEPOS) \
  100:   (((BYTEPOS) < GPT_BYTE && GPT < ZV ? GPT_BYTE : ZV_BYTE) - 1)
  101: #define BUFFER_FLOOR_OF(BYTEPOS) \
  102:   (BEGV <= GPT && GPT_BYTE <= (BYTEPOS) ? GPT_BYTE : BEGV_BYTE)
  103: ^L
  104: /* Similar macros to operate on a specified buffer.
  105:    Note that many of these evaluate the buffer argument more than once.  */
  106: 
  107: /* Position of beginning of buffer.  */
  108: #define BUF_BEG(buf) (BEG)
  109: #define BUF_BEG_BYTE(buf) (BEG_BYTE)
  110: 
  111: /* Position of beginning of accessible range of buffer.  */
  112: #define BUF_BEGV(buf) ((buf)->begv)
  113: #define BUF_BEGV_BYTE(buf) ((buf)->begv_byte)
  114: 
  115: /* Position of point in buffer.  */
  116: #define BUF_PT(buf) ((buf)->pt)
  117: #define BUF_PT_BYTE(buf) ((buf)->pt_byte)
  118: 
  119: /* Position of gap in buffer.  */
  120: #define BUF_GPT(buf) ((buf)->text->gpt)
  121: #define BUF_GPT_BYTE(buf) ((buf)->text->gpt_byte)
  122: 
  123: /* Position of end of accessible range of buffer.  */
  124: #define BUF_ZV(buf) ((buf)->zv)
  125: #define BUF_ZV_BYTE(buf) ((buf)->zv_byte)
  126: 
  127: /* Position of end of buffer.  */
  128: #define BUF_Z(buf) ((buf)->text->z)
  129: #define BUF_Z_BYTE(buf) ((buf)->text->z_byte)
  130: 
  131: /* Address of beginning of buffer.  */
  132: #define BUF_BEG_ADDR(buf) ((buf)->text->beg)
  133: 
  134: /* Address of beginning of gap of buffer.  */
  135: #define BUF_GPT_ADDR(buf) ((buf)->text->beg + (buf)->text->gpt_byte - BEG_BYTE)
  136: 
  137: /* Address of end of buffer.  */
  138: #define BUF_Z_ADDR(buf) ((buf)->text->beg + (buf)->text->gap_size + (buf)->text->z_byte - BEG_BYTE)
  139: 
  140: /* Address of end of gap in buffer.  */
  141: #define BUF_GAP_END_ADDR(buf) ((buf)->text->beg + (buf)->text->gpt_byte + (buf)->text->gap_size - BEG_BYTE)
  142: 
  143: /* Size of gap.  */
  144: #define BUF_GAP_SIZE(buf) ((buf)->text->gap_size)
  145: 
  146: /* Is this buffer narrowed?  */
  147: #define BUF_NARROWED(buf) ((BUF_BEGV (buf) != BUF_BEG (buf)) \
  148:                            || (BUF_ZV (buf) != BUF_Z (buf)))
  149: 
  150: /* Modification count.  */
  151: #define BUF_MODIFF(buf) ((buf)->text->modiff)
  152: 
  153: /* Character modification count.  */
  154: #define BUF_CHARS_MODIFF(buf) ((buf)->text->chars_modiff)
  155: 
  156: /* Modification count as of last visit or save.  */
  157: #define BUF_SAVE_MODIFF(buf) ((buf)->text->save_modiff)
  158: 
  159: /* Overlay modification count.  */
  160: #define BUF_OVERLAY_MODIFF(buf) ((buf)->text->overlay_modiff)
  161: 
  162: /* Interval tree of buffer.  */
  163: #define BUF_INTERVALS(buf) ((buf)->text->intervals)
  164: 
  165: /* Marker chain of buffer.  */
  166: #define BUF_MARKERS(buf) ((buf)->text->markers)
  167: 
  168: #define BUF_UNCHANGED_MODIFIED(buf) \
  169:   ((buf)->text->unchanged_modified)
  170: 
  171: #define BUF_OVERLAY_UNCHANGED_MODIFIED(buf) \
  172:   ((buf)->text->overlay_unchanged_modified)
  173: #define BUF_BEG_UNCHANGED(buf) ((buf)->text->beg_unchanged)
  174: #define BUF_END_UNCHANGED(buf) ((buf)->text->end_unchanged)
  175: 
  176: #define UNCHANGED_MODIFIED \
  177:   BUF_UNCHANGED_MODIFIED (current_buffer)
  178: #define OVERLAY_UNCHANGED_MODIFIED \
  179:   BUF_OVERLAY_UNCHANGED_MODIFIED (current_buffer)
  180: #define BEG_UNCHANGED BUF_BEG_UNCHANGED (current_buffer)
  181: #define END_UNCHANGED BUF_END_UNCHANGED (current_buffer)
  182: 
  183: /* Compute how many characters at the top and bottom of BUF are
  184:    unchanged when the range START..END is modified.  This computation
  185:    must be done each time BUF is modified.  */
  186: 
  187: #define BUF_COMPUTE_UNCHANGED(buf, start, end)                          \
  188:   do                                                                    \
  189:     {                                                                   \
  190:       if (BUF_UNCHANGED_MODIFIED (buf) == BUF_MODIFF (buf)              \
  191:           && (BUF_OVERLAY_UNCHANGED_MODIFIED (buf)                     \
  192:               == BUF_OVERLAY_MODIFF (buf)))                            \
  193:         {                                                              \
  194:           BUF_BEG_UNCHANGED (buf) = (start) - BUF_BEG (buf);           \
  195:           BUF_END_UNCHANGED (buf) = BUF_Z (buf) - (end);               \
  196:         }                                                              \
  197:       else                                                              \
  198:         {                                                              \
  199:           if (BUF_Z (buf) - (end) < BUF_END_UNCHANGED (buf))           \
  200:             BUF_END_UNCHANGED (buf) = BUF_Z (buf) - (end);             \
  201:           if ((start) - BUF_BEG (buf) < BUF_BEG_UNCHANGED (buf))       \
  202:             BUF_BEG_UNCHANGED (buf) = (start) - BUF_BEG (buf);         \
  203:         }                                                              \
  204:     }                                                                   \
  205:   while (0)
  206: 
  207: ^L
  208: /* Macros to set PT in the current buffer, or another buffer.  */
  209: 
  210: #define SET_PT(position) (set_point (current_buffer, (position)))
  211: #define TEMP_SET_PT(position) (temp_set_point (current_buffer, (position)))
  212: 
  213: #define SET_PT_BOTH(position, byte) \
  214:   (set_point_both (current_buffer, (position), (byte)))
  215: #define TEMP_SET_PT_BOTH(position, byte) \
  216:   (temp_set_point_both (current_buffer, (position), (byte)))
  217: 
  218: #define BUF_SET_PT(buffer, position) \
  219:   (set_point ((buffer), (position)))
  220: #define BUF_TEMP_SET_PT(buffer, position) \
  221:   (temp_set_point ((buffer), (position)))
  222: 
  223: extern void set_point P_ ((struct buffer *, int));
  224: extern INLINE void temp_set_point P_ ((struct buffer *, int));
  225: extern void set_point_both P_ ((struct buffer *, int, int));
  226: extern INLINE void temp_set_point_both P_ ((struct buffer *, int, int));
  227: extern void enlarge_buffer_text P_ ((struct buffer *, int));
  228: 
  229: ^L
  230: /* Macros for setting the BEGV, ZV or PT of a given buffer.
  231: 
  232:    SET_BUF_PT* seet to be redundant.  Get rid of them?
  233: 
  234:    The ..._BOTH macros take both a charpos and a bytepos,
  235:    which must correspond to each other.
  236: 
  237:    The macros without ..._BOTH take just a charpos,
  238:    and compute the bytepos from it.  */
  239: 
  240: #define SET_BUF_BEGV(buf, charpos)                               \
  241:   ((buf)->begv_byte = buf_charpos_to_bytepos ((buf), (charpos)), \
  242:    (buf)->begv = (charpos))
  243: 
  244: #define SET_BUF_ZV(buf, charpos)                                \
  245:   ((buf)->zv_byte = buf_charpos_to_bytepos ((buf), (charpos)),  \
  246:    (buf)->zv = (charpos))
  247: 
  248: #define SET_BUF_BEGV_BOTH(buf, charpos, byte)           \
  249:   ((buf)->begv = (charpos),                             \
  250:    (buf)->begv_byte = (byte))
  251: 
  252: #define SET_BUF_ZV_BOTH(buf, charpos, byte)             \
  253:   ((buf)->zv = (charpos),                               \
  254:    (buf)->zv_byte = (byte))
  255: 
  256: #define SET_BUF_PT_BOTH(buf, charpos, byte)             \
  257:   ((buf)->pt = (charpos),                               \
  258:    (buf)->pt_byte = (byte))
  259: ^L
  260: /* Macros to access a character or byte in the current buffer,
  261:    or convert between a byte position and an address.
  262:    These macros do not check that the position is in range.  */
  263: 
  264: /* Access a Lisp position value in POS,
  265:    and store the charpos in CHARPOS and the bytepos in BYTEPOS.  */
  266: 
  267: #define DECODE_POSITION(charpos, bytepos, pos)                  \
  268: if (1)                                                          \
  269:   {                                                             \
  270:     Lisp_Object __pos = (pos);                                  \
  271:     if (NUMBERP (__pos))                                        \
  272:       {                                                         \
  273:         charpos = __pos;                                       \
  274:         bytepos = buf_charpos_to_bytepos (current_buffer, __pos);  \
  275:       }                                                         \
  276:     else if (MARKERP (__pos))                                   \
  277:       {                                                         \
  278:         charpos = marker_position (__pos);                     \
  279:         bytepos = marker_byte_position (__pos);                        \
  280:       }                                                         \
  281:     else                                                        \
  282:       wrong_type_argument (Qinteger_or_marker_p, __pos);        \
  283:   }                                                             \
  284: else
  285: 
  286: /* Return the address of byte position N in current buffer.  */
  287: 
  288: #define BYTE_POS_ADDR(n) \
  289:   (((n) >= GPT_BYTE ? GAP_SIZE : 0) + (n) + BEG_ADDR - BEG_BYTE)
  290: 
  291: /* Return the address of char position N.  */
  292: 
  293: #define CHAR_POS_ADDR(n)                        \
  294:   (((n) >= GPT ? GAP_SIZE : 0)                  \
  295:    + buf_charpos_to_bytepos (current_buffer, n) \
  296:    + BEG_ADDR - BEG_BYTE)
  297: 
  298: /* Convert a character position to a byte position.  */
  299: 
  300: #define CHAR_TO_BYTE(charpos)                   \
  301:   (buf_charpos_to_bytepos (current_buffer, charpos))
  302: 
  303: /* Convert a byte position to a character position.  */
  304: 
  305: #define BYTE_TO_CHAR(bytepos)                   \
  306:   (buf_bytepos_to_charpos (current_buffer, bytepos))
  307: 
  308: /* Convert PTR, the address of a byte in the buffer, into a byte position.  */
  309: 
  310: #define PTR_BYTE_POS(ptr) \
  311: ((ptr) - (current_buffer)->text->beg                                        \
  312:  - (ptr - (current_buffer)->text->beg <= (unsigned) (GPT_BYTE - BEG_BYTE) ? 0 : GAP_SIZE) \
  313:  + BEG_BYTE)
  314: 
  315: /* Return character at position POS.  */
  316: 
  317: #define FETCH_CHAR(pos)                                      \
  318:   (!NILP (current_buffer->enable_multibyte_characters)  \
  319:    ? FETCH_MULTIBYTE_CHAR ((pos))                            \
  320:    : FETCH_BYTE ((pos)))
  321: 
  322: /* Return the byte at byte position N.  */
  323: 
  324: #define FETCH_BYTE(n) *(BYTE_POS_ADDR ((n)))
  325: 
  326: /* Variables used locally in FETCH_MULTIBYTE_CHAR.  */
  327: extern unsigned char *_fetch_multibyte_char_p;
  328: extern int _fetch_multibyte_char_len;
  329: 
  330: /* Return character code of multi-byte form at position POS.  If POS
  331:    doesn't point the head of valid multi-byte form, only the byte at
  332:    POS is returned.  No range checking.  */
  333: 
  334: #define FETCH_MULTIBYTE_CHAR(pos)                                  \
  335:   (_fetch_multibyte_char_p = (((pos) >= GPT_BYTE ? GAP_SIZE : 0)        \
  336:                                + (pos) + BEG_ADDR - BEG_BYTE),                    \
  337:    _fetch_multibyte_char_len                                            \
  338:       = ((pos) >= GPT_BYTE ? ZV_BYTE : GPT_BYTE) - (pos),               \
  339:    STRING_CHAR (_fetch_multibyte_char_p, _fetch_multibyte_char_len))
  340: ^L
  341: /* Macros for accessing a character or byte,
  342:    or converting between byte positions and addresses,
  343:    in a specified buffer.  */
  344: 
  345: /* Return the address of character at byte position POS in buffer BUF.
  346:    Note that both arguments can be computed more than once.  */
  347: 
  348: #define BUF_BYTE_ADDRESS(buf, pos) \
  349: ((buf)->text->beg + (pos) - BEG_BYTE            \
  350:  + ((pos) >= (buf)->text->gpt_byte ? (buf)->text->gap_size : 0))
  351: 
  352: /* Return the address of character at char position POS in buffer BUF.
  353:    Note that both arguments can be computed more than once.  */
  354: 
  355: #define BUF_CHAR_ADDRESS(buf, pos) \
  356: ((buf)->text->beg + buf_charpos_to_bytepos ((buf), (pos)) - BEG_BYTE    \
  357:  + ((pos) >= (buf)->text->gpt ? (buf)->text->gap_size : 0))
  358: 
  359: /* Convert PTR, the address of a char in buffer BUF,
  360:    into a character position.  */
  361: 
  362: #define BUF_PTR_BYTE_POS(buf, ptr)                              \
  363: ((ptr) - (buf)->text->beg                                       \
  364:  - (ptr - (buf)->text->beg <= (unsigned) (BUF_GPT_BYTE ((buf)) - BEG_BYTE)\
  365:     ? 0 : BUF_GAP_SIZE ((buf)))                                 \
  366:  + BEG_BYTE)
  367: 
  368: /* Return the character at byte position POS in buffer BUF.   */
  369: 
  370: #define BUF_FETCH_CHAR(buf, pos)               \
  371:   (!NILP (buf->enable_multibyte_characters)     \
  372:    ? BUF_FETCH_MULTIBYTE_CHAR ((buf), (pos))    \
  373:    : BUF_FETCH_BYTE ((buf), (pos)))
  374: 
  375: /* Return the byte at byte position N in buffer BUF.   */
  376: 
  377: #define BUF_FETCH_BYTE(buf, n) \
  378:   *(BUF_BYTE_ADDRESS ((buf), (n)))
  379: 
  380: /* Return character code of multi-byte form at byte position POS in BUF.
  381:    If POS doesn't point the head of valid multi-byte form, only the byte at
  382:    POS is returned.  No range checking.  */
  383: 
  384: #define BUF_FETCH_MULTIBYTE_CHAR(buf, pos)                              \
  385:   (_fetch_multibyte_char_p                                              \
  386:      = (((pos) >= BUF_GPT_BYTE (buf) ? BUF_GAP_SIZE (buf) : 0)          \
  387:         + (pos) + BUF_BEG_ADDR (buf) - BEG_BYTE),                       \
  388:    _fetch_multibyte_char_len                                            \
  389:      = (((pos) >= BUF_GPT_BYTE (buf) ? BUF_ZV_BYTE (buf) : BUF_GPT_BYTE (buf)) \
  390:         - (pos)),                                                       \
  391:    STRING_CHAR (_fetch_multibyte_char_p, _fetch_multibyte_char_len))
  392: ^L
  393: /* Define the actual buffer data structures.  */
  394: 
  395: /* This data structure describes the actual text contents of a buffer.
  396:    It is shared between indirect buffers and their base buffer.  */
  397: 
  398: struct buffer_text
  399:   {
  400:     /* Actual address of buffer contents.  If REL_ALLOC is defined,
  401:        this address might change when blocks are relocated which can
  402:        e.g. happen when malloc is called.  So, don't pass a pointer
  403:        into a buffer's text to functions that malloc.  */
  404:     unsigned char *beg;
  405: 
  406:     EMACS_INT gpt;              /* Char pos of gap in buffer.  */
  407:     EMACS_INT z;                /* Char pos of end of buffer.  */
  408:     EMACS_INT gpt_byte;         /* Byte pos of gap in buffer.  */
  409:     EMACS_INT z_byte;           /* Byte pos of end of buffer.  */
  410:     EMACS_INT gap_size;         /* Size of buffer's gap.  */
  411:     int modiff;                 /* This counts buffer-modification events
  412:                                    for this buffer.  It is incremented for
  413:                                    each such event, and never otherwise
  414:                                    changed.  */
  415:     int chars_modiff;           /* This is modified with character change
  416:                                    events for this buffer.  It is set to
  417:                                    modiff for each such event, and never
  418:                                    otherwise changed.  */
  419:     int save_modiff;            /* Previous value of modiff, as of last
  420:                                    time buffer visited or saved a file.  */
  421: 
  422:     int overlay_modiff;         /* Counts modifications to overlays.  */
  423: 
  424:     /* Minimum value of GPT - BEG since last redisplay that finished.  */
  425:     EMACS_INT beg_unchanged;
  426: 
  427:     /* Minimum value of Z - GPT since last redisplay that finished.  */
  428:     EMACS_INT end_unchanged;
  429: 
  430:     /* MODIFF as of last redisplay that finished; if it matches MODIFF,
  431:        beg_unchanged and end_unchanged contain no useful information.  */
  432:     int unchanged_modified;
  433: 
  434:     /* BUF_OVERLAY_MODIFF of current buffer, as of last redisplay that
  435:        finished; if it matches BUF_OVERLAY_MODIFF, beg_unchanged and
  436:        end_unchanged contain no useful information.  */
  437:     int overlay_unchanged_modified;
  438: 
  439:     /* Properties of this buffer's text.  */
  440:     INTERVAL intervals;
  441: 
  442:     /* The markers that refer to this buffer.
  443:        This is actually a single marker ---
  444:        successive elements in its marker `chain'
  445:        are the other markers referring to this buffer.  */
  446:     struct Lisp_Marker *markers;
  447:   };
  448: 
  449: /* This is the structure that the buffer Lisp object points to.  */
  450: 
  451: struct buffer
  452: {
  453:   /* Everything before the `name' slot must be of a non-Lisp_Object type,
  454:      and every slot after `name' must be a Lisp_Object.
  455: 
  456:      Check out mark_buffer (alloc.c) to see why.  */
  457: 
  458:   EMACS_INT size;
  459: 
  460:   /* Next buffer, in chain of all buffers including killed buffers.
  461:      This chain is used only for garbage collection, in order to
  462:      collect killed buffers properly.
  463:      Note that vectors and most pseudovectors are all on one chain,
  464:      but buffers are on a separate chain of their own.  */
  465:   struct buffer *next;
  466: 
  467:   /* This structure holds the coordinates of the buffer contents
  468:      in ordinary buffers.  In indirect buffers, this is not used.  */
  469:   struct buffer_text own_text;
  470: 
  471:   /* This points to the `struct buffer_text' that used for this buffer.
  472:      In an ordinary buffer, this is the own_text field above.
  473:      In an indirect buffer, this is the own_text field of another buffer.  */
  474:   struct buffer_text *text;
  475: 
  476:   /* Char position of point in buffer.  */
  477:   EMACS_INT pt;
  478:   /* Byte position of point in buffer.  */
  479:   EMACS_INT pt_byte;
  480:   /* Char position of beginning of accessible range.  */
  481:   EMACS_INT begv;
  482:   /* Byte position of beginning of accessible range.  */
  483:   EMACS_INT begv_byte;
  484:   /* Char position of end of accessible range.  */
  485:   EMACS_INT zv;
  486:   /* Byte position of end of accessible range.  */
  487:   EMACS_INT zv_byte;
  488: 
  489:   /* In an indirect buffer, this points to the base buffer.
  490:      In an ordinary buffer, it is 0.  */
  491:   struct buffer *base_buffer;
  492: 
  493:   /* A non-zero value in slot IDX means that per-buffer variable
  494:      with index IDX has a local value in this buffer.  The index IDX
  495:      for a buffer-local variable is stored in that variable's slot
  496:      in buffer_local_flags as a Lisp integer.  If the index is -1,
  497:      this means the variable is always local in all buffers.  */
  498: #define MAX_PER_BUFFER_VARS 50
  499:   char local_flags[MAX_PER_BUFFER_VARS];
  500: 
  501:   /* Set to the modtime of the visited file when read or written.
  502:      -1 means visited file was nonexistent.
  503:      0 means visited file modtime unknown; in no case complain
  504:      about any mismatch on next save attempt.  */
  505:   int modtime;
  506:   /* The value of text->modiff at the last auto-save.  */
  507:   int auto_save_modified;
  508:   /* The value of text->modiff at the last display error.
  509:      Redisplay of this buffer is inhibited until it changes again.  */
  510:   int display_error_modiff;
  511:   /* The time at which we detected a failure to auto-save,
  512:      Or -1 if we didn't have a failure.  */
  513:   int auto_save_failure_time;
  514:   /* Position in buffer at which display started
  515:      the last time this buffer was displayed.  */
  516:   EMACS_INT last_window_start;
  517: 
  518:   /* Set nonzero whenever the narrowing is changed in this buffer.  */
  519:   int clip_changed;
  520: 
  521:   /* If the long line scan cache is enabled (i.e. the buffer-local
  522:      variable cache-long-line-scans is non-nil), newline_cache
  523:      points to the newline cache, and width_run_cache points to the
  524:      width run cache.
  525: 
  526:      The newline cache records which stretches of the buffer are
  527:      known *not* to contain newlines, so that they can be skipped
  528:      quickly when we search for newlines.
  529: 
  530:      The width run cache records which stretches of the buffer are
  531:      known to contain characters whose widths are all the same.  If
  532:      the width run cache maps a character to a value > 0, that value is
  533:      the character's width; if it maps a character to zero, we don't
  534:      know what its width is.  This allows compute_motion to process
  535:      such regions very quickly, using algebra instead of inspecting
  536:      each character.   See also width_table, below.  */
  537:   struct region_cache *newline_cache;
  538:   struct region_cache *width_run_cache;
  539: 
  540:   /* Non-zero means don't use redisplay optimizations for
  541:      displaying this buffer.  */
  542:   unsigned prevent_redisplay_optimizations_p : 1;
  543: 
  544:   /* List of overlays that end at or before the current center,
  545:      in order of end-position.  */
  546:   struct Lisp_Overlay *overlays_before;
  547: 
  548:   /* List of overlays that end after  the current center,
  549:      in order of start-position.  */
  550:   struct Lisp_Overlay *overlays_after;
  551: 
  552:   /* Position where th