aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorStefan Monnier2003-07-08 21:47:55 +0000
committerStefan Monnier2003-07-08 21:47:55 +0000
commitc2d5b10fc3ba47fec7389de7c98eeb4dd95b3c6e (patch)
tree0680e16cf3ef28da887c41bdf66e88817fcf3b00 /src/buffer.c
parent3ff483be333281cdaf0f5e951a2deaf56576a10e (diff)
downloademacs-c2d5b10fc3ba47fec7389de7c98eeb4dd95b3c6e.tar.gz
emacs-c2d5b10fc3ba47fec7389de7c98eeb4dd95b3c6e.zip
(reset_buffer, recenter_overlay_lists)
(adjust_overlays_for_insert, adjust_overlays_for_delete) (fix_overlays_in_range, Fmake_overlay, Fmove_overlay) (evaporate_overlays, init_buffer_once): Update use of overlay_center. (overlays_at, evaporate_overlays, recenter_overlay_lists) (overlay_strings, fix_overlays_before): Use EMACS_INT for positions.
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c74
1 files changed, 33 insertions, 41 deletions
diff --git a/src/buffer.c b/src/buffer.c
index b0f1a04e3f2..ba441387e17 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -32,7 +32,7 @@ extern int errno;
32#endif 32#endif
33 33
34#ifndef MAXPATHLEN 34#ifndef MAXPATHLEN
35/* in 4.1, param.h fails to define this. */ 35/* in 4.1 [probably SunOS? -stef] , param.h fails to define this. */
36#define MAXPATHLEN 1024 36#define MAXPATHLEN 1024
37#endif /* not MAXPATHLEN */ 37#endif /* not MAXPATHLEN */
38 38
@@ -648,7 +648,7 @@ reset_buffer (b)
648 b->read_only = Qnil; 648 b->read_only = Qnil;
649 b->overlays_before = Qnil; 649 b->overlays_before = Qnil;
650 b->overlays_after = Qnil; 650 b->overlays_after = Qnil;
651 XSETFASTINT (b->overlay_center, 1); 651 b->overlay_center = BEG;
652 b->mark_active = Qnil; 652 b->mark_active = Qnil;
653 b->point_before_scroll = Qnil; 653 b->point_before_scroll = Qnil;
654 b->file_format = Qnil; 654 b->file_format = Qnil;
@@ -2420,7 +2420,7 @@ swap_out_buffer_local_variables (b)
2420 2420
2421int 2421int
2422overlays_at (pos, extend, vec_ptr, len_ptr, next_ptr, prev_ptr, change_req) 2422overlays_at (pos, extend, vec_ptr, len_ptr, next_ptr, prev_ptr, change_req)
2423 int pos; 2423 EMACS_INT pos;
2424 int extend; 2424 int extend;
2425 Lisp_Object **vec_ptr; 2425 Lisp_Object **vec_ptr;
2426 int *len_ptr; 2426 int *len_ptr;
@@ -2942,7 +2942,7 @@ record_overlay_string (ssl, str, str2, pri, size)
2942 2942
2943int 2943int
2944overlay_strings (pos, w, pstr) 2944overlay_strings (pos, w, pstr)
2945 int pos; 2945 EMACS_INT pos;
2946 struct window *w; 2946 struct window *w;
2947 unsigned char **pstr; 2947 unsigned char **pstr;
2948{ 2948{
@@ -2955,8 +2955,7 @@ overlay_strings (pos, w, pstr)
2955 for (ov = current_buffer->overlays_before; CONSP (ov); ov = XCDR (ov)) 2955 for (ov = current_buffer->overlays_before; CONSP (ov); ov = XCDR (ov))
2956 { 2956 {
2957 overlay = XCAR (ov); 2957 overlay = XCAR (ov);
2958 if (!OVERLAYP (overlay)) 2958 eassert (OVERLAYP (overlay));
2959 abort ();
2960 2959
2961 startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); 2960 startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
2962 endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); 2961 endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
@@ -2984,8 +2983,7 @@ overlay_strings (pos, w, pstr)
2984 for (ov = current_buffer->overlays_after; CONSP (ov); ov = XCDR (ov)) 2983 for (ov = current_buffer->overlays_after; CONSP (ov); ov = XCDR (ov))
2985 { 2984 {
2986 overlay = XCAR (ov); 2985 overlay = XCAR (ov);
2987 if (!OVERLAYP (overlay)) 2986 eassert (!OVERLAYP (overlay));
2988 abort ();
2989 2987
2990 startpos = OVERLAY_POSITION (OVERLAY_START (overlay)); 2988 startpos = OVERLAY_POSITION (OVERLAY_START (overlay));
2991 endpos = OVERLAY_POSITION (OVERLAY_END (overlay)); 2989 endpos = OVERLAY_POSITION (OVERLAY_END (overlay));
@@ -3070,7 +3068,7 @@ overlay_strings (pos, w, pstr)
3070void 3068void
3071recenter_overlay_lists (buf, pos) 3069recenter_overlay_lists (buf, pos)
3072 struct buffer *buf; 3070 struct buffer *buf;
3073 int pos; 3071 EMACS_INT pos;
3074{ 3072{
3075 Lisp_Object overlay, tail, next, prev, beg, end; 3073 Lisp_Object overlay, tail, next, prev, beg, end;
3076 3074
@@ -3127,8 +3125,7 @@ recenter_overlay_lists (buf, pos)
3127 Lisp_Object otherbeg, otheroverlay; 3125 Lisp_Object otherbeg, otheroverlay;
3128 3126
3129 otheroverlay = XCAR (other); 3127 otheroverlay = XCAR (other);
3130 if (! OVERLAY_VALID (otheroverlay)) 3128 eassert (! OVERLAY_VALID (otheroverlay));
3131 abort ();
3132 3129
3133 otherbeg = OVERLAY_START (otheroverlay); 3130 otherbeg = OVERLAY_START (otheroverlay);
3134 if (OVERLAY_POSITION (otherbeg) >= where) 3131 if (OVERLAY_POSITION (otherbeg) >= where)
@@ -3204,8 +3201,7 @@ recenter_overlay_lists (buf, pos)
3204 Lisp_Object otherend, otheroverlay; 3201 Lisp_Object otherend, otheroverlay;
3205 3202
3206 otheroverlay = XCAR (other); 3203 otheroverlay = XCAR (other);
3207 if (! OVERLAY_VALID (otheroverlay)) 3204 eassert (! OVERLAY_VALID (otheroverlay));
3208 abort ();
3209 3205
3210 otherend = OVERLAY_END (otheroverlay); 3206 otherend = OVERLAY_END (otheroverlay);
3211 if (OVERLAY_POSITION (otherend) <= where) 3207 if (OVERLAY_POSITION (otherend) <= where)
@@ -3222,36 +3218,34 @@ recenter_overlay_lists (buf, pos)
3222 } 3218 }
3223 } 3219 }
3224 3220
3225 XSETFASTINT (buf->overlay_center, pos); 3221 buf->overlay_center = pos;
3226} 3222}
3227 3223
3228void 3224void
3229adjust_overlays_for_insert (pos, length) 3225adjust_overlays_for_insert (pos, length)
3230 int pos; 3226 EMACS_INT pos;
3231 int length; 3227 EMACS_INT length;
3232{ 3228{
3233 /* After an insertion, the lists are still sorted properly, 3229 /* After an insertion, the lists are still sorted properly,
3234 but we may need to update the value of the overlay center. */ 3230 but we may need to update the value of the overlay center. */
3235 if (XFASTINT (current_buffer->overlay_center) >= pos) 3231 if (current_buffer->overlay_center >= pos)
3236 XSETFASTINT (current_buffer->overlay_center, 3232 current_buffer->overlay_center += length;
3237 XFASTINT (current_buffer->overlay_center) + length);
3238} 3233}
3239 3234
3240void 3235void
3241adjust_overlays_for_delete (pos, length) 3236adjust_overlays_for_delete (pos, length)
3242 int pos; 3237 EMACS_INT pos;
3243 int length; 3238 EMACS_INT length;
3244{ 3239{
3245 if (XFASTINT (current_buffer->overlay_center) < pos) 3240 if (current_buffer->overlay_center < pos)
3246 /* The deletion was to our right. No change needed; the before- and 3241 /* The deletion was to our right. No change needed; the before- and
3247 after-lists are still consistent. */ 3242 after-lists are still consistent. */
3248 ; 3243 ;
3249 else if (XFASTINT (current_buffer->overlay_center) > pos + length) 3244 else if (current_buffer->overlay_center > pos + length)
3250 /* The deletion was to our left. We need to adjust the center value 3245 /* The deletion was to our left. We need to adjust the center value
3251 to account for the change in position, but the lists are consistent 3246 to account for the change in position, but the lists are consistent
3252 given the new value. */ 3247 given the new value. */
3253 XSETFASTINT (current_buffer->overlay_center, 3248 current_buffer->overlay_center -= length;
3254 XFASTINT (current_buffer->overlay_center) - length);
3255 else 3249 else
3256 /* We're right in the middle. There might be things on the after-list 3250 /* We're right in the middle. There might be things on the after-list
3257 that now belong on the before-list. Recentering will move them, 3251 that now belong on the before-list. Recentering will move them,
@@ -3311,7 +3305,7 @@ fix_overlays_in_range (start, end)
3311 } 3305 }
3312 /* Add it to the end of the wrong list. Later on, 3306 /* Add it to the end of the wrong list. Later on,
3313 recenter_overlay_lists will move it to the right place. */ 3307 recenter_overlay_lists will move it to the right place. */
3314 if (endpos < XINT (current_buffer->overlay_center)) 3308 if (endpos < current_buffer->overlay_center)
3315 { 3309 {
3316 if (NILP (afterp)) 3310 if (NILP (afterp))
3317 after_list = tail; 3311 after_list = tail;
@@ -3355,7 +3349,7 @@ fix_overlays_in_range (start, end)
3355 Qnil); 3349 Qnil);
3356 tem = startpos; startpos = endpos; endpos = tem; 3350 tem = startpos; startpos = endpos; endpos = tem;
3357 } 3351 }
3358 if (endpos < XINT (current_buffer->overlay_center)) 3352 if (endpos < current_buffer->overlay_center)
3359 { 3353 {
3360 if (NILP (afterp)) 3354 if (NILP (afterp))
3361 after_list = tail; 3355 after_list = tail;
@@ -3388,16 +3382,14 @@ fix_overlays_in_range (start, end)
3388 XSETCDR (beforep, current_buffer->overlays_before); 3382 XSETCDR (beforep, current_buffer->overlays_before);
3389 current_buffer->overlays_before = before_list; 3383 current_buffer->overlays_before = before_list;
3390 } 3384 }
3391 recenter_overlay_lists (current_buffer, 3385 recenter_overlay_lists (current_buffer, current_buffer->overlay_center);
3392 XINT (current_buffer->overlay_center));
3393 3386
3394 if (!NILP (afterp)) 3387 if (!NILP (afterp))
3395 { 3388 {
3396 XSETCDR (afterp, current_buffer->overlays_after); 3389 XSETCDR (afterp, current_buffer->overlays_after);
3397 current_buffer->overlays_after = after_list; 3390 current_buffer->overlays_after = after_list;
3398 } 3391 }
3399 recenter_overlay_lists (current_buffer, 3392 recenter_overlay_lists (current_buffer, current_buffer->overlay_center);
3400 XINT (current_buffer->overlay_center));
3401} 3393}
3402 3394
3403/* We have two types of overlay: the one whose ending marker is 3395/* We have two types of overlay: the one whose ending marker is
@@ -3415,12 +3407,12 @@ fix_overlays_in_range (start, end)
3415void 3407void
3416fix_overlays_before (bp, prev, pos) 3408fix_overlays_before (bp, prev, pos)
3417 struct buffer *bp; 3409 struct buffer *bp;
3418 int prev, pos; 3410 EMACS_INT prev, pos;
3419{ 3411{
3420 /* If parent is nil, replace overlays_before; otherwise, XCDR(parent). */ 3412 /* If parent is nil, replace overlays_before; otherwise, XCDR(parent). */
3421 Lisp_Object tail = bp->overlays_before, parent = Qnil; 3413 Lisp_Object tail = bp->overlays_before, parent = Qnil;
3422 Lisp_Object right_pair; 3414 Lisp_Object right_pair;
3423 int end; 3415 EMACS_INT end;
3424 3416
3425 /* After the insertion, the several overlays may be in incorrect 3417 /* After the insertion, the several overlays may be in incorrect
3426 order. The possibility is that, in the list `overlays_before', 3418 order. The possibility is that, in the list `overlays_before',
@@ -3554,13 +3546,13 @@ rear delimiter advance when text is inserted there. */)
3554 3546
3555 /* Put the new overlay on the wrong list. */ 3547 /* Put the new overlay on the wrong list. */
3556 end = OVERLAY_END (overlay); 3548 end = OVERLAY_END (overlay);
3557 if (OVERLAY_POSITION (end) < XINT (b->overlay_center)) 3549 if (OVERLAY_POSITION (end) < b->overlay_center)
3558 b->overlays_after = Fcons (overlay, b->overlays_after); 3550 b->overlays_after = Fcons (overlay, b->overlays_after);
3559 else 3551 else
3560 b->overlays_before = Fcons (overlay, b->overlays_before); 3552 b->overlays_before = Fcons (overlay, b->overlays_before);
3561 3553
3562 /* This puts it in the right list, and in the right order. */ 3554 /* This puts it in the right list, and in the right order. */
3563 recenter_overlay_lists (b, XINT (b->overlay_center)); 3555 recenter_overlay_lists (b, b->overlay_center);
3564 3556
3565 /* We don't need to redisplay the region covered by the overlay, because 3557 /* We don't need to redisplay the region covered by the overlay, because
3566 the overlay has no properties at the moment. */ 3558 the overlay has no properties at the moment. */
@@ -3573,7 +3565,7 @@ rear delimiter advance when text is inserted there. */)
3573static void 3565static void
3574modify_overlay (buf, start, end) 3566modify_overlay (buf, start, end)
3575 struct buffer *buf; 3567 struct buffer *buf;
3576 int start, end; 3568 EMACS_INT start, end;
3577{ 3569{
3578 if (start > end) 3570 if (start > end)
3579 { 3571 {
@@ -3691,13 +3683,13 @@ buffer. */)
3691 3683
3692 /* Put the overlay on the wrong list. */ 3684 /* Put the overlay on the wrong list. */
3693 end = OVERLAY_END (overlay); 3685 end = OVERLAY_END (overlay);
3694 if (OVERLAY_POSITION (end) < XINT (b->overlay_center)) 3686 if (OVERLAY_POSITION (end) < b->overlay_center)
3695 b->overlays_after = Fcons (overlay, b->overlays_after); 3687 b->overlays_after = Fcons (overlay, b->overlays_after);
3696 else 3688 else
3697 b->overlays_before = Fcons (overlay, b->overlays_before); 3689 b->overlays_before = Fcons (overlay, b->overlays_before);
3698 3690
3699 /* This puts it in the right list, and in the right order. */ 3691 /* This puts it in the right list, and in the right order. */
3700 recenter_overlay_lists (b, XINT (b->overlay_center)); 3692 recenter_overlay_lists (b, b->overlay_center);
3701 3693
3702 return unbind_to (count, overlay); 3694 return unbind_to (count, overlay);
3703} 3695}
@@ -4241,12 +4233,12 @@ call_overlay_mod_hooks (list, overlay, after, arg1, arg2, arg3)
4241 property is set. */ 4233 property is set. */
4242void 4234void
4243evaporate_overlays (pos) 4235evaporate_overlays (pos)
4244 int pos; 4236 EMACS_INT pos;
4245{ 4237{
4246 Lisp_Object tail, overlay, hit_list; 4238 Lisp_Object tail, overlay, hit_list;
4247 4239
4248 hit_list = Qnil; 4240 hit_list = Qnil;
4249 if (pos <= XFASTINT (current_buffer->overlay_center)) 4241 if (pos <= current_buffer->overlay_center)
4250 for (tail = current_buffer->overlays_before; CONSP (tail); 4242 for (tail = current_buffer->overlays_before; CONSP (tail);
4251 tail = XCDR (tail)) 4243 tail = XCDR (tail))
4252 { 4244 {
@@ -4906,7 +4898,7 @@ init_buffer_once ()
4906 buffer_defaults.file_format = Qnil; 4898 buffer_defaults.file_format = Qnil;
4907 buffer_defaults.overlays_before = Qnil; 4899 buffer_defaults.overlays_before = Qnil;
4908 buffer_defaults.overlays_after = Qnil; 4900 buffer_defaults.overlays_after = Qnil;
4909 XSETFASTINT (buffer_defaults.overlay_center, BEG); 4901 buffer_defaults.overlay_center = BEG;
4910 4902
4911 XSETFASTINT (buffer_defaults.tab_width, 8); 4903 XSETFASTINT (buffer_defaults.tab_width, 8);
4912 buffer_defaults.truncate_lines = Qnil; 4904 buffer_defaults.truncate_lines = Qnil;