diff options
Diffstat (limited to 'src/buffer.c')
| -rw-r--r-- | src/buffer.c | 250 |
1 files changed, 110 insertions, 140 deletions
diff --git a/src/buffer.c b/src/buffer.c index ec6f4647119..878844dd020 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -2789,8 +2789,6 @@ overlays_at (EMACS_INT pos, bool extend, Lisp_Object **vec_ptr, | |||
| 2789 | ptrdiff_t *len_ptr, | 2789 | ptrdiff_t *len_ptr, |
| 2790 | ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr, bool change_req) | 2790 | ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr, bool change_req) |
| 2791 | { | 2791 | { |
| 2792 | Lisp_Object overlay, start, end; | ||
| 2793 | struct Lisp_Overlay *tail; | ||
| 2794 | ptrdiff_t idx = 0; | 2792 | ptrdiff_t idx = 0; |
| 2795 | ptrdiff_t len = *len_ptr; | 2793 | ptrdiff_t len = *len_ptr; |
| 2796 | Lisp_Object *vec = *vec_ptr; | 2794 | Lisp_Object *vec = *vec_ptr; |
| @@ -2798,22 +2796,20 @@ overlays_at (EMACS_INT pos, bool extend, Lisp_Object **vec_ptr, | |||
| 2798 | ptrdiff_t prev = BEGV; | 2796 | ptrdiff_t prev = BEGV; |
| 2799 | bool inhibit_storing = 0; | 2797 | bool inhibit_storing = 0; |
| 2800 | 2798 | ||
| 2801 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) | 2799 | for (struct Lisp_Overlay *tail = current_buffer->overlays_before; |
| 2800 | tail; tail = tail->next) | ||
| 2802 | { | 2801 | { |
| 2803 | ptrdiff_t startpos, endpos; | 2802 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 2804 | 2803 | Lisp_Object start = OVERLAY_START (overlay); | |
| 2805 | XSETMISC (overlay, tail); | 2804 | Lisp_Object end = OVERLAY_END (overlay); |
| 2806 | 2805 | ptrdiff_t endpos = OVERLAY_POSITION (end); | |
| 2807 | start = OVERLAY_START (overlay); | ||
| 2808 | end = OVERLAY_END (overlay); | ||
| 2809 | endpos = OVERLAY_POSITION (end); | ||
| 2810 | if (endpos < pos) | 2806 | if (endpos < pos) |
| 2811 | { | 2807 | { |
| 2812 | if (prev < endpos) | 2808 | if (prev < endpos) |
| 2813 | prev = endpos; | 2809 | prev = endpos; |
| 2814 | break; | 2810 | break; |
| 2815 | } | 2811 | } |
| 2816 | startpos = OVERLAY_POSITION (start); | 2812 | ptrdiff_t startpos = OVERLAY_POSITION (start); |
| 2817 | /* This one ends at or after POS | 2813 | /* This one ends at or after POS |
| 2818 | so its start counts for PREV_PTR if it's before POS. */ | 2814 | so its start counts for PREV_PTR if it's before POS. */ |
| 2819 | if (prev < startpos && startpos < pos) | 2815 | if (prev < startpos && startpos < pos) |
| @@ -2846,22 +2842,20 @@ overlays_at (EMACS_INT pos, bool extend, Lisp_Object **vec_ptr, | |||
| 2846 | next = startpos; | 2842 | next = startpos; |
| 2847 | } | 2843 | } |
| 2848 | 2844 | ||
| 2849 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) | 2845 | for (struct Lisp_Overlay *tail = current_buffer->overlays_after; |
| 2846 | tail; tail = tail->next) | ||
| 2850 | { | 2847 | { |
| 2851 | ptrdiff_t startpos, endpos; | 2848 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 2852 | 2849 | Lisp_Object start = OVERLAY_START (overlay); | |
| 2853 | XSETMISC (overlay, tail); | 2850 | Lisp_Object end = OVERLAY_END (overlay); |
| 2854 | 2851 | ptrdiff_t startpos = OVERLAY_POSITION (start); | |
| 2855 | start = OVERLAY_START (overlay); | ||
| 2856 | end = OVERLAY_END (overlay); | ||
| 2857 | startpos = OVERLAY_POSITION (start); | ||
| 2858 | if (pos < startpos) | 2852 | if (pos < startpos) |
| 2859 | { | 2853 | { |
| 2860 | if (startpos < next) | 2854 | if (startpos < next) |
| 2861 | next = startpos; | 2855 | next = startpos; |
| 2862 | break; | 2856 | break; |
| 2863 | } | 2857 | } |
| 2864 | endpos = OVERLAY_POSITION (end); | 2858 | ptrdiff_t endpos = OVERLAY_POSITION (end); |
| 2865 | if (pos < endpos) | 2859 | if (pos < endpos) |
| 2866 | { | 2860 | { |
| 2867 | if (idx == len) | 2861 | if (idx == len) |
| @@ -2923,8 +2917,6 @@ overlays_in (EMACS_INT beg, EMACS_INT end, bool extend, | |||
| 2923 | Lisp_Object **vec_ptr, ptrdiff_t *len_ptr, | 2917 | Lisp_Object **vec_ptr, ptrdiff_t *len_ptr, |
| 2924 | ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr) | 2918 | ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr) |
| 2925 | { | 2919 | { |
| 2926 | Lisp_Object overlay, ostart, oend; | ||
| 2927 | struct Lisp_Overlay *tail; | ||
| 2928 | ptrdiff_t idx = 0; | 2920 | ptrdiff_t idx = 0; |
| 2929 | ptrdiff_t len = *len_ptr; | 2921 | ptrdiff_t len = *len_ptr; |
| 2930 | Lisp_Object *vec = *vec_ptr; | 2922 | Lisp_Object *vec = *vec_ptr; |
| @@ -2933,22 +2925,20 @@ overlays_in (EMACS_INT beg, EMACS_INT end, bool extend, | |||
| 2933 | bool inhibit_storing = 0; | 2925 | bool inhibit_storing = 0; |
| 2934 | bool end_is_Z = end == Z; | 2926 | bool end_is_Z = end == Z; |
| 2935 | 2927 | ||
| 2936 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) | 2928 | for (struct Lisp_Overlay *tail = current_buffer->overlays_before; |
| 2929 | tail; tail = tail->next) | ||
| 2937 | { | 2930 | { |
| 2938 | ptrdiff_t startpos, endpos; | 2931 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 2939 | 2932 | Lisp_Object ostart = OVERLAY_START (overlay); | |
| 2940 | XSETMISC (overlay, tail); | 2933 | Lisp_Object oend = OVERLAY_END (overlay); |
| 2941 | 2934 | ptrdiff_t endpos = OVERLAY_POSITION (oend); | |
| 2942 | ostart = OVERLAY_START (overlay); | ||
| 2943 | oend = OVERLAY_END (overlay); | ||
| 2944 | endpos = OVERLAY_POSITION (oend); | ||
| 2945 | if (endpos < beg) | 2935 | if (endpos < beg) |
| 2946 | { | 2936 | { |
| 2947 | if (prev < endpos) | 2937 | if (prev < endpos) |
| 2948 | prev = endpos; | 2938 | prev = endpos; |
| 2949 | break; | 2939 | break; |
| 2950 | } | 2940 | } |
| 2951 | startpos = OVERLAY_POSITION (ostart); | 2941 | ptrdiff_t startpos = OVERLAY_POSITION (ostart); |
| 2952 | /* Count an interval if it overlaps the range, is empty at the | 2942 | /* Count an interval if it overlaps the range, is empty at the |
| 2953 | start of the range, or is empty at END provided END denotes the | 2943 | start of the range, or is empty at END provided END denotes the |
| 2954 | end of the buffer. */ | 2944 | end of the buffer. */ |
| @@ -2980,22 +2970,20 @@ overlays_in (EMACS_INT beg, EMACS_INT end, bool extend, | |||
| 2980 | next = startpos; | 2970 | next = startpos; |
| 2981 | } | 2971 | } |
| 2982 | 2972 | ||
| 2983 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) | 2973 | for (struct Lisp_Overlay *tail = current_buffer->overlays_after; |
| 2974 | tail; tail = tail->next) | ||
| 2984 | { | 2975 | { |
| 2985 | ptrdiff_t startpos, endpos; | 2976 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 2986 | 2977 | Lisp_Object ostart = OVERLAY_START (overlay); | |
| 2987 | XSETMISC (overlay, tail); | 2978 | Lisp_Object oend = OVERLAY_END (overlay); |
| 2988 | 2979 | ptrdiff_t startpos = OVERLAY_POSITION (ostart); | |
| 2989 | ostart = OVERLAY_START (overlay); | ||
| 2990 | oend = OVERLAY_END (overlay); | ||
| 2991 | startpos = OVERLAY_POSITION (ostart); | ||
| 2992 | if (end < startpos) | 2980 | if (end < startpos) |
| 2993 | { | 2981 | { |
| 2994 | if (startpos < next) | 2982 | if (startpos < next) |
| 2995 | next = startpos; | 2983 | next = startpos; |
| 2996 | break; | 2984 | break; |
| 2997 | } | 2985 | } |
| 2998 | endpos = OVERLAY_POSITION (oend); | 2986 | ptrdiff_t endpos = OVERLAY_POSITION (oend); |
| 2999 | /* Count an interval if it overlaps the range, is empty at the | 2987 | /* Count an interval if it overlaps the range, is empty at the |
| 3000 | start of the range, or is empty at END provided END denotes the | 2988 | start of the range, or is empty at END provided END denotes the |
| 3001 | end of the buffer. */ | 2989 | end of the buffer. */ |
| @@ -3097,31 +3085,26 @@ disable_line_numbers_overlay_at_eob (void) | |||
| 3097 | bool | 3085 | bool |
| 3098 | overlay_touches_p (ptrdiff_t pos) | 3086 | overlay_touches_p (ptrdiff_t pos) |
| 3099 | { | 3087 | { |
| 3100 | Lisp_Object overlay; | 3088 | for (struct Lisp_Overlay *tail = current_buffer->overlays_before; |
| 3101 | struct Lisp_Overlay *tail; | 3089 | tail; tail = tail->next) |
| 3102 | |||
| 3103 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) | ||
| 3104 | { | 3090 | { |
| 3105 | ptrdiff_t endpos; | 3091 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 3106 | |||
| 3107 | XSETMISC (overlay ,tail); | ||
| 3108 | eassert (OVERLAYP (overlay)); | 3092 | eassert (OVERLAYP (overlay)); |
| 3109 | 3093 | ||
| 3110 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); | 3094 | ptrdiff_t endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); |
| 3111 | if (endpos < pos) | 3095 | if (endpos < pos) |
| 3112 | break; | 3096 | break; |
| 3113 | if (endpos == pos || OVERLAY_POSITION (OVERLAY_START (overlay)) == pos) | 3097 | if (endpos == pos || OVERLAY_POSITION (OVERLAY_START (overlay)) == pos) |
| 3114 | return 1; | 3098 | return 1; |
| 3115 | } | 3099 | } |
| 3116 | 3100 | ||
| 3117 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) | 3101 | for (struct Lisp_Overlay *tail = current_buffer->overlays_after; |
| 3102 | tail; tail = tail->next) | ||
| 3118 | { | 3103 | { |
| 3119 | ptrdiff_t startpos; | 3104 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 3120 | |||
| 3121 | XSETMISC (overlay, tail); | ||
| 3122 | eassert (OVERLAYP (overlay)); | 3105 | eassert (OVERLAYP (overlay)); |
| 3123 | 3106 | ||
| 3124 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); | 3107 | ptrdiff_t startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); |
| 3125 | if (pos < startpos) | 3108 | if (pos < startpos) |
| 3126 | break; | 3109 | break; |
| 3127 | if (startpos == pos || OVERLAY_POSITION (OVERLAY_END (overlay)) == pos) | 3110 | if (startpos == pos || OVERLAY_POSITION (OVERLAY_END (overlay)) == pos) |
| @@ -3337,27 +3320,26 @@ record_overlay_string (struct sortstrlist *ssl, Lisp_Object str, | |||
| 3337 | ptrdiff_t | 3320 | ptrdiff_t |
| 3338 | overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr) | 3321 | overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr) |
| 3339 | { | 3322 | { |
| 3340 | Lisp_Object overlay, window, str; | ||
| 3341 | struct Lisp_Overlay *ov; | ||
| 3342 | ptrdiff_t startpos, endpos; | ||
| 3343 | bool multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); | 3323 | bool multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); |
| 3344 | 3324 | ||
| 3345 | overlay_heads.used = overlay_heads.bytes = 0; | 3325 | overlay_heads.used = overlay_heads.bytes = 0; |
| 3346 | overlay_tails.used = overlay_tails.bytes = 0; | 3326 | overlay_tails.used = overlay_tails.bytes = 0; |
| 3347 | for (ov = current_buffer->overlays_before; ov; ov = ov->next) | 3327 | for (struct Lisp_Overlay *ov = current_buffer->overlays_before; |
| 3328 | ov; ov = ov->next) | ||
| 3348 | { | 3329 | { |
| 3349 | XSETMISC (overlay, ov); | 3330 | Lisp_Object overlay = make_lisp_ptr (ov, Lisp_Vectorlike); |
| 3350 | eassert (OVERLAYP (overlay)); | 3331 | eassert (OVERLAYP (overlay)); |
| 3351 | 3332 | ||
| 3352 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); | 3333 | ptrdiff_t startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); |
| 3353 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); | 3334 | ptrdiff_t endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); |
| 3354 | if (endpos < pos) | 3335 | if (endpos < pos) |
| 3355 | break; | 3336 | break; |
| 3356 | if (endpos != pos && startpos != pos) | 3337 | if (endpos != pos && startpos != pos) |
| 3357 | continue; | 3338 | continue; |
| 3358 | window = Foverlay_get (overlay, Qwindow); | 3339 | Lisp_Object window = Foverlay_get (overlay, Qwindow); |
| 3359 | if (WINDOWP (window) && XWINDOW (window) != w) | 3340 | if (WINDOWP (window) && XWINDOW (window) != w) |
| 3360 | continue; | 3341 | continue; |
| 3342 | Lisp_Object str; | ||
| 3361 | if (startpos == pos | 3343 | if (startpos == pos |
| 3362 | && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))) | 3344 | && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))) |
| 3363 | record_overlay_string (&overlay_heads, str, | 3345 | record_overlay_string (&overlay_heads, str, |
| @@ -3372,20 +3354,22 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr) | |||
| 3372 | Foverlay_get (overlay, Qpriority), | 3354 | Foverlay_get (overlay, Qpriority), |
| 3373 | endpos - startpos); | 3355 | endpos - startpos); |
| 3374 | } | 3356 | } |
| 3375 | for (ov = current_buffer->overlays_after; ov; ov = ov->next) | 3357 | for (struct Lisp_Overlay *ov = current_buffer->overlays_after; |
| 3358 | ov; ov = ov->next) | ||
| 3376 | { | 3359 | { |
| 3377 | XSETMISC (overlay, ov); | 3360 | Lisp_Object overlay = make_lisp_ptr (ov, Lisp_Vectorlike); |
| 3378 | eassert (OVERLAYP (overlay)); | 3361 | eassert (OVERLAYP (overlay)); |
| 3379 | 3362 | ||
| 3380 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); | 3363 | ptrdiff_t startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); |
| 3381 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); | 3364 | ptrdiff_t endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); |
| 3382 | if (startpos > pos) | 3365 | if (startpos > pos) |
| 3383 | break; | 3366 | break; |
| 3384 | if (endpos != pos && startpos != pos) | 3367 | if (endpos != pos && startpos != pos) |
| 3385 | continue; | 3368 | continue; |
| 3386 | window = Foverlay_get (overlay, Qwindow); | 3369 | Lisp_Object window = Foverlay_get (overlay, Qwindow); |
| 3387 | if (WINDOWP (window) && XWINDOW (window) != w) | 3370 | if (WINDOWP (window) && XWINDOW (window) != w) |
| 3388 | continue; | 3371 | continue; |
| 3372 | Lisp_Object str; | ||
| 3389 | if (startpos == pos | 3373 | if (startpos == pos |
| 3390 | && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))) | 3374 | && (str = Foverlay_get (overlay, Qbefore_string), STRINGP (str))) |
| 3391 | record_overlay_string (&overlay_heads, str, | 3375 | record_overlay_string (&overlay_heads, str, |
| @@ -3460,8 +3444,7 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr) | |||
| 3460 | void | 3444 | void |
| 3461 | recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | 3445 | recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) |
| 3462 | { | 3446 | { |
| 3463 | Lisp_Object overlay, beg, end; | 3447 | struct Lisp_Overlay *prev, *next; |
| 3464 | struct Lisp_Overlay *prev, *tail, *next; | ||
| 3465 | 3448 | ||
| 3466 | /* See if anything in overlays_before should move to overlays_after. */ | 3449 | /* See if anything in overlays_before should move to overlays_after. */ |
| 3467 | 3450 | ||
| @@ -3469,14 +3452,15 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | |||
| 3469 | But we use it for symmetry and in case that should cease to be true | 3452 | But we use it for symmetry and in case that should cease to be true |
| 3470 | with some future change. */ | 3453 | with some future change. */ |
| 3471 | prev = NULL; | 3454 | prev = NULL; |
| 3472 | for (tail = buf->overlays_before; tail; prev = tail, tail = next) | 3455 | for (struct Lisp_Overlay *tail = buf->overlays_before; |
| 3456 | tail; prev = tail, tail = next) | ||
| 3473 | { | 3457 | { |
| 3474 | next = tail->next; | 3458 | next = tail->next; |
| 3475 | XSETMISC (overlay, tail); | 3459 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 3476 | eassert (OVERLAYP (overlay)); | 3460 | eassert (OVERLAYP (overlay)); |
| 3477 | 3461 | ||
| 3478 | beg = OVERLAY_START (overlay); | 3462 | Lisp_Object beg = OVERLAY_START (overlay); |
| 3479 | end = OVERLAY_END (overlay); | 3463 | Lisp_Object end = OVERLAY_END (overlay); |
| 3480 | 3464 | ||
| 3481 | if (OVERLAY_POSITION (end) > pos) | 3465 | if (OVERLAY_POSITION (end) > pos) |
| 3482 | { | 3466 | { |
| @@ -3495,12 +3479,10 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | |||
| 3495 | for (other = buf->overlays_after; other; | 3479 | for (other = buf->overlays_after; other; |
| 3496 | other_prev = other, other = other->next) | 3480 | other_prev = other, other = other->next) |
| 3497 | { | 3481 | { |
| 3498 | Lisp_Object otherbeg, otheroverlay; | 3482 | Lisp_Object otheroverlay = make_lisp_ptr (other, Lisp_Vectorlike); |
| 3499 | |||
| 3500 | XSETMISC (otheroverlay, other); | ||
| 3501 | eassert (OVERLAYP (otheroverlay)); | 3483 | eassert (OVERLAYP (otheroverlay)); |
| 3502 | 3484 | ||
| 3503 | otherbeg = OVERLAY_START (otheroverlay); | 3485 | Lisp_Object otherbeg = OVERLAY_START (otheroverlay); |
| 3504 | if (OVERLAY_POSITION (otherbeg) >= where) | 3486 | if (OVERLAY_POSITION (otherbeg) >= where) |
| 3505 | break; | 3487 | break; |
| 3506 | } | 3488 | } |
| @@ -3522,14 +3504,15 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | |||
| 3522 | 3504 | ||
| 3523 | /* See if anything in overlays_after should be in overlays_before. */ | 3505 | /* See if anything in overlays_after should be in overlays_before. */ |
| 3524 | prev = NULL; | 3506 | prev = NULL; |
| 3525 | for (tail = buf->overlays_after; tail; prev = tail, tail = next) | 3507 | for (struct Lisp_Overlay *tail = buf->overlays_after; |
| 3508 | tail; prev = tail, tail = next) | ||
| 3526 | { | 3509 | { |
| 3527 | next = tail->next; | 3510 | next = tail->next; |
| 3528 | XSETMISC (overlay, tail); | 3511 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 3529 | eassert (OVERLAYP (overlay)); | 3512 | eassert (OVERLAYP (overlay)); |
| 3530 | 3513 | ||
| 3531 | beg = OVERLAY_START (overlay); | 3514 | Lisp_Object beg = OVERLAY_START (overlay); |
| 3532 | end = OVERLAY_END (overlay); | 3515 | Lisp_Object end = OVERLAY_END (overlay); |
| 3533 | 3516 | ||
| 3534 | /* Stop looking, when we know that nothing further | 3517 | /* Stop looking, when we know that nothing further |
| 3535 | can possibly end before POS. */ | 3518 | can possibly end before POS. */ |
| @@ -3553,12 +3536,10 @@ recenter_overlay_lists (struct buffer *buf, ptrdiff_t pos) | |||
| 3553 | for (other = buf->overlays_before; other; | 3536 | for (other = buf->overlays_before; other; |
| 3554 | other_prev = other, other = other->next) | 3537 | other_prev = other, other = other->next) |
| 3555 | { | 3538 | { |
| 3556 | Lisp_Object otherend, otheroverlay; | 3539 | Lisp_Object otheroverlay = make_lisp_ptr (other, Lisp_Vectorlike); |
| 3557 | |||
| 3558 | XSETMISC (otheroverlay, other); | ||
| 3559 | eassert (OVERLAYP (otheroverlay)); | 3540 | eassert (OVERLAYP (otheroverlay)); |
| 3560 | 3541 | ||
| 3561 | otherend = OVERLAY_END (otheroverlay); | 3542 | Lisp_Object otherend = OVERLAY_END (otheroverlay); |
| 3562 | if (OVERLAY_POSITION (otherend) <= where) | 3543 | if (OVERLAY_POSITION (otherend) <= where) |
| 3563 | break; | 3544 | break; |
| 3564 | } | 3545 | } |
| @@ -3613,7 +3594,6 @@ adjust_overlays_for_delete (ptrdiff_t pos, ptrdiff_t length) | |||
| 3613 | void | 3594 | void |
| 3614 | fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) | 3595 | fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) |
| 3615 | { | 3596 | { |
| 3616 | Lisp_Object overlay; | ||
| 3617 | struct Lisp_Overlay *before_list UNINIT; | 3597 | struct Lisp_Overlay *before_list UNINIT; |
| 3618 | struct Lisp_Overlay *after_list UNINIT; | 3598 | struct Lisp_Overlay *after_list UNINIT; |
| 3619 | /* These are either nil, indicating that before_list or after_list | 3599 | /* These are either nil, indicating that before_list or after_list |
| @@ -3623,8 +3603,7 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) | |||
| 3623 | /* 'Parent', likewise, indicates a cons cell or | 3603 | /* 'Parent', likewise, indicates a cons cell or |
| 3624 | current_buffer->overlays_before or overlays_after, depending | 3604 | current_buffer->overlays_before or overlays_after, depending |
| 3625 | which loop we're in. */ | 3605 | which loop we're in. */ |
| 3626 | struct Lisp_Overlay *tail, *parent; | 3606 | struct Lisp_Overlay *parent; |
| 3627 | ptrdiff_t startpos, endpos; | ||
| 3628 | 3607 | ||
| 3629 | /* This algorithm shifts links around instead of consing and GCing. | 3608 | /* This algorithm shifts links around instead of consing and GCing. |
| 3630 | The loop invariant is that before_list (resp. after_list) is a | 3609 | The loop invariant is that before_list (resp. after_list) is a |
| @@ -3633,12 +3612,14 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) | |||
| 3633 | (after_list) if it is, is still uninitialized. So it's not a bug | 3612 | (after_list) if it is, is still uninitialized. So it's not a bug |
| 3634 | that before_list isn't initialized, although it may look | 3613 | that before_list isn't initialized, although it may look |
| 3635 | strange. */ | 3614 | strange. */ |
| 3636 | for (parent = NULL, tail = current_buffer->overlays_before; tail;) | 3615 | parent = NULL; |
| 3616 | for (struct Lisp_Overlay *tail = current_buffer->overlays_before; | ||
| 3617 | tail; tail = tail->next) | ||
| 3637 | { | 3618 | { |
| 3638 | XSETMISC (overlay, tail); | 3619 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 3639 | 3620 | ||
| 3640 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); | 3621 | ptrdiff_t endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); |
| 3641 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); | 3622 | ptrdiff_t startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); |
| 3642 | 3623 | ||
| 3643 | /* If the overlay is backwards, make it empty. */ | 3624 | /* If the overlay is backwards, make it empty. */ |
| 3644 | if (endpos < startpos) | 3625 | if (endpos < startpos) |
| @@ -3676,17 +3657,18 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) | |||
| 3676 | set_buffer_overlays_before (current_buffer, tail->next); | 3657 | set_buffer_overlays_before (current_buffer, tail->next); |
| 3677 | else | 3658 | else |
| 3678 | parent->next = tail->next; | 3659 | parent->next = tail->next; |
| 3679 | tail = tail->next; | ||
| 3680 | } | 3660 | } |
| 3681 | else | 3661 | else |
| 3682 | parent = tail, tail = parent->next; | 3662 | parent = tail; |
| 3683 | } | 3663 | } |
| 3684 | for (parent = NULL, tail = current_buffer->overlays_after; tail;) | 3664 | parent = NULL; |
| 3665 | for (struct Lisp_Overlay *tail = current_buffer->overlays_after; | ||
| 3666 | tail; tail = tail->next) | ||
| 3685 | { | 3667 | { |
| 3686 | XSETMISC (overlay, tail); | 3668 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 3687 | 3669 | ||
| 3688 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); | 3670 | ptrdiff_t startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); |
| 3689 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); | 3671 | ptrdiff_t endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); |
| 3690 | 3672 | ||
| 3691 | /* If the overlay is backwards, make it empty. */ | 3673 | /* If the overlay is backwards, make it empty. */ |
| 3692 | if (endpos < startpos) | 3674 | if (endpos < startpos) |
| @@ -3722,10 +3704,9 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end) | |||
| 3722 | set_buffer_overlays_after (current_buffer, tail->next); | 3704 | set_buffer_overlays_after (current_buffer, tail->next); |
| 3723 | else | 3705 | else |
| 3724 | parent->next = tail->next; | 3706 | parent->next = tail->next; |
| 3725 | tail = tail->next; | ||
| 3726 | } | 3707 | } |
| 3727 | else | 3708 | else |
| 3728 | parent = tail, tail = parent->next; | 3709 | parent = tail; |
| 3729 | } | 3710 | } |
| 3730 | 3711 | ||
| 3731 | /* Splice the constructed (wrong) lists into the buffer's lists, | 3712 | /* Splice the constructed (wrong) lists into the buffer's lists, |
| @@ -3776,7 +3757,7 @@ fix_overlays_before (struct buffer *bp, ptrdiff_t prev, ptrdiff_t pos) | |||
| 3776 | overlay whose ending marker is after-insertion-marker if disorder | 3757 | overlay whose ending marker is after-insertion-marker if disorder |
| 3777 | exists). */ | 3758 | exists). */ |
| 3778 | while (tail | 3759 | while (tail |
| 3779 | && (XSETMISC (tem, tail), | 3760 | && (tem = make_lisp_ptr (tail, Lisp_Vectorlike), |
| 3780 | (end = OVERLAY_POSITION (OVERLAY_END (tem))) >= pos)) | 3761 | (end = OVERLAY_POSITION (OVERLAY_END (tem))) >= pos)) |
| 3781 | { | 3762 | { |
| 3782 | parent = tail; | 3763 | parent = tail; |
| @@ -3801,7 +3782,7 @@ fix_overlays_before (struct buffer *bp, ptrdiff_t prev, ptrdiff_t pos) | |||
| 3801 | overlays are in correct order. */ | 3782 | overlays are in correct order. */ |
| 3802 | while (tail) | 3783 | while (tail) |
| 3803 | { | 3784 | { |
| 3804 | XSETMISC (tem, tail); | 3785 | tem = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 3805 | end = OVERLAY_POSITION (OVERLAY_END (tem)); | 3786 | end = OVERLAY_POSITION (OVERLAY_END (tem)); |
| 3806 | 3787 | ||
| 3807 | if (end == pos) | 3788 | if (end == pos) |
| @@ -4308,19 +4289,14 @@ The lists you get are copies, so that changing them has no effect. | |||
| 4308 | However, the overlays you get are the real objects that the buffer uses. */) | 4289 | However, the overlays you get are the real objects that the buffer uses. */) |
| 4309 | (void) | 4290 | (void) |
| 4310 | { | 4291 | { |
| 4311 | struct Lisp_Overlay *ol; | 4292 | Lisp_Object before = Qnil, after = Qnil; |
| 4312 | Lisp_Object before = Qnil, after = Qnil, tmp; | ||
| 4313 | 4293 | ||
| 4314 | for (ol = current_buffer->overlays_before; ol; ol = ol->next) | 4294 | for (struct Lisp_Overlay *ol = current_buffer->overlays_before; |
| 4315 | { | 4295 | ol; ol = ol->next) |
| 4316 | XSETMISC (tmp, ol); | 4296 | before = Fcons (make_lisp_ptr (ol, Lisp_Vectorlike), before); |
| 4317 | before = Fcons (tmp, before); | 4297 | for (struct Lisp_Overlay *ol = current_buffer->overlays_after; |
| 4318 | } | 4298 | ol; ol = ol->next) |
| 4319 | for (ol = current_buffer->overlays_after; ol; ol = ol->next) | 4299 | after = Fcons (make_lisp_ptr (ol, Lisp_Vectorlike), after); |
| 4320 | { | ||
| 4321 | XSETMISC (tmp, ol); | ||
| 4322 | after = Fcons (tmp, after); | ||
| 4323 | } | ||
| 4324 | 4300 | ||
| 4325 | return Fcons (Fnreverse (before), Fnreverse (after)); | 4301 | return Fcons (Fnreverse (before), Fnreverse (after)); |
| 4326 | } | 4302 | } |
| @@ -4439,14 +4415,9 @@ void | |||
| 4439 | report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after, | 4415 | report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after, |
| 4440 | Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) | 4416 | Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) |
| 4441 | { | 4417 | { |
| 4442 | Lisp_Object prop, overlay; | ||
| 4443 | struct Lisp_Overlay *tail; | ||
| 4444 | /* True if this change is an insertion. */ | 4418 | /* True if this change is an insertion. */ |
| 4445 | bool insertion = (after ? XFIXNAT (arg3) == 0 : EQ (start, end)); | 4419 | bool insertion = (after ? XFIXNAT (arg3) == 0 : EQ (start, end)); |
| 4446 | 4420 | ||
| 4447 | overlay = Qnil; | ||
| 4448 | tail = NULL; | ||
| 4449 | |||
| 4450 | /* We used to run the functions as soon as we found them and only register | 4421 | /* We used to run the functions as soon as we found them and only register |
| 4451 | them in last_overlay_modification_hooks for the purpose of the `after' | 4422 | them in last_overlay_modification_hooks for the purpose of the `after' |
| 4452 | case. But running elisp code as we traverse the list of overlays is | 4423 | case. But running elisp code as we traverse the list of overlays is |
| @@ -4460,12 +4431,13 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after, | |||
| 4460 | /* We are being called before a change. | 4431 | /* We are being called before a change. |
| 4461 | Scan the overlays to find the functions to call. */ | 4432 | Scan the overlays to find the functions to call. */ |
| 4462 | last_overlay_modification_hooks_used = 0; | 4433 | last_overlay_modification_hooks_used = 0; |
| 4463 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) | 4434 | for (struct Lisp_Overlay *tail = current_buffer->overlays_before; |
| 4435 | tail; tail = tail->next) | ||
| 4464 | { | 4436 | { |
| 4465 | ptrdiff_t startpos, endpos; | 4437 | ptrdiff_t startpos, endpos; |
| 4466 | Lisp_Object ostart, oend; | 4438 | Lisp_Object ostart, oend; |
| 4467 | 4439 | ||
| 4468 | XSETMISC (overlay, tail); | 4440 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 4469 | 4441 | ||
| 4470 | ostart = OVERLAY_START (overlay); | 4442 | ostart = OVERLAY_START (overlay); |
| 4471 | oend = OVERLAY_END (overlay); | 4443 | oend = OVERLAY_END (overlay); |
| @@ -4476,14 +4448,14 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after, | |||
| 4476 | if (insertion && (XFIXNAT (start) == startpos | 4448 | if (insertion && (XFIXNAT (start) == startpos |
| 4477 | || XFIXNAT (end) == startpos)) | 4449 | || XFIXNAT (end) == startpos)) |
| 4478 | { | 4450 | { |
| 4479 | prop = Foverlay_get (overlay, Qinsert_in_front_hooks); | 4451 | Lisp_Object prop = Foverlay_get (overlay, Qinsert_in_front_hooks); |
| 4480 | if (!NILP (prop)) | 4452 | if (!NILP (prop)) |
| 4481 | add_overlay_mod_hooklist (prop, overlay); | 4453 | add_overlay_mod_hooklist (prop, overlay); |
| 4482 | } | 4454 | } |
| 4483 | if (insertion && (XFIXNAT (start) == endpos | 4455 | if (insertion && (XFIXNAT (start) == endpos |
| 4484 | || XFIXNAT (end) == endpos)) | 4456 | || XFIXNAT (end) == endpos)) |
| 4485 | { | 4457 | { |
| 4486 | prop = Foverlay_get (overlay, Qinsert_behind_hooks); | 4458 | Lisp_Object prop = Foverlay_get (overlay, Qinsert_behind_hooks); |
| 4487 | if (!NILP (prop)) | 4459 | if (!NILP (prop)) |
| 4488 | add_overlay_mod_hooklist (prop, overlay); | 4460 | add_overlay_mod_hooklist (prop, overlay); |
| 4489 | } | 4461 | } |
| @@ -4491,18 +4463,19 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after, | |||
| 4491 | for both insertion and deletion. */ | 4463 | for both insertion and deletion. */ |
| 4492 | if (XFIXNAT (end) > startpos && XFIXNAT (start) < endpos) | 4464 | if (XFIXNAT (end) > startpos && XFIXNAT (start) < endpos) |
| 4493 | { | 4465 | { |
| 4494 | prop = Foverlay_get (overlay, Qmodification_hooks); | 4466 | Lisp_Object prop = Foverlay_get (overlay, Qmodification_hooks); |
| 4495 | if (!NILP (prop)) | 4467 | if (!NILP (prop)) |
| 4496 | add_overlay_mod_hooklist (prop, overlay); | 4468 | add_overlay_mod_hooklist (prop, overlay); |
| 4497 | } | 4469 | } |
| 4498 | } | 4470 | } |
| 4499 | 4471 | ||
| 4500 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) | 4472 | for (struct Lisp_Overlay *tail = current_buffer->overlays_after; |
| 4473 | tail; tail = tail->next) | ||
| 4501 | { | 4474 | { |
| 4502 | ptrdiff_t startpos, endpos; | 4475 | ptrdiff_t startpos, endpos; |
| 4503 | Lisp_Object ostart, oend; | 4476 | Lisp_Object ostart, oend; |
| 4504 | 4477 | ||
| 4505 | XSETMISC (overlay, tail); | 4478 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 4506 | 4479 | ||
| 4507 | ostart = OVERLAY_START (overlay); | 4480 | ostart = OVERLAY_START (overlay); |
| 4508 | oend = OVERLAY_END (overlay); | 4481 | oend = OVERLAY_END (overlay); |
| @@ -4513,14 +4486,14 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after, | |||
| 4513 | if (insertion && (XFIXNAT (start) == startpos | 4486 | if (insertion && (XFIXNAT (start) == startpos |
| 4514 | || XFIXNAT (end) == startpos)) | 4487 | || XFIXNAT (end) == startpos)) |
| 4515 | { | 4488 | { |
| 4516 | prop = Foverlay_get (overlay, Qinsert_in_front_hooks); | 4489 | Lisp_Object prop = Foverlay_get (overlay, Qinsert_in_front_hooks); |
| 4517 | if (!NILP (prop)) | 4490 | if (!NILP (prop)) |
| 4518 | add_overlay_mod_hooklist (prop, overlay); | 4491 | add_overlay_mod_hooklist (prop, overlay); |
| 4519 | } | 4492 | } |
| 4520 | if (insertion && (XFIXNAT (start) == endpos | 4493 | if (insertion && (XFIXNAT (start) == endpos |
| 4521 | || XFIXNAT (end) == endpos)) | 4494 | || XFIXNAT (end) == endpos)) |
| 4522 | { | 4495 | { |
| 4523 | prop = Foverlay_get (overlay, Qinsert_behind_hooks); | 4496 | Lisp_Object prop = Foverlay_get (overlay, Qinsert_behind_hooks); |
| 4524 | if (!NILP (prop)) | 4497 | if (!NILP (prop)) |
| 4525 | add_overlay_mod_hooklist (prop, overlay); | 4498 | add_overlay_mod_hooklist (prop, overlay); |
| 4526 | } | 4499 | } |
| @@ -4528,7 +4501,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after, | |||
| 4528 | for both insertion and deletion. */ | 4501 | for both insertion and deletion. */ |
| 4529 | if (XFIXNAT (end) > startpos && XFIXNAT (start) < endpos) | 4502 | if (XFIXNAT (end) > startpos && XFIXNAT (start) < endpos) |
| 4530 | { | 4503 | { |
| 4531 | prop = Foverlay_get (overlay, Qmodification_hooks); | 4504 | Lisp_Object prop = Foverlay_get (overlay, Qmodification_hooks); |
| 4532 | if (!NILP (prop)) | 4505 | if (!NILP (prop)) |
| 4533 | add_overlay_mod_hooklist (prop, overlay); | 4506 | add_overlay_mod_hooklist (prop, overlay); |
| 4534 | } | 4507 | } |
| @@ -4596,16 +4569,13 @@ call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, bool after, | |||
| 4596 | void | 4569 | void |
| 4597 | evaporate_overlays (ptrdiff_t pos) | 4570 | evaporate_overlays (ptrdiff_t pos) |
| 4598 | { | 4571 | { |
| 4599 | Lisp_Object overlay, hit_list; | 4572 | Lisp_Object hit_list = Qnil; |
| 4600 | struct Lisp_Overlay *tail; | ||
| 4601 | |||
| 4602 | hit_list = Qnil; | ||
| 4603 | if (pos <= current_buffer->overlay_center) | 4573 | if (pos <= current_buffer->overlay_center) |
| 4604 | for (tail = current_buffer->overlays_before; tail; tail = tail->next) | 4574 | for (struct Lisp_Overlay *tail = current_buffer->overlays_before; |
| 4575 | tail; tail = tail->next) | ||
| 4605 | { | 4576 | { |
| 4606 | ptrdiff_t endpos; | 4577 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 4607 | XSETMISC (overlay, tail); | 4578 | ptrdiff_t endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); |
| 4608 | endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); | ||
| 4609 | if (endpos < pos) | 4579 | if (endpos < pos) |
| 4610 | break; | 4580 | break; |
| 4611 | if (endpos == pos && OVERLAY_POSITION (OVERLAY_START (overlay)) == pos | 4581 | if (endpos == pos && OVERLAY_POSITION (OVERLAY_START (overlay)) == pos |
| @@ -4613,11 +4583,11 @@ evaporate_overlays (ptrdiff_t pos) | |||
| 4613 | hit_list = Fcons (overlay, hit_list); | 4583 | hit_list = Fcons (overlay, hit_list); |
| 4614 | } | 4584 | } |
| 4615 | else | 4585 | else |
| 4616 | for (tail = current_buffer->overlays_after; tail; tail = tail->next) | 4586 | for (struct Lisp_Overlay *tail = current_buffer->overlays_after; |
| 4587 | tail; tail = tail->next) | ||
| 4617 | { | 4588 | { |
| 4618 | ptrdiff_t startpos; | 4589 | Lisp_Object overlay = make_lisp_ptr (tail, Lisp_Vectorlike); |
| 4619 | XSETMISC (overlay, tail); | 4590 | ptrdiff_t startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); |
| 4620 | startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); | ||
| 4621 | if (startpos > pos) | 4591 | if (startpos > pos) |
| 4622 | break; | 4592 | break; |
| 4623 | if (startpos == pos && OVERLAY_POSITION (OVERLAY_END (overlay)) == pos | 4593 | if (startpos == pos && OVERLAY_POSITION (OVERLAY_END (overlay)) == pos |