Annotation of GNUtools/emacs/src/buffer.h, revision 1.1

1.1     ! root        1: /* Header file for the buffer manipulation primitives.
        !             2:    Copyright (C) 1985, 1986, 1990 Free Software Foundation, Inc.
        !             3: 
        !             4: This file is part of GNU Emacs.
        !             5: 
        !             6: GNU Emacs is free software; you can redistribute it and/or modify
        !             7: it under the terms of the GNU General Public License as published by
        !             8: the Free Software Foundation; either version 1, or (at your option)
        !             9: any later version.
        !            10: 
        !            11: GNU Emacs is distributed in the hope that it will be useful,
        !            12: but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            14: GNU General Public License for more details.
        !            15: 
        !            16: You should have received a copy of the GNU General Public License
        !            17: along with GNU Emacs; see the file COPYING.  If not, write to
        !            18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
        !            19: 
        !            20: 
        !            21: #define SET_PT  PT =
        !            22: 
        !            23: /* Just for laughs, use the same names as in ITS TECO, around 1973.  */
        !            24: 
        !            25: /* Character position of beginning of buffer.  */ 
        !            26: #define BEG (1)
        !            27: /* Character position of beginning of accessible range of buffer.  */ 
        !            28: #define BEGV (current_buffer->text.begv)
        !            29: /* Character position of point in buffer.  */ 
        !            30: #define PT (current_buffer->text.pt)
        !            31: /* Character position of gap in buffer.  */ 
        !            32: #define GPT (current_buffer->text.gpt)
        !            33: /* Character position of end of accessible range of buffer.  */ 
        !            34: #define ZV (current_buffer->text.zv)
        !            35: /* Character position of end of buffer.  */ 
        !            36: #define Z (current_buffer->text.z)
        !            37: /* Modification count.  */
        !            38: #define MODIFF (current_buffer->text.modiff)
        !            39: 
        !            40: /* Address of beginning of buffer.  */ 
        !            41: #define BEG_ADDR (current_buffer->text.beg)
        !            42: /* Address of beginning of accessible range of buffer.  */ 
        !            43: #define BEGV_ADDR (&FETCH_CHAR (current_buffer->text.begv))
        !            44: /* Address of point in buffer.  */ 
        !            45: #define PT_ADDR (&FETCH_CHAR (current_buffer->text.pt))
        !            46: /* Address of beginning of gap in buffer.  */ 
        !            47: #define GPT_ADDR (current_buffer->text.beg + current_buffer->text.gpt - 1)
        !            48: /* Address of end of gap in buffer.  */
        !            49: #define GAP_END_ADDR (current_buffer->text.beg + current_buffer->text.gpt + current_buffer->text.gap_size - 1)
        !            50: /* Address of end of accessible range of buffer.  */ 
        !            51: #define ZV_ADDR (&FETCH_CHAR (current_buffer->text.zv))
        !            52: 
        !            53: /* Size of gap.  */
        !            54: #define GAP_SIZE (current_buffer->text.gap_size)
        !            55: 
        !            56: /* Now similar macros for a specified buffer.
        !            57:    Note that many of these evaluate the buffer argument more than once.  */
        !            58: 
        !            59: /* Character position of beginning of buffer.  */ 
        !            60: #define BUF_BEG(buf) (1)
        !            61: /* Character position of beginning of accessible range of buffer.  */ 
        !            62: #define BUF_BEGV(buf) ((buf)->text.begv)
        !            63: /* Character position of point in buffer.  */ 
        !            64: #define BUF_PT(buf) ((buf)->text.pt)
        !            65: /* Character position of gap in buffer.  */ 
        !            66: #define BUF_GPT(buf) ((buf)->text.gpt)
        !            67: /* Character position of end of accessible range of buffer.  */ 
        !            68: #define BUF_ZV(buf) ((buf)->text.zv)
        !            69: /* Character position of end of buffer.  */ 
        !            70: #define BUF_Z(buf) ((buf)->text.z)
        !            71: /* Modification count.  */
        !            72: #define BUF_MODIFF(buf) ((buf)->text.modiff)
        !            73: 
        !            74: /* Address of beginning of buffer.  */
        !            75: #define BUF_BEG_ADDR(buf) ((buf)->text.beg)
        !            76: 
        !            77: /* Macro for setting the value of BUF_ZV (BUF) to VALUE,
        !            78:    by varying the end of the accessible region.  */
        !            79: #define SET_BUF_ZV(buf, value) ((buf)->text.zv = (value))
        !            80: #define SET_BUF_PT(buf, value) ((buf)->text.pt = (value))
        !            81: 
        !            82: /* Size of gap.  */
        !            83: #define BUF_GAP_SIZE(buf) ((buf)->text.gap_size)
        !            84: 
        !            85: /* Return the address of character at position POS in buffer BUF. 
        !            86:    Note that both arguments can be computed more than once.  */
        !            87: #define BUF_CHAR_ADDRESS(buf, pos) \
        !            88: ((buf)->text.beg + (pos) - 1           \
        !            89:  + ((pos) >= (buf)->text.gpt ? (buf)->text.gap_size : 0))
        !            90: 
        !            91: /* Convert the address of a char in the buffer into a character position.  */
        !            92: #define PTR_CHAR_POS(ptr) \
        !            93: ((ptr) - (current_buffer)->text.beg            \
        !            94:  - (ptr - (current_buffer)->text.beg < (unsigned) GPT ? 0 : GAP_SIZE))
        !            95: 
        !            96: struct buffer_text
        !            97:   {
        !            98:     /* Actual address of buffer contents.  */
        !            99:     unsigned char *beg;
        !           100:     /* Values of BEGV ... Z in this buffer.  */
        !           101:     int begv;
        !           102:     int pt;
        !           103:     int gpt;
        !           104:     int zv;
        !           105:     int z;
        !           106:     /* Value of GAP_SIZE in this buffer.  */
        !           107:     int gap_size;
        !           108:     /* This counts buffer-modification events for this buffer.
        !           109:        It is incremented for each such event, and never otherwise changed.  */
        !           110:     int modiff;
        !           111:   };
        !           112: 
        !           113: struct buffer
        !           114:   {
        !           115:     /* Everything before the `name' slot must be of a non-Lisp_Object type,
        !           116:        and every slot after `name' must be a Lisp_Object
        !           117:        This is known about by both mark_buffer (alloc.c) and
        !           118:        Flist_buffer_local_variables (buffer.c)
        !           119:      */
        !           120:     /* This structure holds the coordinates of the buffer contents.  */
        !           121:     struct buffer_text text;
        !           122:     /* Next buffer, in chain of all buffers including killed buffers.
        !           123:        This chain is used only for garbage collection, in order to
        !           124:        collect killed buffers properly.  */
        !           125:     struct buffer *next;
        !           126:     /* Flags saying which DEFVAR_PER_BUFFER variables
        !           127:        are local to this buffer.  */
        !           128:     int local_var_flags;
        !           129:     /* Value of text.modified as of when visited file was read or written.  */
        !           130:     int save_modified;
        !           131:     /* the value of text.modified at the last auto-save. */
        !           132:     int auto_save_modified;
        !           133:     /* Set to the modtime of the visited file when read or written.
        !           134:        -1 means visited file was nonexistent.
        !           135:        0 means visited file modtime unknown; in no case complain
        !           136:        about any mismatch on next save attempt.  */
        !           137:     int modtime;
        !           138:     /* Position in buffer at which display started
        !           139:        the last time this buffer was displayed */
        !           140:     int last_window_start;
        !           141: 
        !           142:     /* This is a special exception -- as this slot should not be
        !           143:        marked by gc_sweep, and as it is not lisp-accessible as
        !           144:        a local variable -- so re regard it as not really being of type
        !           145:        Lisp_Object */
        !           146:     /* the markers that refer to this buffer.
        !           147:        This is actually a single marker ---
        !           148:        successive elements in its marker `chain'
        !           149:        are the other markers referring to this
        !           150:        buffer */
        !           151:     Lisp_Object markers;
        !           152: 
        !           153: 
        !           154:     /* Everything from here down must be a Lisp_Object */
        !           155: 
        !           156: 
        !           157:     /* the name of this buffer */
        !           158:     Lisp_Object name;
        !           159:     /* the name of the file associated with this buffer */
        !           160:     Lisp_Object filename;
        !           161:     /* Dir for expanding relative pathnames */
        !           162:     Lisp_Object directory;
        !           163:     /* True iff this buffer has been been backed
        !           164:        up (if you write to its associated file
        !           165:        and it hasn't been backed up, then a
        !           166:        backup will be made) */
        !           167:     /* This isn't really used by the C code, so could be deleted.  */
        !           168:     Lisp_Object backed_up;
        !           169:     /* Length of file when last read or saved. */
        !           170:     Lisp_Object save_length;
        !           171:     /* file name used for auto-saving this buffer */
        !           172:     Lisp_Object auto_save_file_name;
        !           173:     /* Non-nil if buffer read-only */
        !           174:     Lisp_Object read_only;
        !           175:     /* "The mark"; no longer allowed to be nil */
        !           176:     Lisp_Object mark;
        !           177: 
        !           178:     /* Alist of elements (SYMBOL . VALUE-IN-THIS-BUFFER)
        !           179:        for all per-buffer variables of this buffer.  */
        !           180:     Lisp_Object local_var_alist;
        !           181: 
        !           182: 
        !           183:     /* Symbol naming major mode (eg lisp-mode) */
        !           184:     Lisp_Object major_mode;
        !           185:     /* Pretty name of major mode (eg "Lisp") */
        !           186:     Lisp_Object mode_name;
        !           187:     /* Format description for mode line */
        !           188:     Lisp_Object mode_line_format;
        !           189: 
        !           190:     /* Keys that are bound local to this buffer */
        !           191:     Lisp_Object keymap;
        !           192:     /* This buffer's local abbrev table */
        !           193:     Lisp_Object abbrev_table;
        !           194:     /* This buffer's syntax table.  */
        !           195:     Lisp_Object syntax_table;
        !           196: 
        !           197:     /* Values of several buffer-local variables */
        !           198:     /* tab-width is buffer-local so that redisplay can find it
        !           199:        in buffers that are not current */
        !           200:     Lisp_Object case_fold_search;
        !           201:     Lisp_Object tab_width;
        !           202:     Lisp_Object fill_column;
        !           203:     Lisp_Object left_margin;
        !           204:     /* Function to call when insert space past fiull column */
        !           205:     Lisp_Object auto_fill_hook;
        !           206: 
        !           207:     /* Non-nil means do not display continuation lines */
        !           208:     Lisp_Object truncate_lines;
        !           209:     /* Non-nil means display ctl chars with uparrow */
        !           210:     Lisp_Object ctl_arrow;
        !           211:     /* Non-nil means do selective display;
        !           212:        See doc string in syms_of_buffer (buffer.c) for details.  */
        !           213:     Lisp_Object selective_display;
        !           214:     /* Non-nil means show ... at end of line followed by invisible lines.  */
        !           215:     Lisp_Object selective_display_ellipses;
        !           216:     /* t if "self-insertion" should overwrite */
        !           217:     Lisp_Object overwrite_mode;
        !           218:     /* non-nil means abbrev mode is on.  Expand abbrevs automatically. */
        !           219:     Lisp_Object abbrev_mode;
        !           220:     /* Changes in the buffer are recorded here for undo.
        !           221:        t means don't record anything.  */
        !           222:     Lisp_Object undo_list;
        !           223: };
        !           224: 
        !           225: extern struct buffer *current_buffer;          /* points to the current buffer */
        !           226: 
        !           227: /* This structure holds the default values of the buffer-local variables
        !           228:    defined with DefBufferLispVar, that have special slots in each buffer.
        !           229:    The default value occupies the same slot in this structure
        !           230:    as an individual buffer's value occupies in that buffer.
        !           231:    Setting the default value also goes through the alist of buffers
        !           232:    and stores into each buffer that does not say it has a local value.  */
        !           233: 
        !           234: extern struct buffer buffer_defaults;
        !           235: 
        !           236: /* This structure marks which slots in a buffer have corresponding
        !           237:    default values in buffer_defaults.
        !           238:    Each such slot has a nonzero value in this structure.
        !           239:    The value has only one nonzero bit.
        !           240: 
        !           241:    When a buffer has its own local value for a slot,
        !           242:    the bit for that slot (found in the same slot in this structure)
        !           243:    is turned on in the buffer's local_var_flags slot.
        !           244: 
        !           245:    If a slot in this structure is zero, then even though there may
        !           246:    be a DefBufferLispVar for the slot, there is no default valuefeor it;
        !           247:    and the corresponding slot in buffer_defaults is not used.  */
        !           248: 
        !           249: extern struct buffer buffer_local_flags;
        !           250: 
        !           251: /* For each buffer slot, this points to the Lisp symbol name
        !           252:    for that slot in the current buffer.  It is 0 for slots
        !           253:    that don't have such names.  */
        !           254: 
        !           255: extern struct buffer buffer_local_symbols;
        !           256: 
        !           257: /* Some aliases for info about the current buffer.  */
        !           258: 
        !           259: #define point current_buffer->text.pt
        !           260: 
        !           261: /* Return character at position n.  No range checking */
        !           262: #define FETCH_CHAR(n) *(((n)>= GPT ? GAP_SIZE : 0) + (n) + BEG_ADDR - 1)
        !           263:   
        !           264: /* BufferSafeCeiling (resp. BufferSafeFloor), when applied to n, return */
        !           265: /* the max (resp. min) p such that &FETCH_CHAR (p) - &FETCH_CHAR (n) == p - n   */
        !           266: #define BufferSafeCeiling(n) (((n) < GPT && GPT < ZV ? GPT : ZV) - 1)
        !           267: 
        !           268: #define BufferSafeFloor(n) (BEGV <= GPT && GPT <= (n) ? GPT : BEGV)
        !           269: 
        !           270: extern void reset_buffer ();

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.