diff options
| author | Dmitry Antipov | 2012-07-03 07:57:52 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-07-03 07:57:52 +0400 |
| commit | 36429c89cbd7282a7614a358e5edb4d37f4a3f47 (patch) | |
| tree | eafca213d91a33d626e60caec38ccc21bdd394fe /src | |
| parent | b544fef2ac730e5fc8c072b33584d9b48d25f6fa (diff) | |
| download | emacs-36429c89cbd7282a7614a358e5edb4d37f4a3f47.tar.gz emacs-36429c89cbd7282a7614a358e5edb4d37f4a3f47.zip | |
Cleanup basic buffer management.
* buffer.h (struct buffer): Change layout to use generic vector
marking code. Fix some comments. Change type of 'clip_changed'
to bitfield. Remove unused #ifndef old.
(FIRST_FIELD_PER_BUFFER, LAST_FIELD_PER_BUFFER): Remove.
(GET_OVERLAYS_AT): Fix indentation.
(for_each_per_buffer_object_at): New macro.
* buffer.c (clone_per_buffer_values, reset_buffer_local_variables)
(Fbuffer_local_variables): Use it.
(init_buffer_once, syms_of_buffer): Remove unused #ifndef old.
* alloc.c (allocate_buffer): Adjust to match new layout of
struct buffer. Fix comment.
(mark_overlay): New function.
(mark_buffer): Use it. Use mark_vectorlike to mark normal
Lisp area of struct buffer.
(mark_object): Use it. Adjust marking of misc objects
and related comments.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 20 | ||||
| -rw-r--r-- | src/alloc.c | 131 | ||||
| -rw-r--r-- | src/buffer.c | 29 | ||||
| -rw-r--r-- | src/buffer.h | 310 |
4 files changed, 248 insertions, 242 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 58e82c27dc7..6eb1a07faf2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,23 @@ | |||
| 1 | 2012-07-03 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | Cleanup basic buffer management. | ||
| 4 | * buffer.h (struct buffer): Change layout to use generic vector | ||
| 5 | marking code. Fix some comments. Change type of 'clip_changed' | ||
| 6 | to bitfield. Remove unused #ifndef old. | ||
| 7 | (FIRST_FIELD_PER_BUFFER, LAST_FIELD_PER_BUFFER): Remove. | ||
| 8 | (GET_OVERLAYS_AT): Fix indentation. | ||
| 9 | (for_each_per_buffer_object_at): New macro. | ||
| 10 | * buffer.c (clone_per_buffer_values, reset_buffer_local_variables) | ||
| 11 | (Fbuffer_local_variables): Use it. | ||
| 12 | (init_buffer_once, syms_of_buffer): Remove unused #ifndef old. | ||
| 13 | * alloc.c (allocate_buffer): Adjust to match new layout of | ||
| 14 | struct buffer. Fix comment. | ||
| 15 | (mark_overlay): New function. | ||
| 16 | (mark_buffer): Use it. Use mark_vectorlike to mark normal | ||
| 17 | Lisp area of struct buffer. | ||
| 18 | (mark_object): Use it. Adjust marking of misc objects | ||
| 19 | and related comments. | ||
| 20 | |||
| 1 | 2012-07-02 Paul Eggert <eggert@cs.ucla.edu> | 21 | 2012-07-02 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 22 | ||
| 3 | * alloc.c (mark_object): Remove "#ifdef GC_CHECK_MARKED_OBJECTS" | 23 | * alloc.c (mark_object): Remove "#ifdef GC_CHECK_MARKED_OBJECTS" |
diff --git a/src/alloc.c b/src/alloc.c index b0945aa30de..b329f89d15b 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -1186,21 +1186,6 @@ lisp_align_free (void *block) | |||
| 1186 | MALLOC_UNBLOCK_INPUT; | 1186 | MALLOC_UNBLOCK_INPUT; |
| 1187 | } | 1187 | } |
| 1188 | 1188 | ||
| 1189 | /* Return a new buffer structure allocated from the heap with | ||
| 1190 | a call to lisp_malloc. */ | ||
| 1191 | |||
| 1192 | struct buffer * | ||
| 1193 | allocate_buffer (void) | ||
| 1194 | { | ||
| 1195 | struct buffer *b | ||
| 1196 | = (struct buffer *) lisp_malloc (sizeof (struct buffer), | ||
| 1197 | MEM_TYPE_BUFFER); | ||
| 1198 | XSETPVECTYPESIZE (b, PVEC_BUFFER, | ||
| 1199 | ((sizeof (struct buffer) + sizeof (EMACS_INT) - 1) | ||
| 1200 | / sizeof (EMACS_INT))); | ||
| 1201 | return b; | ||
| 1202 | } | ||
| 1203 | |||
| 1204 | 1189 | ||
| 1205 | #ifndef SYSTEM_MALLOC | 1190 | #ifndef SYSTEM_MALLOC |
| 1206 | 1191 | ||
| @@ -3258,6 +3243,17 @@ allocate_pseudovector (int memlen, int lisplen, int tag) | |||
| 3258 | return v; | 3243 | return v; |
| 3259 | } | 3244 | } |
| 3260 | 3245 | ||
| 3246 | struct buffer * | ||
| 3247 | allocate_buffer (void) | ||
| 3248 | { | ||
| 3249 | struct buffer *b = lisp_malloc (sizeof (struct buffer), MEM_TYPE_BUFFER); | ||
| 3250 | |||
| 3251 | XSETPVECTYPESIZE (b, PVEC_BUFFER, (offsetof (struct buffer, own_text) | ||
| 3252 | - header_size) / word_size); | ||
| 3253 | /* Note that the fields of B are not initialized. */ | ||
| 3254 | return b; | ||
| 3255 | } | ||
| 3256 | |||
| 3261 | struct Lisp_Hash_Table * | 3257 | struct Lisp_Hash_Table * |
| 3262 | allocate_hash_table (void) | 3258 | allocate_hash_table (void) |
| 3263 | { | 3259 | { |
| @@ -5786,15 +5782,29 @@ mark_char_table (struct Lisp_Vector *ptr) | |||
| 5786 | } | 5782 | } |
| 5787 | } | 5783 | } |
| 5788 | 5784 | ||
| 5789 | /* Mark the pointers in a buffer structure. */ | 5785 | /* Mark the chain of overlays starting at PTR. */ |
| 5786 | |||
| 5787 | static void | ||
| 5788 | mark_overlay (struct Lisp_Overlay *ptr) | ||
| 5789 | { | ||
| 5790 | for (; ptr && !ptr->gcmarkbit; ptr = ptr->next) | ||
| 5791 | { | ||
| 5792 | ptr->gcmarkbit = 1; | ||
| 5793 | mark_object (ptr->start); | ||
| 5794 | mark_object (ptr->end); | ||
| 5795 | mark_object (ptr->plist); | ||
| 5796 | } | ||
| 5797 | } | ||
| 5798 | |||
| 5799 | /* Mark Lisp_Objects and special pointers in BUFFER. */ | ||
| 5790 | 5800 | ||
| 5791 | static void | 5801 | static void |
| 5792 | mark_buffer (struct buffer *buffer) | 5802 | mark_buffer (struct buffer *buffer) |
| 5793 | { | 5803 | { |
| 5794 | register Lisp_Object *ptr, tmp; | 5804 | /* This is handled much like other pseudovectors... */ |
| 5805 | mark_vectorlike ((struct Lisp_Vector *) buffer); | ||
| 5795 | 5806 | ||
| 5796 | eassert (!VECTOR_MARKED_P (buffer)); | 5807 | /* ...but there are some buffer-specific things. */ |
| 5797 | VECTOR_MARK (buffer); | ||
| 5798 | 5808 | ||
| 5799 | MARK_INTERVAL_TREE (BUF_INTERVALS (buffer)); | 5809 | MARK_INTERVAL_TREE (BUF_INTERVALS (buffer)); |
| 5800 | 5810 | ||
| @@ -5802,24 +5812,8 @@ mark_buffer (struct buffer *buffer) | |||
| 5802 | a special way just before the sweep phase, and after stripping | 5812 | a special way just before the sweep phase, and after stripping |
| 5803 | some of its elements that are not needed any more. */ | 5813 | some of its elements that are not needed any more. */ |
| 5804 | 5814 | ||
| 5805 | if (buffer->overlays_before) | 5815 | mark_overlay (buffer->overlays_before); |
| 5806 | { | 5816 | mark_overlay (buffer->overlays_after); |
| 5807 | XSETMISC (tmp, buffer->overlays_before); | ||
| 5808 | mark_object (tmp); | ||
| 5809 | } | ||
| 5810 | if (buffer->overlays_after) | ||
| 5811 | { | ||
| 5812 | XSETMISC (tmp, buffer->overlays_after); | ||
| 5813 | mark_object (tmp); | ||
| 5814 | } | ||
| 5815 | |||
| 5816 | /* buffer-local Lisp variables start at `undo_list', | ||
| 5817 | tho only the ones from `name' on are GC'd normally. */ | ||
| 5818 | for (ptr = &buffer->BUFFER_INTERNAL_FIELD (name); | ||
| 5819 | ptr <= &PER_BUFFER_VALUE (buffer, | ||
| 5820 | PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER)); | ||
| 5821 | ptr++) | ||
| 5822 | mark_object (*ptr); | ||
| 5823 | 5817 | ||
| 5824 | /* If this is an indirect buffer, mark its base buffer. */ | 5818 | /* If this is an indirect buffer, mark its base buffer. */ |
| 5825 | if (buffer->base_buffer && !VECTOR_MARKED_P (buffer->base_buffer)) | 5819 | if (buffer->base_buffer && !VECTOR_MARKED_P (buffer->base_buffer)) |
| @@ -6061,52 +6055,35 @@ mark_object (Lisp_Object arg) | |||
| 6061 | 6055 | ||
| 6062 | case Lisp_Misc: | 6056 | case Lisp_Misc: |
| 6063 | CHECK_ALLOCATED_AND_LIVE (live_misc_p); | 6057 | CHECK_ALLOCATED_AND_LIVE (live_misc_p); |
| 6064 | if (XMISCANY (obj)->gcmarkbit) | ||
| 6065 | break; | ||
| 6066 | XMISCANY (obj)->gcmarkbit = 1; | ||
| 6067 | 6058 | ||
| 6068 | switch (XMISCTYPE (obj)) | 6059 | if (XMISCTYPE (obj) == Lisp_Misc_Overlay) |
| 6060 | mark_overlay (XOVERLAY (obj)); | ||
| 6061 | else | ||
| 6069 | { | 6062 | { |
| 6063 | if (XMISCANY (obj)->gcmarkbit) | ||
| 6064 | break; | ||
| 6065 | XMISCANY (obj)->gcmarkbit = 1; | ||
| 6070 | 6066 | ||
| 6071 | case Lisp_Misc_Marker: | 6067 | /* Note that we don't mark thru the marker's |
| 6072 | /* DO NOT mark thru the marker's chain. | 6068 | chain. The buffer's markers chain does not |
| 6073 | The buffer's markers chain does not preserve markers from gc; | 6069 | preserve markers from GC; instead, markers |
| 6074 | instead, markers are removed from the chain when freed by gc. */ | 6070 | are removed from the chain when freed by GC. */ |
| 6075 | break; | ||
| 6076 | 6071 | ||
| 6077 | case Lisp_Misc_Save_Value: | ||
| 6078 | #if GC_MARK_STACK | 6072 | #if GC_MARK_STACK |
| 6079 | { | 6073 | if (XMISCTYPE (obj) == Lisp_Misc_Save_Value) |
| 6080 | register struct Lisp_Save_Value *ptr = XSAVE_VALUE (obj); | 6074 | { |
| 6081 | /* If DOGC is set, POINTER is the address of a memory | 6075 | register struct Lisp_Save_Value *ptr = XSAVE_VALUE (obj); |
| 6082 | area containing INTEGER potential Lisp_Objects. */ | 6076 | /* If DOGC is set, POINTER is the address of a memory |
| 6083 | if (ptr->dogc) | 6077 | area containing INTEGER potential Lisp_Objects. */ |
| 6084 | { | 6078 | if (ptr->dogc) |
| 6085 | Lisp_Object *p = (Lisp_Object *) ptr->pointer; | 6079 | { |
| 6086 | ptrdiff_t nelt; | 6080 | Lisp_Object *p = (Lisp_Object *) ptr->pointer; |
| 6087 | for (nelt = ptr->integer; nelt > 0; nelt--, p++) | 6081 | ptrdiff_t nelt; |
| 6088 | mark_maybe_object (*p); | 6082 | for (nelt = ptr->integer; nelt > 0; nelt--, p++) |
| 6089 | } | 6083 | mark_maybe_object (*p); |
| 6090 | } | 6084 | } |
| 6085 | } | ||
| 6091 | #endif | 6086 | #endif |
| 6092 | break; | ||
| 6093 | |||
| 6094 | case Lisp_Misc_Overlay: | ||
| 6095 | { | ||
| 6096 | struct Lisp_Overlay *ptr = XOVERLAY (obj); | ||
| 6097 | mark_object (ptr->start); | ||
| 6098 | mark_object (ptr->end); | ||
| 6099 | mark_object (ptr->plist); | ||
| 6100 | if (ptr->next) | ||
| 6101 | { | ||
| 6102 | XSETMISC (obj, ptr->next); | ||
| 6103 | goto loop; | ||
| 6104 | } | ||
| 6105 | } | ||
| 6106 | break; | ||
| 6107 | |||
| 6108 | default: | ||
| 6109 | abort (); | ||
| 6110 | } | 6087 | } |
| 6111 | break; | 6088 | break; |
| 6112 | 6089 | ||
diff --git a/src/buffer.c b/src/buffer.c index 89a4e26fb73..08118baa3d7 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -465,11 +465,7 @@ clone_per_buffer_values (struct buffer *from, struct buffer *to) | |||
| 465 | 465 | ||
| 466 | XSETBUFFER (to_buffer, to); | 466 | XSETBUFFER (to_buffer, to); |
| 467 | 467 | ||
| 468 | /* buffer-local Lisp variables start at `undo_list', | 468 | for_each_per_buffer_object_at (offset) |
| 469 | tho only the ones from `name' on are GC'd normally. */ | ||
| 470 | for (offset = PER_BUFFER_VAR_OFFSET (FIRST_FIELD_PER_BUFFER); | ||
| 471 | offset <= PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER); | ||
| 472 | offset += sizeof (Lisp_Object)) | ||
| 473 | { | 469 | { |
| 474 | Lisp_Object obj; | 470 | Lisp_Object obj; |
| 475 | 471 | ||
| @@ -820,14 +816,8 @@ reset_buffer_local_variables (register struct buffer *b, int permanent_too) | |||
| 820 | if (permanent_too || buffer_permanent_local_flags[i] == 0) | 816 | if (permanent_too || buffer_permanent_local_flags[i] == 0) |
| 821 | SET_PER_BUFFER_VALUE_P (b, i, 0); | 817 | SET_PER_BUFFER_VALUE_P (b, i, 0); |
| 822 | 818 | ||
| 823 | /* For each slot that has a default value, | 819 | /* For each slot that has a default value, copy that into the slot. */ |
| 824 | copy that into the slot. */ | 820 | for_each_per_buffer_object_at (offset) |
| 825 | |||
| 826 | /* buffer-local Lisp variables start at `undo_list', | ||
| 827 | tho only the ones from `name' on are GC'd normally. */ | ||
| 828 | for (offset = PER_BUFFER_VAR_OFFSET (FIRST_FIELD_PER_BUFFER); | ||
| 829 | offset <= PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER); | ||
| 830 | offset += sizeof (Lisp_Object)) | ||
| 831 | { | 821 | { |
| 832 | int idx = PER_BUFFER_IDX (offset); | 822 | int idx = PER_BUFFER_IDX (offset); |
| 833 | if ((idx > 0 | 823 | if ((idx > 0 |
| @@ -1063,12 +1053,7 @@ No argument or nil as argument means use current buffer as BUFFER. */) | |||
| 1063 | { | 1053 | { |
| 1064 | int offset, idx; | 1054 | int offset, idx; |
| 1065 | 1055 | ||
| 1066 | /* buffer-local Lisp variables start at `undo_list', | 1056 | for_each_per_buffer_object_at (offset) |
| 1067 | tho only the ones from `name' on are GC'd normally. */ | ||
| 1068 | for (offset = PER_BUFFER_VAR_OFFSET (FIRST_FIELD_PER_BUFFER); | ||
| 1069 | offset <= PER_BUFFER_VAR_OFFSET (LAST_FIELD_PER_BUFFER); | ||
| 1070 | /* sizeof EMACS_INT == sizeof Lisp_Object */ | ||
| 1071 | offset += (sizeof (EMACS_INT))) | ||
| 1072 | { | 1057 | { |
| 1073 | idx = PER_BUFFER_IDX (offset); | 1058 | idx = PER_BUFFER_IDX (offset); |
| 1074 | if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) | 1059 | if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) |
| @@ -4903,9 +4888,7 @@ init_buffer_once (void) | |||
| 4903 | BVAR (&buffer_defaults, case_fold_search) = Qt; | 4888 | BVAR (&buffer_defaults, case_fold_search) = Qt; |
| 4904 | BVAR (&buffer_defaults, auto_fill_function) = Qnil; | 4889 | BVAR (&buffer_defaults, auto_fill_function) = Qnil; |
| 4905 | BVAR (&buffer_defaults, selective_display) = Qnil; | 4890 | BVAR (&buffer_defaults, selective_display) = Qnil; |
| 4906 | #ifndef old | ||
| 4907 | BVAR (&buffer_defaults, selective_display_ellipses) = Qt; | 4891 | BVAR (&buffer_defaults, selective_display_ellipses) = Qt; |
| 4908 | #endif | ||
| 4909 | BVAR (&buffer_defaults, abbrev_table) = Qnil; | 4892 | BVAR (&buffer_defaults, abbrev_table) = Qnil; |
| 4910 | BVAR (&buffer_defaults, display_table) = Qnil; | 4893 | BVAR (&buffer_defaults, display_table) = Qnil; |
| 4911 | BVAR (&buffer_defaults, undo_list) = Qnil; | 4894 | BVAR (&buffer_defaults, undo_list) = Qnil; |
| @@ -4984,9 +4967,7 @@ init_buffer_once (void) | |||
| 4984 | XSETFASTINT (BVAR (&buffer_local_flags, case_fold_search), idx); ++idx; | 4967 | XSETFASTINT (BVAR (&buffer_local_flags, case_fold_search), idx); ++idx; |
| 4985 | XSETFASTINT (BVAR (&buffer_local_flags, auto_fill_function), idx); ++idx; | 4968 | XSETFASTINT (BVAR (&buffer_local_flags, auto_fill_function), idx); ++idx; |
| 4986 | XSETFASTINT (BVAR (&buffer_local_flags, selective_display), idx); ++idx; | 4969 | XSETFASTINT (BVAR (&buffer_local_flags, selective_display), idx); ++idx; |
| 4987 | #ifndef old | ||
| 4988 | XSETFASTINT (BVAR (&buffer_local_flags, selective_display_ellipses), idx); ++idx; | 4970 | XSETFASTINT (BVAR (&buffer_local_flags, selective_display_ellipses), idx); ++idx; |
| 4989 | #endif | ||
| 4990 | XSETFASTINT (BVAR (&buffer_local_flags, tab_width), idx); ++idx; | 4971 | XSETFASTINT (BVAR (&buffer_local_flags, tab_width), idx); ++idx; |
| 4991 | XSETFASTINT (BVAR (&buffer_local_flags, truncate_lines), idx); ++idx; | 4972 | XSETFASTINT (BVAR (&buffer_local_flags, truncate_lines), idx); ++idx; |
| 4992 | XSETFASTINT (BVAR (&buffer_local_flags, word_wrap), idx); ++idx; | 4973 | XSETFASTINT (BVAR (&buffer_local_flags, word_wrap), idx); ++idx; |
| @@ -5594,12 +5575,10 @@ A value of t means that the character ^M makes itself and | |||
| 5594 | all the rest of the line invisible; also, when saving the buffer | 5575 | all the rest of the line invisible; also, when saving the buffer |
| 5595 | in a file, save the ^M as a newline. */); | 5576 | in a file, save the ^M as a newline. */); |
| 5596 | 5577 | ||
| 5597 | #ifndef old | ||
| 5598 | DEFVAR_PER_BUFFER ("selective-display-ellipses", | 5578 | DEFVAR_PER_BUFFER ("selective-display-ellipses", |
| 5599 | &BVAR (current_buffer, selective_display_ellipses), | 5579 | &BVAR (current_buffer, selective_display_ellipses), |
| 5600 | Qnil, | 5580 | Qnil, |
| 5601 | doc: /* Non-nil means display ... on previous line when a line is invisible. */); | 5581 | doc: /* Non-nil means display ... on previous line when a line is invisible. */); |
| 5602 | #endif | ||
| 5603 | 5582 | ||
| 5604 | DEFVAR_PER_BUFFER ("overwrite-mode", &BVAR (current_buffer, overwrite_mode), Qnil, | 5583 | DEFVAR_PER_BUFFER ("overwrite-mode", &BVAR (current_buffer, overwrite_mode), Qnil, |
| 5605 | doc: /* Non-nil if self-insertion should replace existing text. | 5584 | doc: /* Non-nil if self-insertion should replace existing text. |
diff --git a/src/buffer.h b/src/buffer.h index b1ace4663cf..b48791f306f 100644 --- a/src/buffer.h +++ b/src/buffer.h | |||
| @@ -482,142 +482,26 @@ struct buffer_text | |||
| 482 | 482 | ||
| 483 | struct buffer | 483 | struct buffer |
| 484 | { | 484 | { |
| 485 | /* Everything before the `name' slot must be of a non-Lisp_Object type, | 485 | /* HEADER.NEXT is the next buffer, in chain of all buffers, including killed |
| 486 | and every slot after `name' must be a Lisp_Object. | 486 | buffers. This chain, starting from all_buffers, is used only for garbage |
| 487 | 487 | collection, in order to collect killed buffers properly. Note that large | |
| 488 | Check out mark_buffer (alloc.c) to see why. */ | 488 | vectors and large pseudo-vector objects are all on another chain starting |
| 489 | 489 | from large_vectors. */ | |
| 490 | /* HEADER.NEXT is the next buffer, in chain of all buffers, | ||
| 491 | including killed buffers. | ||
| 492 | This chain is used only for garbage collection, in order to | ||
| 493 | collect killed buffers properly. | ||
| 494 | Note that vectors and most pseudovectors are all on one chain, | ||
| 495 | but buffers are on a separate chain of their own. */ | ||
| 496 | struct vectorlike_header header; | 490 | struct vectorlike_header header; |
| 497 | 491 | ||
| 498 | /* This structure holds the coordinates of the buffer contents | ||
| 499 | in ordinary buffers. In indirect buffers, this is not used. */ | ||
| 500 | struct buffer_text own_text; | ||
| 501 | |||
| 502 | /* This points to the `struct buffer_text' that used for this buffer. | ||
| 503 | In an ordinary buffer, this is the own_text field above. | ||
| 504 | In an indirect buffer, this is the own_text field of another buffer. */ | ||
| 505 | struct buffer_text *text; | ||
| 506 | |||
| 507 | /* Char position of point in buffer. */ | ||
| 508 | ptrdiff_t pt; | ||
| 509 | /* Byte position of point in buffer. */ | ||
| 510 | ptrdiff_t pt_byte; | ||
| 511 | /* Char position of beginning of accessible range. */ | ||
| 512 | ptrdiff_t begv; | ||
| 513 | /* Byte position of beginning of accessible range. */ | ||
| 514 | ptrdiff_t begv_byte; | ||
| 515 | /* Char position of end of accessible range. */ | ||
| 516 | ptrdiff_t zv; | ||
| 517 | /* Byte position of end of accessible range. */ | ||
| 518 | ptrdiff_t zv_byte; | ||
| 519 | |||
| 520 | /* In an indirect buffer, this points to the base buffer. | ||
| 521 | In an ordinary buffer, it is 0. */ | ||
| 522 | struct buffer *base_buffer; | ||
| 523 | |||
| 524 | /* A non-zero value in slot IDX means that per-buffer variable | ||
| 525 | with index IDX has a local value in this buffer. The index IDX | ||
| 526 | for a buffer-local variable is stored in that variable's slot | ||
| 527 | in buffer_local_flags as a Lisp integer. If the index is -1, | ||
| 528 | this means the variable is always local in all buffers. */ | ||
| 529 | #define MAX_PER_BUFFER_VARS 50 | ||
| 530 | char local_flags[MAX_PER_BUFFER_VARS]; | ||
| 531 | |||
| 532 | /* Set to the modtime of the visited file when read or written. | ||
| 533 | EMACS_NSECS (modtime) == NONEXISTENT_MODTIME_NSECS means | ||
| 534 | visited file was nonexistent. EMACS_NSECS (modtime) == | ||
| 535 | UNKNOWN_MODTIME_NSECS means visited file modtime unknown; | ||
| 536 | in no case complain about any mismatch on next save attempt. */ | ||
| 537 | #define NONEXISTENT_MODTIME_NSECS (-1) | ||
| 538 | #define UNKNOWN_MODTIME_NSECS (-2) | ||
| 539 | EMACS_TIME modtime; | ||
| 540 | /* Size of the file when modtime was set. This is used to detect the | ||
| 541 | case where the file grew while we were reading it, so the modtime | ||
| 542 | is still the same (since it's rounded up to seconds) but we're actually | ||
| 543 | not up-to-date. -1 means the size is unknown. Only meaningful if | ||
| 544 | modtime is actually set. */ | ||
| 545 | off_t modtime_size; | ||
| 546 | /* The value of text->modiff at the last auto-save. */ | ||
| 547 | EMACS_INT auto_save_modified; | ||
| 548 | /* The value of text->modiff at the last display error. | ||
| 549 | Redisplay of this buffer is inhibited until it changes again. */ | ||
| 550 | EMACS_INT display_error_modiff; | ||
| 551 | /* The time at which we detected a failure to auto-save, | ||
| 552 | Or 0 if we didn't have a failure. */ | ||
| 553 | time_t auto_save_failure_time; | ||
| 554 | /* Position in buffer at which display started | ||
| 555 | the last time this buffer was displayed. */ | ||
| 556 | ptrdiff_t last_window_start; | ||
| 557 | |||
| 558 | /* Set nonzero whenever the narrowing is changed in this buffer. */ | ||
| 559 | int clip_changed; | ||
| 560 | |||
| 561 | /* If the long line scan cache is enabled (i.e. the buffer-local | ||
| 562 | variable cache-long-line-scans is non-nil), newline_cache | ||
| 563 | points to the newline cache, and width_run_cache points to the | ||
| 564 | width run cache. | ||
| 565 | |||
| 566 | The newline cache records which stretches of the buffer are | ||
| 567 | known *not* to contain newlines, so that they can be skipped | ||
| 568 | quickly when we search for newlines. | ||
| 569 | |||
| 570 | The width run cache records which stretches of the buffer are | ||
| 571 | known to contain characters whose widths are all the same. If | ||
| 572 | the width run cache maps a character to a value > 0, that value is | ||
| 573 | the character's width; if it maps a character to zero, we don't | ||
| 574 | know what its width is. This allows compute_motion to process | ||
| 575 | such regions very quickly, using algebra instead of inspecting | ||
| 576 | each character. See also width_table, below. */ | ||
| 577 | struct region_cache *newline_cache; | ||
| 578 | struct region_cache *width_run_cache; | ||
| 579 | |||
| 580 | /* Non-zero means don't use redisplay optimizations for | ||
| 581 | displaying this buffer. */ | ||
| 582 | unsigned prevent_redisplay_optimizations_p : 1; | ||
| 583 | |||
| 584 | /* List of overlays that end at or before the current center, | ||
| 585 | in order of end-position. */ | ||
| 586 | struct Lisp_Overlay *overlays_before; | ||
| 587 | |||
| 588 | /* List of overlays that end after the current center, | ||
| 589 | in order of start-position. */ | ||
| 590 | struct Lisp_Overlay *overlays_after; | ||
| 591 | |||
| 592 | /* Position where the overlay lists are centered. */ | ||
| 593 | ptrdiff_t overlay_center; | ||
| 594 | |||
| 595 | /* Everything from here down must be a Lisp_Object. */ | ||
| 596 | /* buffer-local Lisp variables start at `undo_list', | ||
| 597 | tho only the ones from `name' on are GC'd normally. */ | ||
| 598 | #define FIRST_FIELD_PER_BUFFER undo_list | ||
| 599 | |||
| 600 | /* Changes in the buffer are recorded here for undo. | ||
| 601 | t means don't record anything. | ||
| 602 | This information belongs to the base buffer of an indirect buffer, | ||
| 603 | But we can't store it in the struct buffer_text | ||
| 604 | because local variables have to be right in the struct buffer. | ||
| 605 | So we copy it around in set_buffer_internal. | ||
| 606 | This comes before `name' because it is marked in a special way. */ | ||
| 607 | Lisp_Object BUFFER_INTERNAL_FIELD (undo_list); | ||
| 608 | |||
| 609 | /* The name of this buffer. */ | 492 | /* The name of this buffer. */ |
| 610 | Lisp_Object BUFFER_INTERNAL_FIELD (name); | 493 | Lisp_Object BUFFER_INTERNAL_FIELD (name); |
| 611 | 494 | ||
| 612 | /* The name of the file visited in this buffer, or nil. */ | 495 | /* The name of the file visited in this buffer, or nil. */ |
| 613 | Lisp_Object BUFFER_INTERNAL_FIELD (filename); | 496 | Lisp_Object BUFFER_INTERNAL_FIELD (filename); |
| 614 | /* Dir for expanding relative file names. */ | 497 | |
| 498 | /* Directory for expanding relative file names. */ | ||
| 615 | Lisp_Object BUFFER_INTERNAL_FIELD (directory); | 499 | Lisp_Object BUFFER_INTERNAL_FIELD (directory); |
| 616 | /* True if this buffer has been backed up (if you write to the | 500 | |
| 617 | visited file and it hasn't been backed up, then a backup will | 501 | /* True if this buffer has been backed up (if you write to the visited |
| 618 | be made). */ | 502 | file and it hasn't been backed up, then a backup will be made). */ |
| 619 | /* This isn't really used by the C code, so could be deleted. */ | ||
| 620 | Lisp_Object BUFFER_INTERNAL_FIELD (backed_up); | 503 | Lisp_Object BUFFER_INTERNAL_FIELD (backed_up); |
| 504 | |||
| 621 | /* Length of file when last read or saved. | 505 | /* Length of file when last read or saved. |
| 622 | -1 means auto saving turned off because buffer shrank a lot. | 506 | -1 means auto saving turned off because buffer shrank a lot. |
| 623 | -2 means don't turn off auto saving if buffer shrinks. | 507 | -2 means don't turn off auto saving if buffer shrinks. |
| @@ -625,6 +509,7 @@ struct buffer | |||
| 625 | This is not in the struct buffer_text | 509 | This is not in the struct buffer_text |
| 626 | because it's not used in indirect buffers at all. */ | 510 | because it's not used in indirect buffers at all. */ |
| 627 | Lisp_Object BUFFER_INTERNAL_FIELD (save_length); | 511 | Lisp_Object BUFFER_INTERNAL_FIELD (save_length); |
| 512 | |||
| 628 | /* File name used for auto-saving this buffer. | 513 | /* File name used for auto-saving this buffer. |
| 629 | This is not in the struct buffer_text | 514 | This is not in the struct buffer_text |
| 630 | because it's not used in indirect buffers at all. */ | 515 | because it's not used in indirect buffers at all. */ |
| @@ -632,6 +517,7 @@ struct buffer | |||
| 632 | 517 | ||
| 633 | /* Non-nil if buffer read-only. */ | 518 | /* Non-nil if buffer read-only. */ |
| 634 | Lisp_Object BUFFER_INTERNAL_FIELD (read_only); | 519 | Lisp_Object BUFFER_INTERNAL_FIELD (read_only); |
| 520 | |||
| 635 | /* "The mark". This is a marker which may | 521 | /* "The mark". This is a marker which may |
| 636 | point into this buffer or may point nowhere. */ | 522 | point into this buffer or may point nowhere. */ |
| 637 | Lisp_Object BUFFER_INTERNAL_FIELD (mark); | 523 | Lisp_Object BUFFER_INTERNAL_FIELD (mark); |
| @@ -641,10 +527,12 @@ struct buffer | |||
| 641 | symbols, just the symbol appears as the element. */ | 527 | symbols, just the symbol appears as the element. */ |
| 642 | Lisp_Object BUFFER_INTERNAL_FIELD (local_var_alist); | 528 | Lisp_Object BUFFER_INTERNAL_FIELD (local_var_alist); |
| 643 | 529 | ||
| 644 | /* Symbol naming major mode (eg, lisp-mode). */ | 530 | /* Symbol naming major mode (e.g., lisp-mode). */ |
| 645 | Lisp_Object BUFFER_INTERNAL_FIELD (major_mode); | 531 | Lisp_Object BUFFER_INTERNAL_FIELD (major_mode); |
| 646 | /* Pretty name of major mode (eg, "Lisp"). */ | 532 | |
| 533 | /* Pretty name of major mode (e.g., "Lisp"). */ | ||
| 647 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_name); | 534 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_name); |
| 535 | |||
| 648 | /* Mode line element that controls format of mode line. */ | 536 | /* Mode line element that controls format of mode line. */ |
| 649 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_line_format); | 537 | Lisp_Object BUFFER_INTERNAL_FIELD (mode_line_format); |
| 650 | 538 | ||
| @@ -654,10 +542,13 @@ struct buffer | |||
| 654 | 542 | ||
| 655 | /* Keys that are bound local to this buffer. */ | 543 | /* Keys that are bound local to this buffer. */ |
| 656 | Lisp_Object BUFFER_INTERNAL_FIELD (keymap); | 544 | Lisp_Object BUFFER_INTERNAL_FIELD (keymap); |
| 545 | |||
| 657 | /* This buffer's local abbrev table. */ | 546 | /* This buffer's local abbrev table. */ |
| 658 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_table); | 547 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_table); |
| 548 | |||
| 659 | /* This buffer's syntax table. */ | 549 | /* This buffer's syntax table. */ |
| 660 | Lisp_Object BUFFER_INTERNAL_FIELD (syntax_table); | 550 | Lisp_Object BUFFER_INTERNAL_FIELD (syntax_table); |
| 551 | |||
| 661 | /* This buffer's category table. */ | 552 | /* This buffer's category table. */ |
| 662 | Lisp_Object BUFFER_INTERNAL_FIELD (category_table); | 553 | Lisp_Object BUFFER_INTERNAL_FIELD (category_table); |
| 663 | 554 | ||
| @@ -668,48 +559,61 @@ struct buffer | |||
| 668 | Lisp_Object BUFFER_INTERNAL_FIELD (tab_width); | 559 | Lisp_Object BUFFER_INTERNAL_FIELD (tab_width); |
| 669 | Lisp_Object BUFFER_INTERNAL_FIELD (fill_column); | 560 | Lisp_Object BUFFER_INTERNAL_FIELD (fill_column); |
| 670 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin); | 561 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin); |
| 562 | |||
| 671 | /* Function to call when insert space past fill column. */ | 563 | /* Function to call when insert space past fill column. */ |
| 672 | Lisp_Object BUFFER_INTERNAL_FIELD (auto_fill_function); | 564 | Lisp_Object BUFFER_INTERNAL_FIELD (auto_fill_function); |
| 673 | 565 | ||
| 674 | /* Case table for case-conversion in this buffer. | 566 | /* Case table for case-conversion in this buffer. |
| 675 | This char-table maps each char into its lower-case version. */ | 567 | This char-table maps each char into its lower-case version. */ |
| 676 | Lisp_Object BUFFER_INTERNAL_FIELD (downcase_table); | 568 | Lisp_Object BUFFER_INTERNAL_FIELD (downcase_table); |
| 569 | |||
| 677 | /* Char-table mapping each char to its upper-case version. */ | 570 | /* Char-table mapping each char to its upper-case version. */ |
| 678 | Lisp_Object BUFFER_INTERNAL_FIELD (upcase_table); | 571 | Lisp_Object BUFFER_INTERNAL_FIELD (upcase_table); |
| 572 | |||
| 679 | /* Char-table for conversion for case-folding search. */ | 573 | /* Char-table for conversion for case-folding search. */ |
| 680 | Lisp_Object BUFFER_INTERNAL_FIELD (case_canon_table); | 574 | Lisp_Object BUFFER_INTERNAL_FIELD (case_canon_table); |
| 575 | |||
| 681 | /* Char-table of equivalences for case-folding search. */ | 576 | /* Char-table of equivalences for case-folding search. */ |
| 682 | Lisp_Object BUFFER_INTERNAL_FIELD (case_eqv_table); | 577 | Lisp_Object BUFFER_INTERNAL_FIELD (case_eqv_table); |
| 683 | 578 | ||
| 684 | /* Non-nil means do not display continuation lines. */ | 579 | /* Non-nil means do not display continuation lines. */ |
| 685 | Lisp_Object BUFFER_INTERNAL_FIELD (truncate_lines); | 580 | Lisp_Object BUFFER_INTERNAL_FIELD (truncate_lines); |
| 581 | |||
| 686 | /* Non-nil means to use word wrapping when displaying continuation lines. */ | 582 | /* Non-nil means to use word wrapping when displaying continuation lines. */ |
| 687 | Lisp_Object BUFFER_INTERNAL_FIELD (word_wrap); | 583 | Lisp_Object BUFFER_INTERNAL_FIELD (word_wrap); |
| 584 | |||
| 688 | /* Non-nil means display ctl chars with uparrow. */ | 585 | /* Non-nil means display ctl chars with uparrow. */ |
| 689 | Lisp_Object BUFFER_INTERNAL_FIELD (ctl_arrow); | 586 | Lisp_Object BUFFER_INTERNAL_FIELD (ctl_arrow); |
| 587 | |||
| 690 | /* Non-nil means reorder bidirectional text for display in the | 588 | /* Non-nil means reorder bidirectional text for display in the |
| 691 | visual order. */ | 589 | visual order. */ |
| 692 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_display_reordering); | 590 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_display_reordering); |
| 591 | |||
| 693 | /* If non-nil, specifies which direction of text to force in all the | 592 | /* If non-nil, specifies which direction of text to force in all the |
| 694 | paragraphs of the buffer. Nil means determine paragraph | 593 | paragraphs of the buffer. Nil means determine paragraph |
| 695 | direction dynamically for each paragraph. */ | 594 | direction dynamically for each paragraph. */ |
| 696 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_paragraph_direction); | 595 | Lisp_Object BUFFER_INTERNAL_FIELD (bidi_paragraph_direction); |
| 596 | |||
| 697 | /* Non-nil means do selective display; | 597 | /* Non-nil means do selective display; |
| 698 | see doc string in syms_of_buffer (buffer.c) for details. */ | 598 | see doc string in syms_of_buffer (buffer.c) for details. */ |
| 699 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display); | 599 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display); |
| 700 | #ifndef old | 600 | |
| 701 | /* Non-nil means show ... at end of line followed by invisible lines. */ | 601 | /* Non-nil means show ... at end of line followed by invisible lines. */ |
| 702 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display_ellipses); | 602 | Lisp_Object BUFFER_INTERNAL_FIELD (selective_display_ellipses); |
| 703 | #endif | 603 | |
| 704 | /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */ | 604 | /* Alist of (FUNCTION . STRING) for each minor mode enabled in buffer. */ |
| 705 | Lisp_Object BUFFER_INTERNAL_FIELD (minor_modes); | 605 | Lisp_Object BUFFER_INTERNAL_FIELD (minor_modes); |
| 606 | |||
| 706 | /* t if "self-insertion" should overwrite; `binary' if it should also | 607 | /* t if "self-insertion" should overwrite; `binary' if it should also |
| 707 | overwrite newlines and tabs - for editing executables and the like. */ | 608 | overwrite newlines and tabs - for editing executables and the like. */ |
| 708 | Lisp_Object BUFFER_INTERNAL_FIELD (overwrite_mode); | 609 | Lisp_Object BUFFER_INTERNAL_FIELD (overwrite_mode); |
| 709 | /* non-nil means abbrev mode is on. Expand abbrevs automatically. */ | 610 | |
| 611 | /* Non-nil means abbrev mode is on. Expand abbrevs automatically. */ | ||
| 710 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_mode); | 612 | Lisp_Object BUFFER_INTERNAL_FIELD (abbrev_mode); |
| 613 | |||
| 711 | /* Display table to use for text in this buffer. */ | 614 | /* Display table to use for text in this buffer. */ |
| 712 | Lisp_Object BUFFER_INTERNAL_FIELD (display_table); | 615 | Lisp_Object BUFFER_INTERNAL_FIELD (display_table); |
| 616 | |||
| 713 | /* t means the mark and region are currently active. */ | 617 | /* t means the mark and region are currently active. */ |
| 714 | Lisp_Object BUFFER_INTERNAL_FIELD (mark_active); | 618 | Lisp_Object BUFFER_INTERNAL_FIELD (mark_active); |
| 715 | 619 | ||
| @@ -776,11 +680,13 @@ struct buffer | |||
| 776 | 680 | ||
| 777 | /* Widths of left and right marginal areas for windows displaying | 681 | /* Widths of left and right marginal areas for windows displaying |
| 778 | this buffer. */ | 682 | this buffer. */ |
| 779 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin_cols), BUFFER_INTERNAL_FIELD (right_margin_cols); | 683 | Lisp_Object BUFFER_INTERNAL_FIELD (left_margin_cols); |
| 684 | Lisp_Object BUFFER_INTERNAL_FIELD (right_margin_cols); | ||
| 780 | 685 | ||
| 781 | /* Widths of left and right fringe areas for windows displaying | 686 | /* Widths of left and right fringe areas for windows displaying |
| 782 | this buffer. */ | 687 | this buffer. */ |
| 783 | Lisp_Object BUFFER_INTERNAL_FIELD (left_fringe_width), BUFFER_INTERNAL_FIELD (right_fringe_width); | 688 | Lisp_Object BUFFER_INTERNAL_FIELD (left_fringe_width); |
| 689 | Lisp_Object BUFFER_INTERNAL_FIELD (right_fringe_width); | ||
| 784 | 690 | ||
| 785 | /* Non-nil means fringes are drawn outside display margins; | 691 | /* Non-nil means fringes are drawn outside display margins; |
| 786 | othersize draw them between margin areas and text. */ | 692 | othersize draw them between margin areas and text. */ |
| @@ -788,7 +694,8 @@ struct buffer | |||
| 788 | 694 | ||
| 789 | /* Width and type of scroll bar areas for windows displaying | 695 | /* Width and type of scroll bar areas for windows displaying |
| 790 | this buffer. */ | 696 | this buffer. */ |
| 791 | Lisp_Object BUFFER_INTERNAL_FIELD (scroll_bar_width), BUFFER_INTERNAL_FIELD (vertical_scroll_bar_type); | 697 | Lisp_Object BUFFER_INTERNAL_FIELD (scroll_bar_width); |
| 698 | Lisp_Object BUFFER_INTERNAL_FIELD (vertical_scroll_bar_type); | ||
| 792 | 699 | ||
| 793 | /* Non-nil means indicate lines not displaying text (in a style | 700 | /* Non-nil means indicate lines not displaying text (in a style |
| 794 | like vi). */ | 701 | like vi). */ |
| @@ -826,13 +733,127 @@ struct buffer | |||
| 826 | in the display of this buffer. */ | 733 | in the display of this buffer. */ |
| 827 | Lisp_Object BUFFER_INTERNAL_FIELD (extra_line_spacing); | 734 | Lisp_Object BUFFER_INTERNAL_FIELD (extra_line_spacing); |
| 828 | 735 | ||
| 829 | /* *Cursor type to display in non-selected windows. | 736 | /* Cursor type to display in non-selected windows. |
| 830 | t means to use hollow box cursor. | 737 | t means to use hollow box cursor. |
| 831 | See `cursor-type' for other values. */ | 738 | See `cursor-type' for other values. */ |
| 832 | Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows); | 739 | Lisp_Object BUFFER_INTERNAL_FIELD (cursor_in_non_selected_windows); |
| 833 | 740 | ||
| 834 | /* This must be the last field in the above list. */ | 741 | /* No more Lisp_Object beyond this point. Except undo_list, |
| 835 | #define LAST_FIELD_PER_BUFFER cursor_in_non_selected_windows | 742 | which is handled specially in Fgarbage_collect . */ |
| 743 | |||
| 744 | /* This structure holds the coordinates of the buffer contents | ||
| 745 | in ordinary buffers. In indirect buffers, this is not used. */ | ||
| 746 | struct buffer_text own_text; | ||
| 747 | |||
| 748 | /* This points to the `struct buffer_text' that used for this buffer. | ||
| 749 | In an ordinary buffer, this is the own_text field above. | ||
| 750 | In an indirect buffer, this is the own_text field of another buffer. */ | ||
| 751 | struct buffer_text *text; | ||
| 752 | |||
| 753 | /* Char position of point in buffer. */ | ||
| 754 | ptrdiff_t pt; | ||
| 755 | |||
| 756 | /* Byte position of point in buffer. */ | ||
| 757 | ptrdiff_t pt_byte; | ||
| 758 | |||
| 759 | /* Char position of beginning of accessible range. */ | ||
| 760 | ptrdiff_t begv; | ||
| 761 | |||
| 762 | /* Byte position of beginning of accessible range. */ | ||
| 763 | ptrdiff_t begv_byte; | ||
| 764 | |||
| 765 | /* Char position of end of accessible range. */ | ||
| 766 | ptrdiff_t zv; | ||
| 767 | |||
| 768 | /* Byte position of end of accessible range. */ | ||
| 769 | ptrdiff_t zv_byte; | ||
| 770 | |||
| 771 | /* In an indirect buffer, this points to the base buffer. | ||
| 772 | In an ordinary buffer, it is 0. */ | ||
| 773 | struct buffer *base_buffer; | ||
| 774 | |||
| 775 | /* A non-zero value in slot IDX means that per-buffer variable | ||
| 776 | with index IDX has a local value in this buffer. The index IDX | ||
| 777 | for a buffer-local variable is stored in that variable's slot | ||
| 778 | in buffer_local_flags as a Lisp integer. If the index is -1, | ||
| 779 | this means the variable is always local in all buffers. */ | ||
| 780 | #define MAX_PER_BUFFER_VARS 50 | ||
| 781 | char local_flags[MAX_PER_BUFFER_VARS]; | ||
| 782 | |||
| 783 | /* Set to the modtime of the visited file when read or written. | ||
| 784 | EMACS_NSECS (modtime) == NONEXISTENT_MODTIME_NSECS means | ||
| 785 | visited file was nonexistent. EMACS_NSECS (modtime) == | ||
| 786 | UNKNOWN_MODTIME_NSECS means visited file modtime unknown; | ||
| 787 | in no case complain about any mismatch on next save attempt. */ | ||
| 788 | #define NONEXISTENT_MODTIME_NSECS (-1) | ||
| 789 | #define UNKNOWN_MODTIME_NSECS (-2) | ||
| 790 | EMACS_TIME modtime; | ||
| 791 | |||
| 792 | /* Size of the file when modtime was set. This is used to detect the | ||
| 793 | case where the file grew while we were reading it, so the modtime | ||
| 794 | is still the same (since it's rounded up to seconds) but we're actually | ||
| 795 | not up-to-date. -1 means the size is unknown. Only meaningful if | ||
| 796 | modtime is actually set. */ | ||
| 797 | off_t modtime_size; | ||
| 798 | |||
| 799 | /* The value of text->modiff at the last auto-save. */ | ||
| 800 | EMACS_INT auto_save_modified; | ||
| 801 | |||
| 802 | /* The value of text->modiff at the last display error. | ||
| 803 | Redisplay of this buffer is inhibited until it changes again. */ | ||
| 804 | EMACS_INT display_error_modiff; | ||
| 805 | |||
| 806 | /* The time at which we detected a failure to auto-save, | ||
| 807 | Or 0 if we didn't have a failure. */ | ||
| 808 | time_t auto_save_failure_time; | ||
| 809 | |||
| 810 | /* Position in buffer at which display started | ||
| 811 | the last time this buffer was displayed. */ | ||
| 812 | ptrdiff_t last_window_start; | ||
| 813 | |||
| 814 | /* If the long line scan cache is enabled (i.e. the buffer-local | ||
| 815 | variable cache-long-line-scans is non-nil), newline_cache | ||
| 816 | points to the newline cache, and width_run_cache points to the | ||
| 817 | width run cache. | ||
| 818 | |||
| 819 | The newline cache records which stretches of the buffer are | ||
| 820 | known *not* to contain newlines, so that they can be skipped | ||
| 821 | quickly when we search for newlines. | ||
| 822 | |||
| 823 | The width run cache records which stretches of the buffer are | ||
| 824 | known to contain characters whose widths are all the same. If | ||
| 825 | the width run cache maps a character to a value > 0, that value is | ||
| 826 | the character's width; if it maps a character to zero, we don't | ||
| 827 | know what its width is. This allows compute_motion to process | ||
| 828 | such regions very quickly, using algebra instead of inspecting | ||
| 829 | each character. See also width_table, below. */ | ||
| 830 | struct region_cache *newline_cache; | ||
| 831 | struct region_cache *width_run_cache; | ||
| 832 | |||
| 833 | /* Non-zero means don't use redisplay optimizations for | ||
| 834 | displaying this buffer. */ | ||
| 835 | unsigned prevent_redisplay_optimizations_p : 1; | ||
| 836 | |||
| 837 | /* Non-zero whenever the narrowing is changed in this buffer. */ | ||
| 838 | unsigned clip_changed : 1; | ||
| 839 | |||
| 840 | /* List of overlays that end at or before the current center, | ||
| 841 | in order of end-position. */ | ||
| 842 | struct Lisp_Overlay *overlays_before; | ||
| 843 | |||
| 844 | /* List of overlays that end after the current center, | ||
| 845 | in order of start-position. */ | ||
| 846 | struct Lisp_Overlay *overlays_after; | ||
| 847 | |||
| 848 | /* Position where the overlay lists are centered. */ | ||
| 849 | ptrdiff_t overlay_center; | ||
| 850 | |||
| 851 | /* Changes in the buffer are recorded here for undo, and t means | ||
| 852 | don't record anything. This information belongs to the base | ||
| 853 | buffer of an indirect buffer. But we can't store it in the | ||
| 854 | struct buffer_text because local variables have to be right in | ||
| 855 | the struct buffer. So we copy it around in set_buffer_internal. */ | ||
| 856 | Lisp_Object BUFFER_INTERNAL_FIELD (undo_list); | ||
| 836 | }; | 857 | }; |
| 837 | 858 | ||
| 838 | 859 | ||
| @@ -896,10 +917,10 @@ extern void mmap_set_vars (int); | |||
| 896 | 917 | ||
| 897 | #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ | 918 | #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq) \ |
| 898 | do { \ | 919 | do { \ |
| 899 | ptrdiff_t maxlen = 40; \ | 920 | ptrdiff_t maxlen = 40; \ |
| 900 | overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ | 921 | overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \ |
| 901 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ | 922 | noverlays = overlays_at (posn, 0, &overlays, &maxlen, \ |
| 902 | nextp, NULL, chrq); \ | 923 | nextp, NULL, chrq); \ |
| 903 | if (noverlays > maxlen) \ | 924 | if (noverlays > maxlen) \ |
| 904 | { \ | 925 | { \ |
| 905 | maxlen = noverlays; \ | 926 | maxlen = noverlays; \ |
| @@ -992,6 +1013,15 @@ extern int last_per_buffer_idx; | |||
| 992 | #define PER_BUFFER_VAR_OFFSET(VAR) \ | 1013 | #define PER_BUFFER_VAR_OFFSET(VAR) \ |
| 993 | offsetof (struct buffer, BUFFER_INTERNAL_FIELD (VAR)) | 1014 | offsetof (struct buffer, BUFFER_INTERNAL_FIELD (VAR)) |
| 994 | 1015 | ||
| 1016 | /* Used to iterate over normal Lisp_Object fields of struct buffer (all | ||
| 1017 | Lisp_Objects except undo_list). If you add, remove, or reorder | ||
| 1018 | Lisp_Objects in a struct buffer, make sure that this is still correct. */ | ||
| 1019 | |||
| 1020 | #define for_each_per_buffer_object_at(offset) \ | ||
| 1021 | for (offset = PER_BUFFER_VAR_OFFSET (name); \ | ||
| 1022 | offset <= PER_BUFFER_VAR_OFFSET (cursor_in_non_selected_windows); \ | ||
| 1023 | offset += sizeof (Lisp_Object)) | ||
| 1024 | |||
| 995 | /* Return the index of buffer-local variable VAR. Each per-buffer | 1025 | /* Return the index of buffer-local variable VAR. Each per-buffer |
| 996 | variable has an index > 0 associated with it, except when it always | 1026 | variable has an index > 0 associated with it, except when it always |
| 997 | has buffer-local values, in which case the index is -1. If this is | 1027 | has buffer-local values, in which case the index is -1. If this is |