annotate src/buffer.h @ 1721:6ba3bca4c3de

* frame.h (struct frame): New fields `can_have_scrollbars' and `has_vertical_scrollbars'. (FRAME_CAN_HAVE_SCROLLBARS, FRAME_HAS_VERTICAL_SCROLLBARS): New accessors, for both the MULTI_FRAME and non-MULTI_FRAME. (VERTICAL_SCROLLBAR_WIDTH, WINDOW_VERTICAL_SCROLLBAR, WINDOW_VERTICAL_SCROLLBAR_COLUMN, WINDOW_VERTICAL_SCROLLBAR_HEIGHT): New macros. * window.h (struct window): New field `vertical_scrollbar'. * xterm.h (struct x_display): vertical_scrollbars, judge_timestamp, vertical_scrollbar_extra: New fields. (struct scrollbar): New struct. (VERTICAL_SCROLLBAR_PIXEL_WIDTH, VERTICAL_SCROLLBAR_PIXEL_HEIGHT, VERTICAL_SCROLLBAR_LEFT_BORDER, VERTICAL_SCROLLBAR_RIGHT_BORDER, VERTICAL_SCROLLBAR_TOP_BORDER, VERTICAL_SCROLLBAR_BOTTOM_BORDER, CHAR_TO_PIXEL_WIDTH, CHAR_TO_PIXEL_HEIGHT, PIXEL_TO_CHAR_WIDTH, PIXEL_TO_CHAR_HEIGHT): New accessors and macros. * frame.c (make_frame): Initialize the `can_have_scrollbars' and `has_vertical_scrollbars' fields of the frame. * term.c (term_init): Note that TERMCAP terminals don't support scrollbars. (mouse_position_hook): Document new args. (set_vertical_scrollbar_hook, condemn_scrollbars_hook, redeem_scrollbar_hook, judge_scrollbars_hook): New hooks. * termhooks.h: Declare and document them. (enum scrollbar_part): New type. (struct input_event): Describe the new form of the scrollbar_click event type. Change `part' from a Lisp_Object to an enum scrollbar_part. Add a new field `scrollbar'. * keyboard.c (kbd_buffer_get_event): Pass appropriate new parameters to *mouse_position_hook, and make_lispy_movement. * xfns.c (x_set_vertical_scrollbar): New function. (x_figure_window_size): Use new macros to calculate frame size. (Fx_create_frame): Note that X Windows frames do support scroll bars. Default to "yes". * xterm.c: #include <X11/cursorfont.h> and "window.h". (x_vertical_scrollbar_cursor): New variable. (x_term_init): Initialize it. (last_mouse_bar, last_mouse_bar_frame, last_mouse_part, last_mouse_scroll_range_start, last_mouse_scroll_range_end): New variables. (XTmouse_position): Use them to return scrollbar movement events. Take new arguments, for that purpose. (x_window_to_scrollbar, x_scrollbar_create, x_scrollbar_set_handle, x_scrollbar_remove, x_scrollbar_move, XTset_scrollbar, XTcondemn_scrollbars, XTredeem_scrollbar, XTjudge_scrollbars, x_scrollbar_expose, x_scrollbar_background_expose, x_scrollbar_handle_click, x_scrollbar_handle_motion): New functions to implement scrollbars. (x_term_init): Set the termhooks.h hooks to point to them. (x_set_window_size): Use new macros to calculate frame size. Set vertical_scrollbar_extra field. (x_make_frame_visible): Use the frame accessor FRAME_HAS_VERTICAL_SCROLLBARS to decide if we need to map the frame's subwindows as well. (XTread_socket): Use new size-calculation macros from xterm.h when processing ConfigureNotify events. (x_wm_set_size_hint): Use PIXEL_TO_CHAR_WIDTH and PIXEL_TO_CHAR_HEIGHT macros. * ymakefile (xdisp.o): This now depends on termhooks.h. (xterm.o): This now depends on window.h. * xterm.h (struct x_display): Delete v_scrollbar, v_thumbup, v_thumbdown, v_slider, h_scrollbar, h_thumbup, h_thumbdown, h_slider, v_scrollbar_width, h_scrollbar_height fields. * keyboard.c (Qvscrollbar_part, Qvslider_part, Qvthumbup_part, Qvthumbdown_part, Qhscrollbar_part, Qhslider_part, Qhthumbup_part, Qhthumbdown_part, Qscrollbar_click): Deleted; part of an obsolete interface. (head_table): Removed from here as well. (syms_of_keyboard): And here. * keyboard.h: And here. (POSN_SCROLLBAR_BUTTON): Removed. * xscrollbar.h: File removed - no longer necessary. * xfns.c: Don't #include it any more. (Qhorizontal_scroll_bar, Qvertical_scroll_bar): Deleted. (syms_of_xfns): Don't initialize or staticpro them. (gray_bits): Salvaged from xscrollbar.h. (x_window_to_scrollbar): Deleted. (x_set_horizontal_scrollbar): Deleted. (enum x_frame_parm, x_frame_parms): Remove references to x_set_horizontal_scrollbar. (x_set_foreground_color, x_set_background_color, x_set_border_pixel): Remove special code to support scrollbars. (Fx_create_frame): Remove old scrollbar setup code. (install_vertical_scrollbar, install_horizontal_scrollbar, adjust_scrollbars, x_resize_scrollbars): Deleted. * xterm.c (construct_mouse_click): This doesn't need to take care of scrollbar clicks anymore. (XTread_socket): Remove old code to support scrollbars. Call new functions instead for events which occur in scrollbar windows. (XTupdate_end): Remove call to adjust_scrollbars; the main redisplay code takes care of that now. (enum window_type): Deleted. * ymakefile: Note that xfns.o no longer depends on xscrollbar.h. * xterm.h (PIXEL_WIDTH, PIXEL_HEIGHT): Change name of parameter from `s' to `f'; it's a frame pointer.
author Jim Blandy <jimb@redhat.com>
date Thu, 24 Dec 1992 06:23:08 +0000
parents 0e105bd23f44
children 04fb1d3d6992
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
193
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Header file for the buffer manipulation primitives.
998
61c6983219ff entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 672
diff changeset
2 Copyright (C) 1985, 1986, 1990, 1992 Free Software Foundation, Inc.
193
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4 This file is part of GNU Emacs.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
998
61c6983219ff entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 672
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
193
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 any later version.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 #ifdef lint
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 #include "undo.h"
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 #endif /* lint */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25
1286
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
26 #ifdef USE_TEXT_PROPERTIES
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
27 #define SET_PT(position) (set_point ((position), current_buffer))
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
28 #define TEMP_SET_PT(position) (temp_set_point ((position), current_buffer))
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
29
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
30 #define BUF_SET_PT(buffer, position) (set_point ((position), (buffer)))
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
31 #define BUF_TEMP_SET_PT(buffer, position) (temp_set_point ((position), (buffer)))
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
32
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
33 #else /* don't support text properties */
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
34
193
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 #define SET_PT(position) (current_buffer->text.pt = (position))
1286
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
36 #define TEMP_SET_PT(position) (current_buffer->text.pt = (position))
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
37
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
38 #define BUF_SET_PT(buffer, position) (buffer->text.pt = (position))
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
39 #define BUF_TEMP_SET_PT(buffer, position) (buffer->text.pt = (position))
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
40 #endif /* don't support text properties */
193
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 /* Character position of beginning of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 #define BEG (1)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 /* Character position of beginning of accessible range of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 #define BEGV (current_buffer->text.begv)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 /* Character position of point in buffer. The "+ 0" makes this
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 not an l-value, so you can't assign to it. Use SET_PT instead. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 #define PT (current_buffer->text.pt + 0)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 /* Character position of gap in buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 #define GPT (current_buffer->text.gpt)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 /* Character position of end of accessible range of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 #define ZV (current_buffer->text.zv)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 /* Character position of end of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 #define Z (current_buffer->text.z)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 /* Modification count. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 #define MODIFF (current_buffer->text.modiff)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 /* Address of beginning of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 #define BEG_ADDR (current_buffer->text.beg)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 /* Address of beginning of accessible range of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 #define BEGV_ADDR (&FETCH_CHAR (current_buffer->text.begv))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 /* Address of point in buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 #define PT_ADDR (&FETCH_CHAR (current_buffer->text.pt))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 /* Address of beginning of gap in buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 #define GPT_ADDR (current_buffer->text.beg + current_buffer->text.gpt - 1)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 /* Address of end of gap in buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 #define GAP_END_ADDR (current_buffer->text.beg + current_buffer->text.gpt + current_buffer->text.gap_size - 1)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 /* Address of end of accessible range of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 #define ZV_ADDR (&FETCH_CHAR (current_buffer->text.zv))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 /* Size of gap. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 #define GAP_SIZE (current_buffer->text.gap_size)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 /* Now similar macros for a specified buffer.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 Note that many of these evaluate the buffer argument more than once. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 /* Character position of beginning of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 #define BUF_BEG(buf) (1)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 /* Character position of beginning of accessible range of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 #define BUF_BEGV(buf) ((buf)->text.begv)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 /* Character position of point in buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 #define BUF_PT(buf) ((buf)->text.pt)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 /* Character position of gap in buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 #define BUF_GPT(buf) ((buf)->text.gpt)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 /* Character position of end of accessible range of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 #define BUF_ZV(buf) ((buf)->text.zv)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 /* Character position of end of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 #define BUF_Z(buf) ((buf)->text.z)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 /* Modification count. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 #define BUF_MODIFF(buf) ((buf)->text.modiff)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 /* Address of beginning of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 #define BUF_BEG_ADDR(buf) ((buf)->text.beg)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 /* Macro for setting the value of BUF_ZV (BUF) to VALUE,
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 by varying the end of the accessible region. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 #define SET_BUF_ZV(buf, value) ((buf)->text.zv = (value))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 #define SET_BUF_PT(buf, value) ((buf)->text.pt = (value))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 /* Size of gap. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 #define BUF_GAP_SIZE(buf) ((buf)->text.gap_size)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 /* Return the address of character at position POS in buffer BUF.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 Note that both arguments can be computed more than once. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 #define BUF_CHAR_ADDRESS(buf, pos) \
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 ((buf)->text.beg + (pos) - 1 \
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 + ((pos) >= (buf)->text.gpt ? (buf)->text.gap_size : 0))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 /* Convert the address of a char in the buffer into a character position. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 #define PTR_CHAR_POS(ptr) \
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 ((ptr) - (current_buffer)->text.beg \
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 - (ptr - (current_buffer)->text.beg < (unsigned) GPT ? 0 : GAP_SIZE) \
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 + 1)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 struct buffer_text
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 {
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 unsigned char *beg; /* Actual address of buffer contents. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 int begv; /* Index of beginning of accessible range. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 int pt; /* Position of point in buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 int gpt; /* Index of gap in buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 int zv; /* Index of end of accessible range. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 int z; /* Index of end of buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 int gap_size; /* Size of buffer's gap */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 int modiff; /* This counts buffer-modification events
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 for this buffer. It is incremented for
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 each such event, and never otherwise
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 changed. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 };
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 struct buffer
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 {
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 /* Everything before the `name' slot must be of a non-Lisp_Object type,
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 and every slot after `name' must be a Lisp_Object.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 Check out mark_buffer (alloc.c) to see why.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 /* This structure holds the coordinates of the buffer contents. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 struct buffer_text text;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 /* Next buffer, in chain of all buffers including killed buffers.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 This chain is used only for garbage collection, in order to
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 collect killed buffers properly. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 struct buffer *next;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 /* Flags saying which DEFVAR_PER_BUFFER variables
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 are local to this buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 int local_var_flags;
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 193
diff changeset
164 /* Value of text.modiff as of when visited file was read or written. */
193
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 int save_modified;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 /* Set to the modtime of the visited file when read or written.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 -1 means visited file was nonexistent.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 0 means visited file modtime unknown; in no case complain
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 about any mismatch on next save attempt. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 int modtime;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 /* the value of text.modiff at the last auto-save. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 int auto_save_modified;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 /* Position in buffer at which display started
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 the last time this buffer was displayed */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 int last_window_start;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176
1286
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
177 /* Properties of this buffer's text -- conditionally compiled. */
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
178 DECLARE_INTERVALS
fbd402838d8d * buffer.h: New macro TEMP_SET_PT. If intervals are used, SET_PT
Joseph Arceneaux <jla@gnu.org>
parents: 998
diff changeset
179
193
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 /* This is a special exception -- as this slot should not be
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 marked by gc_sweep, and as it is not lisp-accessible as
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 a local variable -- so we regard it as not really being of type
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 Lisp_Object */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 /* the markers that refer to this buffer.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 This is actually a single marker ---
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 successive elements in its marker `chain'
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 are the other markers referring to this
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 buffer */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 Lisp_Object markers;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 /* Everything from here down must be a Lisp_Object */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 /* the name of this buffer */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 Lisp_Object name;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 /* Nuked: buffer number, assigned when buffer made Lisp_Object number;*/
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 /* the name of the file associated with this buffer */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 Lisp_Object filename;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 /* Dir for expanding relative pathnames */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 Lisp_Object directory;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 /* true iff this buffer has been been backed
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 up (if you write to its associated file
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 and it hasn't been backed up, then a
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 backup will be made) */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 /* This isn't really used by the C code, so could be deleted. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 Lisp_Object backed_up;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 /* Length of file when last read or saved. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 Lisp_Object save_length;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 /* file name used for auto-saving this buffer */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 Lisp_Object auto_save_file_name;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 /* Non-nil if buffer read-only */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 Lisp_Object read_only;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 /* "The mark"; no longer allowed to be nil */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 Lisp_Object mark;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 /* Alist of elements (SYMBOL . VALUE-IN-THIS-BUFFER)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 for all per-buffer variables of this buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 Lisp_Object local_var_alist;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 /* Symbol naming major mode (eg lisp-mode) */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 Lisp_Object major_mode;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 /* Pretty name of major mode (eg "Lisp") */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 Lisp_Object mode_name;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 /* Format string for mode line */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 Lisp_Object mode_line_format;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 /* Keys that are bound local to this buffer */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 Lisp_Object keymap;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 /* This buffer's local abbrev table */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 Lisp_Object abbrev_table;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 /* This buffer's syntax table. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 Lisp_Object syntax_table;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 /* Values of several buffer-local variables */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 /* tab-width is buffer-local so that redisplay can find it
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 in buffers that are not current */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 Lisp_Object case_fold_search;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 Lisp_Object tab_width;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 Lisp_Object fill_column;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 Lisp_Object left_margin;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 /* Function to call when insert space past fill column */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 Lisp_Object auto_fill_function;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 /* String of length 256 mapping each char to its lower-case version. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 Lisp_Object downcase_table;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 /* String of length 256 mapping each char to its upper-case version. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 Lisp_Object upcase_table;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 /* Non-nil means do not display continuation lines */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 Lisp_Object truncate_lines;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 /* Non-nil means display ctl chars with uparrow */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 Lisp_Object ctl_arrow;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 /* Non-nil means do selective display;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 See doc string in syms_of_buffer (buffer.c) for details. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 Lisp_Object selective_display;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 #ifndef old
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 /* Non-nil means show ... at end of line followed by invisible lines. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 Lisp_Object selective_display_ellipses;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 #endif
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 Lisp_Object minor_modes;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 /* t if "self-insertion" should overwrite */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 Lisp_Object overwrite_mode;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 /* non-nil means abbrev mode is on. Expand abbrevs automatically. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 Lisp_Object abbrev_mode;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 /* Display table to use for text in this buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 Lisp_Object display_table;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 /* Translate table for case-folding search. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 Lisp_Object case_canon_table;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 /* Inverse translate (equivalence class) table for case-folding search. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 Lisp_Object case_eqv_table;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 /* Changes in the buffer are recorded here for undo.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 t means don't record anything. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 Lisp_Object undo_list;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 /* List of fields in this buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 Lisp_Object fieldlist;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 };
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 extern struct buffer *current_buffer;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 /* This structure holds the default values of the buffer-local variables
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 defined with DefBufferLispVar, that have special slots in each buffer.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 The default value occupies the same slot in this structure
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 as an individual buffer's value occupies in that buffer.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 Setting the default value also goes through the alist of buffers
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 and stores into each buffer that does not say it has a local value. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 extern struct buffer buffer_defaults;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 /* This structure marks which slots in a buffer have corresponding
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 default values in buffer_defaults.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 Each such slot has a nonzero value in this structure.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 The value has only one nonzero bit.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 When a buffer has its own local value for a slot,
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 the bit for that slot (found in the same slot in this structure)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 is turned on in the buffer's local_var_flags slot.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 If a slot in this structure is zero, then even though there may
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 be a DefBufferLispVar for the slot, there is no default valuefeor it;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 and the corresponding slot in buffer_defaults is not used. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 extern struct buffer buffer_local_flags;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 /* For each buffer slot, this points to the Lisp symbol name
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 for that slot in the current buffer. It is 0 for slots
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 that don't have such names. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 extern struct buffer buffer_local_symbols;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313
998
61c6983219ff entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 672
diff changeset
314 /* This structure holds the required types for the values in the
61c6983219ff entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 672
diff changeset
315 buffer-local slots. If a slot contains Qnil, then the
61c6983219ff entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 672
diff changeset
316 corresponding buffer slot may contain a value of any type. If a
61c6983219ff entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 672
diff changeset
317 slot contains an integer, then prospective values' tags must be
61c6983219ff entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 672
diff changeset
318 equal to that integer. When a tag does not match, the function
61c6983219ff entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 672
diff changeset
319 buffer_slot_type_mismatch will signal an error. The value Qnil may
61c6983219ff entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 672
diff changeset
320 always be safely stored in any slot. */
1502
fa4c1f1c744d * buffer.h (Fbuffer_name, Fget_file_buffer): Added external
Jim Blandy <jimb@redhat.com>
parents: 1286
diff changeset
321 extern struct buffer buffer_local_types;
998
61c6983219ff entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 672
diff changeset
322
193
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 /* Point in the current buffer. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 #define point (current_buffer->text.pt + 0)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 /* Return character at position n. No range checking */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 #define FETCH_CHAR(n) *(((n)>= GPT ? GAP_SIZE : 0) + (n) + BEG_ADDR - 1)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 /* BUFFER_CEILING_OF (resp. BUFFER_FLOOR_OF), when applied to n, return
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 the max (resp. min) p such that
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 &FETCH_CHAR (p) - &FETCH_CHAR (n) == p - n */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 #define BUFFER_CEILING_OF(n) (((n) < GPT && GPT < ZV ? GPT : ZV) - 1)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 #define BUFFER_FLOOR_OF(n) (BEGV <= GPT && GPT <= (n) ? GPT : BEGV)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 extern void reset_buffer ();
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 /* Functions to call before and after each text change. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 extern Lisp_Object Vbefore_change_function;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 extern Lisp_Object Vafter_change_function;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 extern Lisp_Object Vfirst_change_function;
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 /* Fields.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 A field is like a marker but it defines a region rather than a
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 point. Like a marker, a field is asocated with a buffer.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 The field mechanism uses the marker mechanism in the
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 sense that its start and end points are maintained as markers
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 updated in the usual way as the buffer changes.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 A field can be protected or unprotected. If it is protected,
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 no modifications can be made that affect the field in its buffer,
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 when protected field checking is enabled.
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 Each field also contains an alist, in which you can store
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 whatever you like. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 /* Slots in a field: */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 #define FIELD_BUFFER(f) (XVECTOR(f)->contents[1])
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 #define FIELD_START_MARKER(f) (XVECTOR(f)->contents[2])
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 #define FIELD_END_MARKER(f) (XVECTOR(f)->contents[3])
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 #define FIELD_PROTECTED_FLAG(f) (XVECTOR(f)->contents[4])
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 #define FIELD_ALIST(f) (XVECTOR(f)->contents[5])
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 /* Allocation of buffer data. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 #ifdef REL_ALLOC
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 #define BUFFER_ALLOC(data,size) ((unsigned char *) r_alloc (&data, (size)))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 #define BUFFER_REALLOC(data,size) ((unsigned char *) r_re_alloc (&data, (size)))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 #define BUFFER_FREE(data) (r_alloc_free (&data))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 #define R_ALLOC_DECLARE(var,data) (r_alloc_declare (&var, (data)))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 #else
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 #define BUFFER_ALLOC(data,size) (data = (unsigned char *) malloc ((size)))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 #define BUFFER_REALLOC(data,size) ((unsigned char *) realloc ((data), (size)))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 #define BUFFER_FREE(data) (free ((data)))
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 #define R_ALLOC_DECLARE(var,data)
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 #endif
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380
1596
0e105bd23f44 * systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents: 1502
diff changeset
381 /* VAX C is non-ANSI wrt extern declarations and requires the struct
0e105bd23f44 * systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents: 1502
diff changeset
382 re_pattern_buffer to completely defined for searchbuf's declaration. */
0e105bd23f44 * systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents: 1502
diff changeset
383 #ifdef VMS
0e105bd23f44 * systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents: 1502
diff changeset
384 #include "regex.h"
0e105bd23f44 * systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents: 1502
diff changeset
385 #endif /* VMS */
0e105bd23f44 * systty.h, process.c, buffer.h, callproc.c, sysdep.c, dired.c:
Jim Blandy <jimb@redhat.com>
parents: 1502
diff changeset
386
193
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 /* A search buffer, with a fastmap allocated and ready to go. */
596cfc339998 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 extern struct re_pattern_buffer searchbuf;
1502
fa4c1f1c744d * buffer.h (Fbuffer_name, Fget_file_buffer): Added external
Jim Blandy <jimb@redhat.com>
parents: 1286
diff changeset
389
fa4c1f1c744d * buffer.h (Fbuffer_name, Fget_file_buffer): Added external
Jim Blandy <jimb@redhat.com>
parents: 1286
diff changeset
390 extern Lisp_Object Fbuffer_name ();
fa4c1f1c744d * buffer.h (Fbuffer_name, Fget_file_buffer): Added external
Jim Blandy <jimb@redhat.com>
parents: 1286
diff changeset
391 extern Lisp_Object Fget_file_buffer ();