aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h98
1 files changed, 59 insertions, 39 deletions
diff --git a/src/buffer.h b/src/buffer.h
index 1129840bd47..276cca32e48 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -1,7 +1,7 @@
1/* Header file for the buffer manipulation primitives. 1/* Header file for the buffer manipulation primitives.
2 2
3Copyright (C) 1985-1986, 1993-1995, 1997-2012 3Copyright (C) 1985-1986, 1993-1995, 1997-2013 Free Software Foundation,
4 Free Software Foundation, Inc. 4Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -82,9 +82,6 @@ INLINE_HEADER_BEGIN
82/* Size of gap. */ 82/* Size of gap. */
83#define GAP_SIZE (current_buffer->text->gap_size) 83#define GAP_SIZE (current_buffer->text->gap_size)
84 84
85/* Is the current buffer narrowed? */
86#define NARROWED ((BEGV != BEG) || (ZV != Z))
87
88/* Modification count. */ 85/* Modification count. */
89#define MODIFF (current_buffer->text->modiff) 86#define MODIFF (current_buffer->text->modiff)
90 87
@@ -173,10 +170,6 @@ INLINE_HEADER_BEGIN
173/* Size of gap. */ 170/* Size of gap. */
174#define BUF_GAP_SIZE(buf) ((buf)->text->gap_size) 171#define BUF_GAP_SIZE(buf) ((buf)->text->gap_size)
175 172
176/* Is this buffer narrowed? */
177#define BUF_NARROWED(buf) ((BUF_BEGV (buf) != BUF_BEG (buf)) \
178 || (BUF_ZV (buf) != BUF_Z (buf)))
179
180/* Modification count. */ 173/* Modification count. */
181#define BUF_MODIFF(buf) ((buf)->text->modiff) 174#define BUF_MODIFF(buf) ((buf)->text->modiff)
182 175
@@ -193,6 +186,9 @@ INLINE_HEADER_BEGIN
193/* FIXME: should we move this into ->text->auto_save_modiff? */ 186/* FIXME: should we move this into ->text->auto_save_modiff? */
194#define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified) 187#define BUF_AUTOSAVE_MODIFF(buf) ((buf)->auto_save_modified)
195 188
189/* Compaction count. */
190#define BUF_COMPACT(buf) ((buf)->text->compact)
191
196/* Marker chain of buffer. */ 192/* Marker chain of buffer. */
197#define BUF_MARKERS(buf) ((buf)->text->markers) 193#define BUF_MARKERS(buf) ((buf)->text->markers)
198 194
@@ -291,24 +287,24 @@ extern void enlarge_buffer_text (struct buffer *, ptrdiff_t);
291/* Access a Lisp position value in POS, 287/* Access a Lisp position value in POS,
292 and store the charpos in CHARPOS and the bytepos in BYTEPOS. */ 288 and store the charpos in CHARPOS and the bytepos in BYTEPOS. */
293 289
294#define DECODE_POSITION(charpos, bytepos, pos) \ 290#define DECODE_POSITION(charpos, bytepos, pos) \
295do \ 291 do \
296 { \ 292 { \
297 Lisp_Object __pos = (pos); \ 293 Lisp_Object __pos = (pos); \
298 if (NUMBERP (__pos)) \ 294 if (NUMBERP (__pos)) \
299 { \ 295 { \
300 charpos = __pos; \ 296 charpos = __pos; \
301 bytepos = buf_charpos_to_bytepos (current_buffer, __pos); \ 297 bytepos = buf_charpos_to_bytepos (current_buffer, __pos); \
302 } \ 298 } \
303 else if (MARKERP (__pos)) \ 299 else if (MARKERP (__pos)) \
304 { \ 300 { \
305 charpos = marker_position (__pos); \ 301 charpos = marker_position (__pos); \
306 bytepos = marker_byte_position (__pos); \ 302 bytepos = marker_byte_position (__pos); \
307 } \ 303 } \
308 else \ 304 else \
309 wrong_type_argument (Qinteger_or_marker_p, __pos); \ 305 wrong_type_argument (Qinteger_or_marker_p, __pos); \
310 } \ 306 } \
311while (0) 307 while (0)
312 308
313/* Maximum number of bytes in a buffer. 309/* Maximum number of bytes in a buffer.
314 A buffer cannot contain more bytes than a 1-origin fixnum can represent, 310 A buffer cannot contain more bytes than a 1-origin fixnum can represent,
@@ -317,6 +313,16 @@ while (0)
317#define BUF_BYTES_MAX \ 313#define BUF_BYTES_MAX \
318 (ptrdiff_t) min (MOST_POSITIVE_FIXNUM - 1, min (SIZE_MAX, PTRDIFF_MAX)) 314 (ptrdiff_t) min (MOST_POSITIVE_FIXNUM - 1, min (SIZE_MAX, PTRDIFF_MAX))
319 315
316/* Maximum gap size after compact_buffer, in bytes. Also
317 used in make_gap_larger to get some extra reserved space. */
318
319#define GAP_BYTES_DFL 2000
320
321/* Minimum gap size after compact_buffer, in bytes. Also
322 used in make_gap_smaller to avoid too small gap size. */
323
324#define GAP_BYTES_MIN 20
325
320/* Return the address of byte position N in current buffer. */ 326/* Return the address of byte position N in current buffer. */
321 327
322#define BYTE_POS_ADDR(n) \ 328#define BYTE_POS_ADDR(n) \
@@ -770,11 +776,15 @@ struct buffer
770 In an ordinary buffer, it is 0. */ 776 In an ordinary buffer, it is 0. */
771 struct buffer *base_buffer; 777 struct buffer *base_buffer;
772 778
773 /* In an indirect buffer, this is -1. In an ordinary buffer, 779 /* In an indirect buffer, this is -1. In an ordinary buffer,
774 it's the number of indirect buffers that share our text; 780 it's the number of indirect buffers that share our text;
775 zero means that we're the only owner of this text. */ 781 zero means that we're the only owner of this text. */
776 int indirections; 782 int indirections;
777 783
784 /* Number of windows showing this buffer. Always -1 for
785 an indirect buffer since it counts as its base buffer. */
786 int window_count;
787
778 /* A non-zero value in slot IDX means that per-buffer variable 788 /* A non-zero value in slot IDX means that per-buffer variable
779 with index IDX has a local value in this buffer. The index IDX 789 with index IDX has a local value in this buffer. The index IDX
780 for a buffer-local variable is stored in that variable's slot 790 for a buffer-local variable is stored in that variable's slot
@@ -992,15 +1002,15 @@ bset_width_table (struct buffer *b, Lisp_Object val)
992#define BUFFER_CHECK_INDIRECTION(b) \ 1002#define BUFFER_CHECK_INDIRECTION(b) \
993 do { \ 1003 do { \
994 if (BUFFER_LIVE_P (b)) \ 1004 if (BUFFER_LIVE_P (b)) \
995 { \ 1005 { \
996 if (b->base_buffer) \ 1006 if (b->base_buffer) \
997 { \ 1007 { \
998 eassert (b->indirections == -1); \ 1008 eassert (b->indirections == -1); \
999 eassert (b->base_buffer->indirections > 0); \ 1009 eassert (b->base_buffer->indirections > 0); \
1000 } \ 1010 } \
1001 else \ 1011 else \
1002 eassert (b->indirections >= 0); \ 1012 eassert (b->indirections >= 0); \
1003 } \ 1013 } \
1004 } while (0) 1014 } while (0)
1005 1015
1006/* Chain of all buffers, including killed ones. */ 1016/* Chain of all buffers, including killed ones. */
@@ -1061,7 +1071,6 @@ extern void set_buffer_internal_1 (struct buffer *);
1061extern void set_buffer_temp (struct buffer *); 1071extern void set_buffer_temp (struct buffer *);
1062extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object); 1072extern Lisp_Object buffer_local_value_1 (Lisp_Object, Lisp_Object);
1063extern void record_buffer (Lisp_Object); 1073extern void record_buffer (Lisp_Object);
1064extern _Noreturn void buffer_slot_type_mismatch (Lisp_Object, int);
1065extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t); 1074extern void fix_overlays_before (struct buffer *, ptrdiff_t, ptrdiff_t);
1066extern void mmap_set_vars (bool); 1075extern void mmap_set_vars (bool);
1067 1076
@@ -1173,7 +1182,18 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos)
1173 + pos + BUF_BEG_ADDR (buf) - BEG_BYTE); 1182 + pos + BUF_BEG_ADDR (buf) - BEG_BYTE);
1174 return STRING_CHAR (p); 1183 return STRING_CHAR (p);
1175} 1184}
1176 1185
1186/* Return number of windows showing B. */
1187
1188BUFFER_INLINE int
1189buffer_window_count (struct buffer *b)
1190{
1191 if (b->base_buffer)
1192 b = b->base_buffer;
1193 eassert (b->window_count >= 0);
1194 return b->window_count;
1195}
1196
1177/* Overlays */ 1197/* Overlays */
1178 1198
1179/* Return the marker that stands for where OV starts in the buffer. */ 1199/* Return the marker that stands for where OV starts in the buffer. */