aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.h
diff options
context:
space:
mode:
authorTom Tromey2012-12-17 07:56:22 -0700
committerTom Tromey2012-12-17 07:56:22 -0700
commit3d6eced1ae51ffd0a782130e7c334052277e2724 (patch)
tree5d1d2ad7cd3374f922886c4a72062511a035c168 /src/buffer.h
parentbf69f522a9e135f9aa483cedd53e71e915f2bf75 (diff)
parent7c3d167f48d6262ee4e5512aa50a07ee96bc1509 (diff)
downloademacs-3d6eced1ae51ffd0a782130e7c334052277e2724.tar.gz
emacs-3d6eced1ae51ffd0a782130e7c334052277e2724.zip
merge from trunk
Diffstat (limited to 'src/buffer.h')
-rw-r--r--src/buffer.h82
1 files changed, 70 insertions, 12 deletions
diff --git a/src/buffer.h b/src/buffer.h
index e603486418b..a65b769469f 100644
--- a/src/buffer.h
+++ b/src/buffer.h
@@ -482,11 +482,6 @@ struct buffer_text
482 482
483struct buffer 483struct buffer
484{ 484{
485 /* HEADER.NEXT is the next buffer, in chain of all buffers, including killed
486 buffers. This chain, starting from all_buffers, is used only for garbage
487 collection, in order to collect killed buffers properly. Note that large
488 vectors and large pseudo-vector objects are all on another chain starting
489 from large_vectors. */
490 struct vectorlike_header header; 485 struct vectorlike_header header;
491 486
492 /* The name of this buffer. */ 487 /* The name of this buffer. */
@@ -750,6 +745,9 @@ struct buffer
750 In an indirect buffer, this is the own_text field of another buffer. */ 745 In an indirect buffer, this is the own_text field of another buffer. */
751 struct buffer_text *text; 746 struct buffer_text *text;
752 747
748 /* Next buffer, in chain of all buffers, including killed ones. */
749 struct buffer *next;
750
753 /* Char position of point in buffer. */ 751 /* Char position of point in buffer. */
754 ptrdiff_t pt; 752 ptrdiff_t pt;
755 753
@@ -772,11 +770,15 @@ struct buffer
772 In an ordinary buffer, it is 0. */ 770 In an ordinary buffer, it is 0. */
773 struct buffer *base_buffer; 771 struct buffer *base_buffer;
774 772
775 /* In an indirect buffer, this is -1. In an ordinary buffer, 773 /* In an indirect buffer, this is -1. In an ordinary buffer,
776 it's the number of indirect buffers that share our text; 774 it's the number of indirect buffers that share our text;
777 zero means that we're the only owner of this text. */ 775 zero means that we're the only owner of this text. */
778 int indirections; 776 int indirections;
779 777
778 /* Number of windows showing this buffer. Always -1 for
779 an indirect buffer since it counts as its base buffer. */
780 int window_count;
781
780 /* A non-zero value in slot IDX means that per-buffer variable 782 /* A non-zero value in slot IDX means that per-buffer variable
781 with index IDX has a local value in this buffer. The index IDX 783 with index IDX has a local value in this buffer. The index IDX
782 for a buffer-local variable is stored in that variable's slot 784 for a buffer-local variable is stored in that variable's slot
@@ -959,7 +961,52 @@ bset_width_table (struct buffer *b, Lisp_Object val)
959 b->INTERNAL_FIELD (width_table) = val; 961 b->INTERNAL_FIELD (width_table) = val;
960} 962}
961 963
962 964/* Number of Lisp_Objects at the beginning of struct buffer.
965 If you add, remove, or reorder Lisp_Objects within buffer
966 structure, make sure that this is still correct. */
967
968#define BUFFER_LISP_SIZE \
969 ((offsetof (struct buffer, own_text) - header_size) / word_size)
970
971/* Size of the struct buffer part beyond leading Lisp_Objects, in word_size
972 units. Rounding is needed for --with-wide-int configuration. */
973
974#define BUFFER_REST_SIZE \
975 ((((sizeof (struct buffer) - offsetof (struct buffer, own_text)) \
976 + (word_size - 1)) & ~(word_size - 1)) / word_size)
977
978/* Initialize the pseudovector header of buffer object. BUFFER_LISP_SIZE
979 is required for GC, but BUFFER_REST_SIZE is set up just to be consistent
980 with other pseudovectors. */
981
982#define BUFFER_PVEC_INIT(b) \
983 XSETPVECTYPESIZE (b, PVEC_BUFFER, BUFFER_LISP_SIZE, BUFFER_REST_SIZE)
984
985/* Convenient check whether buffer B is live. */
986
987#define BUFFER_LIVE_P(b) (!NILP (BVAR (b, name)))
988
989/* Convenient check whether buffer B is hidden (i.e. its name
990 starts with a space). Caller must ensure that B is live. */
991
992#define BUFFER_HIDDEN_P(b) (SREF (BVAR (b, name), 0) == ' ')
993
994/* Verify indirection counters. */
995
996#define BUFFER_CHECK_INDIRECTION(b) \
997 do { \
998 if (BUFFER_LIVE_P (b)) \
999 { \
1000 if (b->base_buffer) \
1001 { \
1002 eassert (b->indirections == -1); \
1003 eassert (b->base_buffer->indirections > 0); \
1004 } \
1005 else \
1006 eassert (b->indirections >= 0); \
1007 } \
1008 } while (0)
1009
963/* Chain of all buffers, including killed ones. */ 1010/* Chain of all buffers, including killed ones. */
964 1011
965extern struct buffer *all_buffers; 1012extern struct buffer *all_buffers;
@@ -967,7 +1014,7 @@ extern struct buffer *all_buffers;
967/* Used to iterate over the chain above. */ 1014/* Used to iterate over the chain above. */
968 1015
969#define FOR_EACH_BUFFER(b) \ 1016#define FOR_EACH_BUFFER(b) \
970 for ((b) = all_buffers; (b); (b) = (b)->header.next.buffer) 1017 for ((b) = all_buffers; (b); (b) = (b)->next)
971 1018
972/* This structure holds the default values of the buffer-local variables 1019/* This structure holds the default values of the buffer-local variables
973 that have special slots in each buffer. 1020 that have special slots in each buffer.
@@ -1126,7 +1173,18 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos)
1126 + pos + BUF_BEG_ADDR (buf) - BEG_BYTE); 1173 + pos + BUF_BEG_ADDR (buf) - BEG_BYTE);
1127 return STRING_CHAR (p); 1174 return STRING_CHAR (p);
1128} 1175}
1129 1176
1177/* Return number of windows showing B. */
1178
1179BUFFER_INLINE int
1180buffer_window_count (struct buffer *b)
1181{
1182 if (b->base_buffer)
1183 b = b->base_buffer;
1184 eassert (b->window_count >= 0);
1185 return b->window_count;
1186}
1187
1130/* Overlays */ 1188/* Overlays */
1131 1189
1132/* Return the marker that stands for where OV starts in the buffer. */ 1190/* Return the marker that stands for where OV starts in the buffer. */
@@ -1145,7 +1203,7 @@ BUF_FETCH_MULTIBYTE_CHAR (struct buffer *buf, ptrdiff_t pos)
1145 We assume you know which buffer it's pointing into. */ 1203 We assume you know which buffer it's pointing into. */
1146 1204
1147#define OVERLAY_POSITION(P) \ 1205#define OVERLAY_POSITION(P) \
1148 (MARKERP (P) ? marker_position (P) : (abort (), 0)) 1206 (MARKERP (P) ? marker_position (P) : (emacs_abort (), 0))
1149 1207
1150 1208
1151/*********************************************************************** 1209/***********************************************************************
@@ -1185,7 +1243,7 @@ extern int last_per_buffer_idx;
1185 1243
1186#define PER_BUFFER_VALUE_P(B, IDX) \ 1244#define PER_BUFFER_VALUE_P(B, IDX) \
1187 (((IDX) < 0 || IDX >= last_per_buffer_idx) \ 1245 (((IDX) < 0 || IDX >= last_per_buffer_idx) \
1188 ? (abort (), 0) \ 1246 ? (emacs_abort (), 0) \
1189 : ((B)->local_flags[IDX] != 0)) 1247 : ((B)->local_flags[IDX] != 0))
1190 1248
1191/* Set whether per-buffer variable with index IDX has a buffer-local 1249/* Set whether per-buffer variable with index IDX has a buffer-local
@@ -1194,7 +1252,7 @@ extern int last_per_buffer_idx;
1194#define SET_PER_BUFFER_VALUE_P(B, IDX, VAL) \ 1252#define SET_PER_BUFFER_VALUE_P(B, IDX, VAL) \
1195 do { \ 1253 do { \
1196 if ((IDX) < 0 || (IDX) >= last_per_buffer_idx) \ 1254 if ((IDX) < 0 || (IDX) >= last_per_buffer_idx) \
1197 abort (); \ 1255 emacs_abort (); \
1198 (B)->local_flags[IDX] = (VAL); \ 1256 (B)->local_flags[IDX] = (VAL); \
1199 } while (0) 1257 } while (0)
1200 1258