comparison src/buffer.c @ 51844:c5036e7cc93b

(overlay_strings, recenter_overlay_lists): Fix typo in eassert in last commit. (unchain_overlay): New function. (add_overlay_mod_hooklist): Use AREF. (copy_overlays, reset_buffer, overlays_at, overlays_in) (overlay_touches_p, overlay_strings, recenter_overlay_lists) (fix_overlays_in_range, fix_overlays_before, Fmake_overlay) (Fmove_overlay, Fdelete_overlay, Foverlay_lists) (report_overlay_modification, evaporate_overlays, init_buffer_once): Adjust to new type of overlays_(before|after).
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 09 Jul 2003 15:09:12 +0000
parents 8f62ae8e410c
children fd71e1aaa838
comparison
equal deleted inserted replaced
51843:65772ad7d4e1 51844:c5036e7cc93b
181 Lisp_Object Qinsert_in_front_hooks; 181 Lisp_Object Qinsert_in_front_hooks;
182 Lisp_Object Qinsert_behind_hooks; 182 Lisp_Object Qinsert_behind_hooks;
183 183
184 static void alloc_buffer_text P_ ((struct buffer *, size_t)); 184 static void alloc_buffer_text P_ ((struct buffer *, size_t));
185 static void free_buffer_text P_ ((struct buffer *b)); 185 static void free_buffer_text P_ ((struct buffer *b));
186 static Lisp_Object copy_overlays P_ ((struct buffer *, Lisp_Object)); 186 static struct Lisp_Overlay * copy_overlays P_ ((struct buffer *, struct Lisp_Overlay *));
187 static void modify_overlay P_ ((struct buffer *, int, int)); 187 static void modify_overlay P_ ((struct buffer *, int, int));
188 188
189 189
190 /* For debugging; temporary. See set_buffer_internal. */ 190 /* For debugging; temporary. See set_buffer_internal. */
191 /* Lisp_Object Qlisp_mode, Vcheck_symbol; */ 191 /* Lisp_Object Qlisp_mode, Vcheck_symbol; */
432 432
433 433
434 /* Return a list of overlays which is a copy of the overlay list 434 /* Return a list of overlays which is a copy of the overlay list
435 LIST, but for buffer B. */ 435 LIST, but for buffer B. */
436 436
437 static Lisp_Object 437 static struct Lisp_Overlay *
438 copy_overlays (b, list) 438 copy_overlays (b, list)
439 struct buffer *b; 439 struct buffer *b;
440 Lisp_Object list; 440 struct Lisp_Overlay *list;
441 { 441 {
442 Lisp_Object result, buffer; 442 Lisp_Object buffer;
443 struct Lisp_Overlay *result = NULL, *tail = NULL;
443 444
444 XSETBUFFER (buffer, b); 445 XSETBUFFER (buffer, b);
445 446
446 for (result = Qnil; CONSP (list); list = XCDR (list)) 447 for (; list; list = list->next)
447 { 448 {
448 Lisp_Object overlay, start, end, old_overlay; 449 Lisp_Object overlay, start, end, old_overlay;
449 int charpos; 450 int charpos;
450 451
451 old_overlay = XCAR (list); 452 XSETMISC (old_overlay, list);
452 charpos = marker_position (OVERLAY_START (old_overlay)); 453 charpos = marker_position (OVERLAY_START (old_overlay));
453 start = Fmake_marker (); 454 start = Fmake_marker ();
454 Fset_marker (start, make_number (charpos), buffer); 455 Fset_marker (start, make_number (charpos), buffer);
455 XMARKER (start)->insertion_type 456 XMARKER (start)->insertion_type
456 = XMARKER (OVERLAY_START (old_overlay))->insertion_type; 457 = XMARKER (OVERLAY_START (old_overlay))->insertion_type;
464 overlay = allocate_misc (); 465 overlay = allocate_misc ();
465 XMISCTYPE (overlay) = Lisp_Misc_Overlay; 466 XMISCTYPE (overlay) = Lisp_Misc_Overlay;
466 OVERLAY_START (overlay) = start; 467 OVERLAY_START (overlay) = start;
467 OVERLAY_END (overlay) = end; 468 OVERLAY_END (overlay) = end;
468 OVERLAY_PLIST (overlay) = Fcopy_sequence (OVERLAY_PLIST (old_overlay)); 469 OVERLAY_PLIST (overlay) = Fcopy_sequence (OVERLAY_PLIST (old_overlay));
469 470 XOVERLAY (overlay)->next = NULL;
470 result = Fcons (overlay, result); 471
471 } 472 if (tail)
472 473 tail = tail->next = XOVERLAY (overlay);
473 return Fnreverse (result); 474 else
475 result = tail = XOVERLAY (overlay);
476 }
477
478 return result;
474 } 479 }
475 480
476 481
477 /* Clone per-buffer values of buffer FROM. 482 /* Clone per-buffer values of buffer FROM.
478 483
644 b->backed_up = Qnil; 649 b->backed_up = Qnil;
645 b->auto_save_modified = 0; 650 b->auto_save_modified = 0;
646 b->auto_save_failure_time = -1; 651 b->auto_save_failure_time = -1;
647 b->auto_save_file_name = Qnil; 652 b->auto_save_file_name = Qnil;
648 b->read_only = Qnil; 653 b->read_only = Qnil;
649 b->overlays_before = Qnil; 654 b->overlays_before = NULL;
650 b->overlays_after = Qnil; 655 b->overlays_after = NULL;
651 b->overlay_center = BEG; 656 b->overlay_center = BEG;
652 b->mark_active = Qnil; 657 b->mark_active = Qnil;
653 b->point_before_scroll = Qnil; 658 b->point_before_scroll = Qnil;
654 b->file_format = Qnil; 659 b->file_format = Qnil;
655 b->last_selected_window = Qnil; 660 b->last_selected_window = Qnil;
2426 int *len_ptr; 2431 int *len_ptr;
2427 int *next_ptr; 2432 int *next_ptr;
2428 int *prev_ptr; 2433 int *prev_ptr;
2429 int change_req; 2434 int change_req;
2430 { 2435 {
2431 Lisp_Object tail, overlay, start, end; 2436 Lisp_Object overlay, start, end;
2437 struct Lisp_Overlay *tail;
2432 int idx = 0; 2438 int idx = 0;
2433 int len = *len_ptr; 2439 int len = *len_ptr;
2434 Lisp_Object *vec = *vec_ptr; 2440 Lisp_Object *vec = *vec_ptr;
2435 int next = ZV; 2441 int next = ZV;
2436 int prev = BEGV; 2442 int prev = BEGV;
2437 int inhibit_storing = 0; 2443 int inhibit_storing = 0;
2438 2444
2439 for (tail = current_buffer->overlays_before; 2445 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
2440 GC_CONSP (tail);
2441 tail = XCDR (tail))
2442 { 2446 {
2443 int startpos, endpos; 2447 int startpos, endpos;
2444 2448
2445 overlay = XCAR (tail); 2449 XSETMISC (overlay, tail);
2446 2450
2447 start = OVERLAY_START (overlay); 2451 start = OVERLAY_START (overlay);
2448 end = OVERLAY_END (overlay); 2452 end = OVERLAY_END (overlay);
2449 endpos = OVERLAY_POSITION (end); 2453 endpos = OVERLAY_POSITION (end);
2450 if (endpos < pos) 2454 if (endpos < pos)
2487 } 2491 }
2488 else if (startpos < next) 2492 else if (startpos < next)
2489 next = startpos; 2493 next = startpos;
2490 } 2494 }
2491 2495
2492 for (tail = current_buffer->overlays_after; 2496 for (tail = current_buffer->overlays_after; tail; tail = tail->next)
2493 GC_CONSP (tail);
2494 tail = XCDR (tail))
2495 { 2497 {
2496 int startpos, endpos; 2498 int startpos, endpos;
2497 2499
2498 overlay = XCAR (tail); 2500 XSETMISC (overlay, tail);
2499 2501
2500 start = OVERLAY_START (overlay); 2502 start = OVERLAY_START (overlay);
2501 end = OVERLAY_END (overlay); 2503 end = OVERLAY_END (overlay);
2502 startpos = OVERLAY_POSITION (start); 2504 startpos = OVERLAY_POSITION (start);
2503 if (pos < startpos) 2505 if (pos < startpos)
2572 Lisp_Object **vec_ptr; 2574 Lisp_Object **vec_ptr;
2573 int *len_ptr; 2575 int *len_ptr;
2574 int *next_ptr; 2576 int *next_ptr;
2575 int *prev_ptr; 2577 int *prev_ptr;
2576 { 2578 {
2577 Lisp_Object tail, overlay, ostart, oend; 2579 Lisp_Object overlay, ostart, oend;
2580 struct Lisp_Overlay *tail;
2578 int idx = 0; 2581 int idx = 0;
2579 int len = *len_ptr; 2582 int len = *len_ptr;
2580 Lisp_Object *vec = *vec_ptr; 2583 Lisp_Object *vec = *vec_ptr;
2581 int next = ZV; 2584 int next = ZV;
2582 int prev = BEGV; 2585 int prev = BEGV;
2583 int inhibit_storing = 0; 2586 int inhibit_storing = 0;
2584 2587
2585 for (tail = current_buffer->overlays_before; 2588 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
2586 GC_CONSP (tail);
2587 tail = XCDR (tail))
2588 { 2589 {
2589 int startpos, endpos; 2590 int startpos, endpos;
2590 2591
2591 overlay = XCAR (tail); 2592 XSETMISC (overlay, tail);
2592 2593
2593 ostart = OVERLAY_START (overlay); 2594 ostart = OVERLAY_START (overlay);
2594 oend = OVERLAY_END (overlay); 2595 oend = OVERLAY_END (overlay);
2595 endpos = OVERLAY_POSITION (oend); 2596 endpos = OVERLAY_POSITION (oend);
2596 if (endpos < beg) 2597 if (endpos < beg)
2630 } 2631 }
2631 else if (startpos < next) 2632 else if (startpos < next)
2632 next = startpos; 2633 next = startpos;
2633 } 2634 }
2634 2635
2635 for (tail = current_buffer->overlays_after; 2636 for (tail = current_buffer->overlays_after; tail; tail = tail->next)
2636 GC_CONSP (tail);
2637 tail = XCDR (tail))
2638 { 2637 {
2639 int startpos, endpos; 2638 int startpos, endpos;
2640 2639
2641 overlay = XCAR (tail); 2640 XSETMISC (overlay, tail);
2642 2641
2643 ostart = OVERLAY_START (overlay); 2642 ostart = OVERLAY_START (overlay);
2644 oend = OVERLAY_END (overlay); 2643 oend = OVERLAY_END (overlay);
2645 startpos = OVERLAY_POSITION (ostart); 2644 startpos = OVERLAY_POSITION (ostart);
2646 if (end < startpos) 2645 if (end < startpos)
2722 /* Fast function to just test if we're at an overlay boundary. */ 2721 /* Fast function to just test if we're at an overlay boundary. */
2723 int 2722 int
2724 overlay_touches_p (pos) 2723 overlay_touches_p (pos)
2725 int pos; 2724 int pos;
2726 { 2725 {
2727 Lisp_Object tail, overlay; 2726 Lisp_Object overlay;
2728 2727 struct Lisp_Overlay *tail;
2729 for (tail = current_buffer->overlays_before; GC_CONSP (tail); 2728
2730 tail = XCDR (tail)) 2729 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
2731 { 2730 {
2732 int endpos; 2731 int endpos;
2733 2732
2734 overlay = XCAR (tail); 2733 XSETMISC (overlay ,tail);
2735 if (!GC_OVERLAYP (overlay)) 2734 if (!GC_OVERLAYP (overlay))
2736 abort (); 2735 abort ();
2737 2736
2738 endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); 2737 endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
2739 if (endpos < pos) 2738 if (endpos < pos)
2740 break; 2739 break;
2741 if (endpos == pos || OVERLAY_POSITION (OVERLAY_START (overlay)) == pos) 2740 if (endpos == pos || OVERLAY_POSITION (OVERLAY_START (overlay)) == pos)
2742 return 1; 2741 return 1;
2743 } 2742 }
2744 2743
2745 for (tail = current_buffer->overlays_after; GC_CONSP (tail); 2744 for (tail = current_buffer->overlays_after; tail; tail = tail->next)
2746 tail = XCDR (tail))
2747 { 2745 {
2748 int startpos; 2746 int startpos;
2749 2747
2750 overlay = XCAR (tail); 2748 XSETMISC (overlay, tail);
2751 if (!GC_OVERLAYP (overlay)) 2749 if (!GC_OVERLAYP (overlay))
2752 abort (); 2750 abort ();
2753 2751
2754 startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); 2752 startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
2755 if (pos < startpos) 2753 if (pos < startpos)
2944 overlay_strings (pos, w, pstr) 2942 overlay_strings (pos, w, pstr)
2945 EMACS_INT pos; 2943 EMACS_INT pos;
2946 struct window *w; 2944 struct window *w;
2947 unsigned char **pstr; 2945 unsigned char **pstr;
2948 { 2946 {
2949 Lisp_Object ov, overlay, window, str; 2947 Lisp_Object overlay, window, str;
2948 struct Lisp_Overlay *ov;
2950 int startpos, endpos; 2949 int startpos, endpos;
2951 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); 2950 int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
2952 2951
2953 overlay_heads.used = overlay_heads.bytes = 0; 2952 overlay_heads.used = overlay_heads.bytes = 0;
2954 overlay_tails.used = overlay_tails.bytes = 0; 2953 overlay_tails.used = overlay_tails.bytes = 0;
2955 for (ov = current_buffer->overlays_before; CONSP (ov); ov = XCDR (ov)) 2954 for (ov = current_buffer->overlays_before; ov; ov = ov->next)
2956 { 2955 {
2957 overlay = XCAR (ov); 2956 XSETMISC (overlay, ov);
2958 eassert (OVERLAYP (overlay)); 2957 eassert (OVERLAYP (overlay));
2959 2958
2960 startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); 2959 startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
2961 endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); 2960 endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
2962 if (endpos < pos) 2961 if (endpos < pos)
2978 && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str))) 2977 && (str = Foverlay_get (overlay, Qafter_string), STRINGP (str)))
2979 record_overlay_string (&overlay_tails, str, Qnil, 2978 record_overlay_string (&overlay_tails, str, Qnil,
2980 Foverlay_get (overlay, Qpriority), 2979 Foverlay_get (overlay, Qpriority),
2981 endpos - startpos); 2980 endpos - startpos);
2982 } 2981 }
2983 for (ov = current_buffer->overlays_after; CONSP (ov); ov = XCDR (ov)) 2982 for (ov = current_buffer->overlays_after; ov; ov = ov->next)
2984 { 2983 {
2985 overlay = XCAR (ov); 2984 XSETMISC (overlay, ov);
2986 eassert (!OVERLAYP (overlay)); 2985 eassert (OVERLAYP (overlay));
2987 2986
2988 startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); 2987 startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
2989 endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); 2988 endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
2990 if (startpos > pos) 2989 if (startpos > pos)
2991 break; 2990 break;
3068 void 3067 void
3069 recenter_overlay_lists (buf, pos) 3068 recenter_overlay_lists (buf, pos)
3070 struct buffer *buf; 3069 struct buffer *buf;
3071 EMACS_INT pos; 3070 EMACS_INT pos;
3072 { 3071 {
3073 Lisp_Object overlay, tail, next, prev, beg, end; 3072 Lisp_Object overlay, beg, end;
3073 struct Lisp_Overlay *prev, *tail, *next;
3074 3074
3075 /* See if anything in overlays_before should move to overlays_after. */ 3075 /* See if anything in overlays_before should move to overlays_after. */
3076 3076
3077 /* We don't strictly need prev in this loop; it should always be nil. 3077 /* We don't strictly need prev in this loop; it should always be nil.
3078 But we use it for symmetry and in case that should cease to be true 3078 But we use it for symmetry and in case that should cease to be true
3079 with some future change. */ 3079 with some future change. */
3080 prev = Qnil; 3080 prev = NULL;
3081 for (tail = buf->overlays_before; 3081 for (tail = buf->overlays_before; tail; prev = tail, tail = next)
3082 CONSP (tail); 3082 {
3083 prev = tail, tail = next) 3083 next = tail->next;
3084 { 3084 XSETMISC (overlay, tail);
3085 next = XCDR (tail);
3086 overlay = XCAR (tail);
3087 3085
3088 /* If the overlay is not valid, get rid of it. */ 3086 /* If the overlay is not valid, get rid of it. */
3089 if (!OVERLAY_VALID (overlay)) 3087 if (!OVERLAY_VALID (overlay))
3090 #if 1 3088 #if 1
3091 abort (); 3089 abort ();
3106 3104
3107 if (OVERLAY_POSITION (end) > pos) 3105 if (OVERLAY_POSITION (end) > pos)
3108 { 3106 {
3109 /* OVERLAY needs to be moved. */ 3107 /* OVERLAY needs to be moved. */
3110 int where = OVERLAY_POSITION (beg); 3108 int where = OVERLAY_POSITION (beg);
3111 Lisp_Object other, other_prev; 3109 struct Lisp_Overlay *other, *other_prev;
3112 3110
3113 /* Splice the cons cell TAIL out of overlays_before. */ 3111 /* Splice the cons cell TAIL out of overlays_before. */
3114 if (!NILP (prev)) 3112 if (prev)
3115 XSETCDR (prev, next); 3113 prev->next = next;
3116 else 3114 else
3117 buf->overlays_before = next; 3115 buf->overlays_before = next;
3118 3116
3119 /* Search thru overlays_after for where to put it. */ 3117 /* Search thru overlays_after for where to put it. */
3120 other_prev = Qnil; 3118 other_prev = NULL;
3121 for (other = buf->overlays_after; 3119 for (other = buf->overlays_after; other;
3122 CONSP (other); 3120 other_prev = other, other = other->next)
3123 other_prev = other, other = XCDR (other))
3124 { 3121 {
3125 Lisp_Object otherbeg, otheroverlay; 3122 Lisp_Object otherbeg, otheroverlay;
3126 3123
3127 otheroverlay = XCAR (other); 3124 XSETMISC (otheroverlay, other);
3128 eassert (! OVERLAY_VALID (otheroverlay)); 3125 eassert (OVERLAY_VALID (otheroverlay));
3129 3126
3130 otherbeg = OVERLAY_START (otheroverlay); 3127 otherbeg = OVERLAY_START (otheroverlay);
3131 if (OVERLAY_POSITION (otherbeg) >= where) 3128 if (OVERLAY_POSITION (otherbeg) >= where)
3132 break; 3129 break;
3133 } 3130 }
3134 3131
3135 /* Add TAIL to overlays_after before OTHER. */ 3132 /* Add TAIL to overlays_after before OTHER. */
3136 XSETCDR (tail, other); 3133 tail->next = other;
3137 if (!NILP (other_prev)) 3134 if (other_prev)
3138 XSETCDR (other_prev, tail); 3135 other_prev->next = tail;
3139 else 3136 else
3140 buf->overlays_after = tail; 3137 buf->overlays_after = tail;
3141 tail = prev; 3138 tail = prev;
3142 } 3139 }
3143 else 3140 else
3146 so stop now. */ 3143 so stop now. */
3147 break; 3144 break;
3148 } 3145 }
3149 3146
3150 /* See if anything in overlays_after should be in overlays_before. */ 3147 /* See if anything in overlays_after should be in overlays_before. */
3151 prev = Qnil; 3148 prev = NULL;
3152 for (tail = buf->overlays_after; 3149 for (tail = buf->overlays_after; tail; prev = tail, tail = next)
3153 CONSP (tail); 3150 {
3154 prev = tail, tail = next) 3151 next = tail->next;
3155 { 3152 XSETMISC (overlay, tail);
3156 next = XCDR (tail);
3157 overlay = XCAR (tail);
3158 3153
3159 /* If the overlay is not valid, get rid of it. */ 3154 /* If the overlay is not valid, get rid of it. */
3160 if (!OVERLAY_VALID (overlay)) 3155 if (!OVERLAY_VALID (overlay))
3161 #if 1 3156 #if 1
3162 abort (); 3157 abort ();
3182 3177
3183 if (OVERLAY_POSITION (end) <= pos) 3178 if (OVERLAY_POSITION (end) <= pos)
3184 { 3179 {
3185 /* OVERLAY needs to be moved. */ 3180 /* OVERLAY needs to be moved. */
3186 int where = OVERLAY_POSITION (end); 3181 int where = OVERLAY_POSITION (end);
3187 Lisp_Object other, other_prev; 3182 struct Lisp_Overlay *other, *other_prev;
3188 3183
3189 /* Splice the cons cell TAIL out of overlays_after. */ 3184 /* Splice the cons cell TAIL out of overlays_after. */
3190 if (!NILP (prev)) 3185 if (prev)
3191 XSETCDR (prev, next); 3186 prev->next = next;
3192 else 3187 else
3193 buf->overlays_after = next; 3188 buf->overlays_after = next;
3194 3189
3195 /* Search thru overlays_before for where to put it. */ 3190 /* Search thru overlays_before for where to put it. */
3196 other_prev = Qnil; 3191 other_prev = NULL;
3197 for (other = buf->overlays_before; 3192 for (other = buf->overlays_before; other;
3198 CONSP (other); 3193 other_prev = other, other = other->next)
3199 other_prev = other, other = XCDR (other))
3200 { 3194 {
3201 Lisp_Object otherend, otheroverlay; 3195 Lisp_Object otherend, otheroverlay;
3202 3196
3203 otheroverlay = XCAR (other); 3197 XSETMISC (otheroverlay, other);
3204 eassert (! OVERLAY_VALID (otheroverlay)); 3198 eassert (OVERLAY_VALID (otheroverlay));
3205 3199
3206 otherend = OVERLAY_END (otheroverlay); 3200 otherend = OVERLAY_END (otheroverlay);
3207 if (OVERLAY_POSITION (otherend) <= where) 3201 if (OVERLAY_POSITION (otherend) <= where)
3208 break; 3202 break;
3209 } 3203 }
3210 3204
3211 /* Add TAIL to overlays_before before OTHER. */ 3205 /* Add TAIL to overlays_before before OTHER. */
3212 XSETCDR (tail, other); 3206 tail->next = other;
3213 if (!NILP (other_prev)) 3207 if (other_prev)
3214 XSETCDR (other_prev, tail); 3208 other_prev->next = tail;
3215 else 3209 else
3216 buf->overlays_before = tail; 3210 buf->overlays_before = tail;
3217 tail = prev; 3211 tail = prev;
3218 } 3212 }
3219 } 3213 }
3263 void 3257 void
3264 fix_overlays_in_range (start, end) 3258 fix_overlays_in_range (start, end)
3265 register int start, end; 3259 register int start, end;
3266 { 3260 {
3267 Lisp_Object overlay; 3261 Lisp_Object overlay;
3268 Lisp_Object before_list, after_list; 3262 struct Lisp_Overlay *before_list, *after_list;
3269 /* These are either nil, indicating that before_list or after_list 3263 /* These are either nil, indicating that before_list or after_list
3270 should be assigned, or the cons cell the cdr of which should be 3264 should be assigned, or the cons cell the cdr of which should be
3271 assigned. */ 3265 assigned. */
3272 Lisp_Object beforep = Qnil, afterp = Qnil; 3266 struct Lisp_Overlay *beforep = NULL, *afterp = NULL;
3273 /* 'Parent', likewise, indicates a cons cell or 3267 /* 'Parent', likewise, indicates a cons cell or
3274 current_buffer->overlays_before or overlays_after, depending 3268 current_buffer->overlays_before or overlays_after, depending
3275 which loop we're in. */ 3269 which loop we're in. */
3276 Lisp_Object tail, parent; 3270 struct Lisp_Overlay *tail, *parent;
3277 int startpos, endpos; 3271 int startpos, endpos;
3278 3272
3279 /* This algorithm shifts links around instead of consing and GCing. 3273 /* This algorithm shifts links around instead of consing and GCing.
3280 The loop invariant is that before_list (resp. after_list) is a 3274 The loop invariant is that before_list (resp. after_list) is a
3281 well-formed list except that its last element, the CDR of beforep 3275 well-formed list except that its last element, the CDR of beforep
3282 (resp. afterp) if beforep (afterp) isn't nil or before_list 3276 (resp. afterp) if beforep (afterp) isn't nil or before_list
3283 (after_list) if it is, is still uninitialized. So it's not a bug 3277 (after_list) if it is, is still uninitialized. So it's not a bug
3284 that before_list isn't initialized, although it may look 3278 that before_list isn't initialized, although it may look
3285 strange. */ 3279 strange. */
3286 for (parent = Qnil, tail = current_buffer->overlays_before; CONSP (tail);) 3280 for (parent = NULL, tail = current_buffer->overlays_before; tail;)
3287 { 3281 {
3288 overlay = XCAR (tail); 3282 XSETMISC (overlay, tail);
3289 endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); 3283 endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
3290 if (endpos < start) 3284 if (endpos < start)
3291 break; 3285 break;
3292 startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); 3286 startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
3293 if (endpos < end 3287 if (endpos < end
3305 } 3299 }
3306 /* Add it to the end of the wrong list. Later on, 3300 /* Add it to the end of the wrong list. Later on,
3307 recenter_overlay_lists will move it to the right place. */ 3301 recenter_overlay_lists will move it to the right place. */
3308 if (endpos < current_buffer->overlay_center) 3302 if (endpos < current_buffer->overlay_center)
3309 { 3303 {
3310 if (NILP (afterp)) 3304 if (!afterp)
3311 after_list = tail; 3305 after_list = tail;
3312 else 3306 else
3313 XSETCDR (afterp, tail); 3307 afterp->next = tail;
3314 afterp = tail; 3308 afterp = tail;
3315 } 3309 }
3316 else 3310 else
3317 { 3311 {
3318 if (NILP (beforep)) 3312 if (!beforep)
3319 before_list = tail; 3313 before_list = tail;
3320 else 3314 else
3321 XSETCDR (beforep, tail); 3315 beforep->next = tail;
3322 beforep = tail; 3316 beforep = tail;
3323 } 3317 }
3324 if (NILP (parent)) 3318 if (!parent)
3325 current_buffer->overlays_before = XCDR (tail); 3319 current_buffer->overlays_before = tail->next;
3326 else 3320 else
3327 XSETCDR (parent, XCDR (tail)); 3321 parent->next = tail->next;
3328 tail = XCDR (tail); 3322 tail = tail->next;
3329 } 3323 }
3330 else 3324 else
3331 parent = tail, tail = XCDR (parent); 3325 parent = tail, tail = parent->next;
3332 } 3326 }
3333 for (parent = Qnil, tail = current_buffer->overlays_after; CONSP (tail);) 3327 for (parent = NULL, tail = current_buffer->overlays_after; tail;)
3334 { 3328 {
3335 overlay = XCAR (tail); 3329 XSETMISC (overlay, tail);
3336 startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); 3330 startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
3337 if (startpos >= end) 3331 if (startpos >= end)
3338 break; 3332 break;
3339 endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); 3333 endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
3340 if (startpos >= start 3334 if (startpos >= start
3349 Qnil); 3343 Qnil);
3350 tem = startpos; startpos = endpos; endpos = tem; 3344 tem = startpos; startpos = endpos; endpos = tem;
3351 } 3345 }
3352 if (endpos < current_buffer->overlay_center) 3346 if (endpos < current_buffer->overlay_center)
3353 { 3347 {
3354 if (NILP (afterp)) 3348 if (!afterp)
3355 after_list = tail; 3349 after_list = tail;
3356 else 3350 else
3357 XSETCDR (afterp, tail); 3351 afterp->next = tail;
3358 afterp = tail; 3352 afterp = tail;
3359 } 3353 }
3360 else 3354 else
3361 { 3355 {
3362 if (NILP (beforep)) 3356 if (!beforep)
3363 before_list = tail; 3357 before_list = tail;
3364 else 3358 else
3365 XSETCDR (beforep, tail); 3359 beforep->next = tail;
3366 beforep = tail; 3360 beforep = tail;
3367 } 3361 }
3368 if (NILP (parent)) 3362 if (!parent)
3369 current_buffer->overlays_after = XCDR (tail); 3363 current_buffer->overlays_after = tail->next;
3370 else 3364 else
3371 XSETCDR (parent, XCDR (tail)); 3365 parent->next = tail->next;
3372 tail = XCDR (tail); 3366 tail = tail->next;
3373 } 3367 }
3374 else 3368 else
3375 parent = tail, tail = XCDR (parent); 3369 parent = tail, tail = parent->next;
3376 } 3370 }
3377 3371
3378 /* Splice the constructed (wrong) lists into the buffer's lists, 3372 /* Splice the constructed (wrong) lists into the buffer's lists,
3379 and let the recenter function make it sane again. */ 3373 and let the recenter function make it sane again. */
3380 if (!NILP (beforep)) 3374 if (beforep)
3381 { 3375 {
3382 XSETCDR (beforep, current_buffer->overlays_before); 3376 beforep->next = current_buffer->overlays_before;
3383 current_buffer->overlays_before = before_list; 3377 current_buffer->overlays_before = before_list;
3384 } 3378 }
3385 recenter_overlay_lists (current_buffer, current_buffer->overlay_center); 3379 recenter_overlay_lists (current_buffer, current_buffer->overlay_center);
3386 3380
3387 if (!NILP (afterp)) 3381 if (afterp)
3388 { 3382 {
3389 XSETCDR (afterp, current_buffer->overlays_after); 3383 afterp->next = current_buffer->overlays_after;
3390 current_buffer->overlays_after = after_list; 3384 current_buffer->overlays_after = after_list;
3391 } 3385 }
3392 recenter_overlay_lists (current_buffer, current_buffer->overlay_center); 3386 recenter_overlay_lists (current_buffer, current_buffer->overlay_center);
3393 } 3387 }
3394 3388
3407 void 3401 void
3408 fix_overlays_before (bp, prev, pos) 3402 fix_overlays_before (bp, prev, pos)
3409 struct buffer *bp; 3403 struct buffer *bp;
3410 EMACS_INT prev, pos; 3404 EMACS_INT prev, pos;
3411 { 3405 {
3412 /* If parent is nil, replace overlays_before; otherwise, XCDR(parent). */ 3406 /* If parent is nil, replace overlays_before; otherwise, parent->next. */
3413 Lisp_Object tail = bp->overlays_before, parent = Qnil; 3407 struct Lisp_Overlay *tail = bp->overlays_before, *parent = NULL, *right_pair;
3414 Lisp_Object right_pair; 3408 Lisp_Object tem;
3415 EMACS_INT end; 3409 EMACS_INT end;
3416 3410
3417 /* After the insertion, the several overlays may be in incorrect 3411 /* After the insertion, the several overlays may be in incorrect
3418 order. The possibility is that, in the list `overlays_before', 3412 order. The possibility is that, in the list `overlays_before',
3419 an overlay which ends at POS appears after an overlay which ends 3413 an overlay which ends at POS appears after an overlay which ends
3423 3417
3424 /* At first, find a place where disordered overlays should be linked 3418 /* At first, find a place where disordered overlays should be linked
3425 in. It is where an overlay which end before POS exists. (i.e. an 3419 in. It is where an overlay which end before POS exists. (i.e. an
3426 overlay whose ending marker is after-insertion-marker if disorder 3420 overlay whose ending marker is after-insertion-marker if disorder
3427 exists). */ 3421 exists). */
3428 while (!NILP (tail) 3422 while (tail
3429 && ((end = OVERLAY_POSITION (OVERLAY_END (XCAR (tail)))) 3423 && (XSETMISC (tem, tail),
3430 >= pos)) 3424 (end = OVERLAY_POSITION (OVERLAY_END (tem))) >= pos))
3431 { 3425 {
3432 parent = tail; 3426 parent = tail;
3433 tail = XCDR (tail); 3427 tail = tail->next;
3434 } 3428 }
3435 3429
3436 /* If we don't find such an overlay, 3430 /* If we don't find such an overlay,
3437 or the found one ends before PREV, 3431 or the found one ends before PREV,
3438 or the found one is the last one in the list, 3432 or the found one is the last one in the list,
3439 we don't have to fix anything. */ 3433 we don't have to fix anything. */
3440 if (NILP (tail) 3434 if (tail || end < prev || !tail->next)
3441 || end < prev
3442 || NILP (XCDR (tail)))
3443 return; 3435 return;
3444 3436
3445 right_pair = parent; 3437 right_pair = parent;
3446 parent = tail; 3438 parent = tail;
3447 tail = XCDR (tail); 3439 tail = tail->next;
3448 3440
3449 /* Now, end position of overlays in the list TAIL should be before 3441 /* Now, end position of overlays in the list TAIL should be before
3450 or equal to PREV. In the loop, an overlay which ends at POS is 3442 or equal to PREV. In the loop, an overlay which ends at POS is
3451 moved ahead to the place indicated by the CDR of RIGHT_PAIR. If 3443 moved ahead to the place indicated by the CDR of RIGHT_PAIR. If
3452 we found an overlay which ends before PREV, the remaining 3444 we found an overlay which ends before PREV, the remaining
3453 overlays are in correct order. */ 3445 overlays are in correct order. */
3454 while (!NILP (tail)) 3446 while (tail)
3455 { 3447 {
3456 end = OVERLAY_POSITION (OVERLAY_END (XCAR (tail))); 3448 XSETMISC (tem, tail);
3449 end = OVERLAY_POSITION (OVERLAY_END (tem));
3457 3450
3458 if (end == pos) 3451 if (end == pos)
3459 { /* This overlay is disordered. */ 3452 { /* This overlay is disordered. */
3460 Lisp_Object found = tail; 3453 struct Lisp_Overlay *found = tail;
3461 3454
3462 /* Unlink the found overlay. */ 3455 /* Unlink the found overlay. */
3463 tail = XCDR (found); 3456 tail = found->next;
3464 XSETCDR (parent, tail); 3457 parent->next = tail;
3465 /* Move an overlay at RIGHT_PLACE to the next of the found one, 3458 /* Move an overlay at RIGHT_PLACE to the next of the found one,
3466 and link it into the right place. */ 3459 and link it into the right place. */
3467 if (NILP (right_pair)) 3460 if (!right_pair)
3468 { 3461 {
3469 XSETCDR (found, bp->overlays_before); 3462 found->next = bp->overlays_before;
3470 bp->overlays_before = found; 3463 bp->overlays_before = found;
3471 } 3464 }
3472 else 3465 else
3473 { 3466 {
3474 XSETCDR (found, XCDR (right_pair)); 3467 found->next = right_pair->next;
3475 XSETCDR (right_pair, found); 3468 right_pair->next = found;
3476 } 3469 }
3477 } 3470 }
3478 else if (end == prev) 3471 else if (end == prev)
3479 { 3472 {
3480 parent = tail; 3473 parent = tail;
3481 tail = XCDR (tail); 3474 tail = tail->next;
3482 } 3475 }
3483 else /* No more disordered overlay. */ 3476 else /* No more disordered overlay. */
3484 break; 3477 break;
3485 } 3478 }
3486 } 3479 }
3541 overlay = allocate_misc (); 3534 overlay = allocate_misc ();
3542 XMISCTYPE (overlay) = Lisp_Misc_Overlay; 3535 XMISCTYPE (overlay) = Lisp_Misc_Overlay;
3543 XOVERLAY (overlay)->start = beg; 3536 XOVERLAY (overlay)->start = beg;
3544 XOVERLAY (overlay)->end = end; 3537 XOVERLAY (overlay)->end = end;
3545 XOVERLAY (overlay)->plist = Qnil; 3538 XOVERLAY (overlay)->plist = Qnil;
3539 XOVERLAY (overlay)->next = NULL;
3546 3540
3547 /* Put the new overlay on the wrong list. */ 3541 /* Put the new overlay on the wrong list. */
3548 end = OVERLAY_END (overlay); 3542 end = OVERLAY_END (overlay);
3549 if (OVERLAY_POSITION (end) < b->overlay_center) 3543 if (OVERLAY_POSITION (end) < b->overlay_center)
3550 b->overlays_after = Fcons (overlay, b->overlays_after); 3544 {
3545 if (b->overlays_after)
3546 XOVERLAY (overlay)->next = b->overlays_after;
3547 b->overlays_after = XOVERLAY (overlay);
3548 }
3551 else 3549 else
3552 b->overlays_before = Fcons (overlay, b->overlays_before); 3550 {
3551 if (b->overlays_before)
3552 XOVERLAY (overlay)->next = b->overlays_before;
3553 b->overlays_before = XOVERLAY (overlay);
3554 }
3553 3555
3554 /* This puts it in the right list, and in the right order. */ 3556 /* This puts it in the right list, and in the right order. */
3555 recenter_overlay_lists (b, b->overlay_center); 3557 recenter_overlay_lists (b, b->overlay_center);
3556 3558
3557 /* We don't need to redisplay the region covered by the overlay, because 3559 /* We don't need to redisplay the region covered by the overlay, because
3587 ++BUF_OVERLAY_MODIFF (buf); 3589 ++BUF_OVERLAY_MODIFF (buf);
3588 } 3590 }
3589 3591
3590 3592
3591 Lisp_Object Fdelete_overlay (); 3593 Lisp_Object Fdelete_overlay ();
3594
3595 static struct Lisp_Overlay *
3596 unchain_overlay (list, overlay)
3597 struct Lisp_Overlay *list, *overlay;
3598 {
3599 struct Lisp_Overlay *tmp, *prev;
3600 for (tmp = list, prev = NULL; tmp; prev = tmp, tmp = tmp->next)
3601 if (tmp == overlay)
3602 {
3603 if (prev)
3604 prev->next = tmp->next;
3605 else
3606 list = tmp->next;
3607 overlay->next = NULL;
3608 break;
3609 }
3610 return list;
3611 }
3592 3612
3593 DEFUN ("move-overlay", Fmove_overlay, Smove_overlay, 3, 4, 0, 3613 DEFUN ("move-overlay", Fmove_overlay, Smove_overlay, 3, 4, 0,
3594 doc: /* Set the endpoints of OVERLAY to BEG and END in BUFFER. 3614 doc: /* Set the endpoints of OVERLAY to BEG and END in BUFFER.
3595 If BUFFER is omitted, leave OVERLAY in the same buffer it inhabits now. 3615 If BUFFER is omitted, leave OVERLAY in the same buffer it inhabits now.
3596 If BUFFER is omitted, and OVERLAY is in no buffer, put it in the current 3616 If BUFFER is omitted, and OVERLAY is in no buffer, put it in the current
3672 } 3692 }
3673 } 3693 }
3674 3694
3675 if (!NILP (obuffer)) 3695 if (!NILP (obuffer))
3676 { 3696 {
3677 ob->overlays_before = Fdelq (overlay, ob->overlays_before); 3697 ob->overlays_before
3678 ob->overlays_after = Fdelq (overlay, ob->overlays_after); 3698 = unchain_overlay (ob->overlays_before, XOVERLAY (overlay));
3699 ob->overlays_after
3700 = unchain_overlay (ob->overlays_after, XOVERLAY (overlay));
3701 eassert (XOVERLAY (overlay)->next == NULL);
3679 } 3702 }
3680 3703
3681 Fset_marker (OVERLAY_START (overlay), beg, buffer); 3704 Fset_marker (OVERLAY_START (overlay), beg, buffer);
3682 Fset_marker (OVERLAY_END (overlay), end, buffer); 3705 Fset_marker (OVERLAY_END (overlay), end, buffer);
3683 3706
3684 /* Put the overlay on the wrong list. */ 3707 /* Put the overlay on the wrong list. */
3685 end = OVERLAY_END (overlay); 3708 end = OVERLAY_END (overlay);
3686 if (OVERLAY_POSITION (end) < b->overlay_center) 3709 if (OVERLAY_POSITION (end) < b->overlay_center)
3687 b->overlays_after = Fcons (overlay, b->overlays_after); 3710 {
3711 if (b->overlays_after)
3712 XOVERLAY (overlay)->next = b->overlays_after;
3713 b->overlays_after = XOVERLAY (overlay);
3714 }
3688 else 3715 else
3689 b->overlays_before = Fcons (overlay, b->overlays_before); 3716 {
3717 if (b->overlays_before)
3718 XOVERLAY (overlay)->next = b->overlays_before;
3719 b->overlays_before = XOVERLAY (overlay);
3720 }
3690 3721
3691 /* This puts it in the right list, and in the right order. */ 3722 /* This puts it in the right list, and in the right order. */
3692 recenter_overlay_lists (b, b->overlay_center); 3723 recenter_overlay_lists (b, b->overlay_center);
3693 3724
3694 return unbind_to (count, overlay); 3725 return unbind_to (count, overlay);
3710 return Qnil; 3741 return Qnil;
3711 3742
3712 b = XBUFFER (buffer); 3743 b = XBUFFER (buffer);
3713 specbind (Qinhibit_quit, Qt); 3744 specbind (Qinhibit_quit, Qt);
3714 3745
3715 b->overlays_before = Fdelq (overlay, b->overlays_before); 3746 b->overlays_before = unchain_overlay (b->overlays_before,XOVERLAY (overlay));
3716 b->overlays_after = Fdelq (overlay, b->overlays_after); 3747 b->overlays_after = unchain_overlay (b->overlays_after, XOVERLAY (overlay));
3748 eassert (XOVERLAY (overlay)->next == NULL);
3717 modify_overlay (b, 3749 modify_overlay (b,
3718 marker_position (OVERLAY_START (overlay)), 3750 marker_position (OVERLAY_START (overlay)),
3719 marker_position (OVERLAY_END (overlay))); 3751 marker_position (OVERLAY_END (overlay)));
3720 Fset_marker (OVERLAY_START (overlay), Qnil, Qnil); 3752 Fset_marker (OVERLAY_START (overlay), Qnil, Qnil);
3721 Fset_marker (OVERLAY_END (overlay), Qnil, Qnil); 3753 Fset_marker (OVERLAY_END (overlay), Qnil, Qnil);
3919 Recentering overlays moves overlays between these lists. 3951 Recentering overlays moves overlays between these lists.
3920 The lists you get are copies, so that changing them has no effect. 3952 The lists you get are copies, so that changing them has no effect.
3921 However, the overlays you get are the real objects that the buffer uses. */) 3953 However, the overlays you get are the real objects that the buffer uses. */)
3922 () 3954 ()
3923 { 3955 {
3924 Lisp_Object before, after; 3956 struct Lisp_Overlay *ol;
3925 before = current_buffer->overlays_before; 3957 Lisp_Object before = Qnil, after = Qnil, tmp;
3926 if (CONSP (before)) 3958 for (ol = current_buffer->overlays_before; ol; ol = ol->next)
3927 before = Fcopy_sequence (before); 3959 {
3928 after = current_buffer->overlays_after; 3960 XSETMISC (tmp, ol);
3929 if (CONSP (after)) 3961 before = Fcons (tmp, before);
3930 after = Fcopy_sequence (after); 3962 }
3931 3963 for (ol = current_buffer->overlays_after; ol; ol = ol->next)
3932 return Fcons (before, after); 3964 {
3965 XSETMISC (tmp, ol);
3966 after = Fcons (tmp, after);
3967 }
3968 return Fcons (Fnreverse (before), Fnreverse (after));
3933 } 3969 }
3934 3970
3935 DEFUN ("overlay-recenter", Foverlay_recenter, Soverlay_recenter, 1, 1, 0, 3971 DEFUN ("overlay-recenter", Foverlay_recenter, Soverlay_recenter, 1, 1, 0,
3936 doc: /* Recenter the overlays of the current buffer around position POS. 3972 doc: /* Recenter the overlays of the current buffer around position POS.
3937 That makes overlay lookup faster for positions near POS (but perhaps slower 3973 That makes overlay lookup faster for positions near POS (but perhaps slower
4027 = Fmake_vector (make_number (oldsize * 2), Qnil); 4063 = Fmake_vector (make_number (oldsize * 2), Qnil);
4028 bcopy (XVECTOR (old)->contents, 4064 bcopy (XVECTOR (old)->contents,
4029 XVECTOR (last_overlay_modification_hooks)->contents, 4065 XVECTOR (last_overlay_modification_hooks)->contents,
4030 sizeof (Lisp_Object) * oldsize); 4066 sizeof (Lisp_Object) * oldsize);
4031 } 4067 }
4032 XVECTOR (last_overlay_modification_hooks)->contents[last_overlay_modification_hooks_used++] = functionlist; 4068 AREF (last_overlay_modification_hooks, last_overlay_modification_hooks_used++) = functionlist;
4033 XVECTOR (last_overlay_modification_hooks)->contents[last_overlay_modification_hooks_used++] = overlay; 4069 AREF (last_overlay_modification_hooks, last_overlay_modification_hooks_used++) = overlay;
4034 } 4070 }
4035 4071
4036 /* Run the modification-hooks of overlays that include 4072 /* Run the modification-hooks of overlays that include
4037 any part of the text in START to END. 4073 any part of the text in START to END.
4038 If this change is an insertion, also 4074 If this change is an insertion, also
4051 report_overlay_modification (start, end, after, arg1, arg2, arg3) 4087 report_overlay_modification (start, end, after, arg1, arg2, arg3)
4052 Lisp_Object start, end; 4088 Lisp_Object start, end;
4053 int after; 4089 int after;
4054 Lisp_Object arg1, arg2, arg3; 4090 Lisp_Object arg1, arg2, arg3;
4055 { 4091 {
4056 Lisp_Object prop, overlay, tail; 4092 Lisp_Object prop, overlay;
4093 struct Lisp_Overlay *tail;
4057 /* 1 if this change is an insertion. */ 4094 /* 1 if this change is an insertion. */
4058 int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end)); 4095 int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end));
4059 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 4096 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
4060 4097
4061 overlay = Qnil; 4098 overlay = Qnil;
4062 tail = Qnil; 4099 tail = NULL;
4063 4100
4064 if (!after) 4101 if (!after)
4065 { 4102 {
4066 /* We are being called before a change. 4103 /* We are being called before a change.
4067 Scan the overlays to find the functions to call. */ 4104 Scan the overlays to find the functions to call. */
4068 last_overlay_modification_hooks_used = 0; 4105 last_overlay_modification_hooks_used = 0;
4069 for (tail = current_buffer->overlays_before; 4106 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
4070 CONSP (tail);
4071 tail = XCDR (tail))
4072 { 4107 {
4073 int startpos, endpos; 4108 int startpos, endpos;
4074 Lisp_Object ostart, oend; 4109 Lisp_Object ostart, oend;
4075 4110
4076 overlay = XCAR (tail); 4111 XSETMISC (overlay, tail);
4077 4112
4078 ostart = OVERLAY_START (overlay); 4113 ostart = OVERLAY_START (overlay);
4079 oend = OVERLAY_END (overlay); 4114 oend = OVERLAY_END (overlay);
4080 endpos = OVERLAY_POSITION (oend); 4115 endpos = OVERLAY_POSITION (oend);
4081 if (XFASTINT (start) > endpos) 4116 if (XFASTINT (start) > endpos)
4102 prop = Foverlay_get (overlay, Qmodification_hooks); 4137 prop = Foverlay_get (overlay, Qmodification_hooks);
4103 if (!NILP (prop)) 4138 if (!NILP (prop))
4104 add_overlay_mod_hooklist (prop, overlay); 4139 add_overlay_mod_hooklist (prop, overlay);
4105 } 4140 }
4106 } 4141 }
4107 4142
4108 for (tail = current_buffer->overlays_after; 4143 for (tail = current_buffer->overlays_after; tail; tail = tail->next)
4109 CONSP (tail);
4110 tail = XCDR (tail))
4111 { 4144 {
4112 int startpos, endpos; 4145 int startpos, endpos;
4113 Lisp_Object ostart, oend; 4146 Lisp_Object ostart, oend;
4114 4147
4115 overlay = XCAR (tail); 4148 XSETMISC (overlay, tail);
4116 4149
4117 ostart = OVERLAY_START (overlay); 4150 ostart = OVERLAY_START (overlay);
4118 oend = OVERLAY_END (overlay); 4151 oend = OVERLAY_END (overlay);
4119 startpos = OVERLAY_POSITION (ostart); 4152 startpos = OVERLAY_POSITION (ostart);
4120 endpos = OVERLAY_POSITION (oend); 4153 endpos = OVERLAY_POSITION (oend);
4195 property is set. */ 4228 property is set. */
4196 void 4229 void
4197 evaporate_overlays (pos) 4230 evaporate_overlays (pos)
4198 EMACS_INT pos; 4231 EMACS_INT pos;
4199 { 4232 {
4200 Lisp_Object tail, overlay, hit_list; 4233 Lisp_Object overlay, hit_list;
4234 struct Lisp_Overlay *tail;
4201 4235
4202 hit_list = Qnil; 4236 hit_list = Qnil;
4203 if (pos <= current_buffer->overlay_center) 4237 if (pos <= current_buffer->overlay_center)
4204 for (tail = current_buffer->overlays_before; CONSP (tail); 4238 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
4205 tail = XCDR (tail))
4206 { 4239 {
4207 int endpos; 4240 int endpos;
4208 overlay = XCAR (tail); 4241 XSETMISC (overlay, tail);
4209 endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); 4242 endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
4210 if (endpos < pos) 4243 if (endpos < pos)
4211 break; 4244 break;
4212 if (endpos == pos && OVERLAY_POSITION (OVERLAY_START (overlay)) == pos 4245 if (endpos == pos && OVERLAY_POSITION (OVERLAY_START (overlay)) == pos
4213 && ! NILP (Foverlay_get (overlay, Qevaporate))) 4246 && ! NILP (Foverlay_get (overlay, Qevaporate)))
4214 hit_list = Fcons (overlay, hit_list); 4247 hit_list = Fcons (overlay, hit_list);
4215 } 4248 }
4216 else 4249 else
4217 for (tail = current_buffer->overlays_after; CONSP (tail); 4250 for (tail = current_buffer->overlays_after; tail; tail = tail->next)
4218 tail = XCDR (tail))
4219 { 4251 {
4220 int startpos; 4252 int startpos;
4221 overlay = XCAR (tail); 4253 XSETMISC (overlay, tail);
4222 startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); 4254 startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
4223 if (startpos > pos) 4255 if (startpos > pos)
4224 break; 4256 break;
4225 if (startpos == pos && OVERLAY_POSITION (OVERLAY_END (overlay)) == pos 4257 if (startpos == pos && OVERLAY_POSITION (OVERLAY_END (overlay)) == pos
4226 && ! NILP (Foverlay_get (overlay, Qevaporate))) 4258 && ! NILP (Foverlay_get (overlay, Qevaporate)))
4856 buffer_defaults.abbrev_table = Qnil; 4888 buffer_defaults.abbrev_table = Qnil;
4857 buffer_defaults.display_table = Qnil; 4889 buffer_defaults.display_table = Qnil;
4858 buffer_defaults.undo_list = Qnil; 4890 buffer_defaults.undo_list = Qnil;
4859 buffer_defaults.mark_active = Qnil; 4891 buffer_defaults.mark_active = Qnil;
4860 buffer_defaults.file_format = Qnil; 4892 buffer_defaults.file_format = Qnil;
4861 buffer_defaults.overlays_before = Qnil; 4893 buffer_defaults.overlays_before = NULL;
4862 buffer_defaults.overlays_after = Qnil; 4894 buffer_defaults.overlays_after = NULL;
4863 buffer_defaults.overlay_center = BEG; 4895 buffer_defaults.overlay_center = BEG;
4864 4896
4865 XSETFASTINT (buffer_defaults.tab_width, 8); 4897 XSETFASTINT (buffer_defaults.tab_width, 8);
4866 buffer_defaults.truncate_lines = Qnil; 4898 buffer_defaults.truncate_lines = Qnil;
4867 buffer_defaults.ctl_arrow = Qt; 4899 buffer_defaults.ctl_arrow = Qt;