Mercurial > emacs
comparison src/buffer.c @ 30695:48cc3d076524
(overlays_at): Add CHANGE_REQ parameter.
(Foverlays_at, Fnext_overlay_change, Fprevious_overlay_change): Use it.
| author | Miles Bader <miles@gnu.org> |
|---|---|
| date | Tue, 08 Aug 2000 23:45:38 +0000 |
| parents | 92f92a541686 |
| children | c1de0fc3a34b |
comparison
equal
deleted
inserted
replaced
| 30694:766ccccf5c4f | 30695:48cc3d076524 |
|---|---|
| 1 /* Buffer manipulation primitives for GNU Emacs. | 1 /* Buffer manipulation primitives for GNU Emacs. |
| 2 Copyright (C) 1985,86,87,88,89,93,94,95,97,98, 1999 | 2 Copyright (C) 1985,86,87,88,89,93,94,95,97,98, 1999, 2000 |
| 3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
| 4 | 4 |
| 5 This file is part of GNU Emacs. | 5 This file is part of GNU Emacs. |
| 6 | 6 |
| 7 GNU Emacs is free software; you can redistribute it and/or modify | 7 GNU Emacs is free software; you can redistribute it and/or modify |
| 2228 when this function is called. | 2228 when this function is called. |
| 2229 | 2229 |
| 2230 If EXTEND is non-zero, we make the vector bigger if necessary. | 2230 If EXTEND is non-zero, we make the vector bigger if necessary. |
| 2231 If EXTEND is zero, we never extend the vector, | 2231 If EXTEND is zero, we never extend the vector, |
| 2232 and we store only as many overlays as will fit. | 2232 and we store only as many overlays as will fit. |
| 2233 But we still return the total number of overlays. */ | 2233 But we still return the total number of overlays. |
| 2234 | |
| 2235 If CHANGE_REQ is true, then any position written into *PREV_PTR or | |
| 2236 *NEXT_PTR is guaranteed to be not equal to POS, unless it is the | |
| 2237 default (BEGV or ZV). */ | |
| 2234 | 2238 |
| 2235 int | 2239 int |
| 2236 overlays_at (pos, extend, vec_ptr, len_ptr, next_ptr, prev_ptr) | 2240 overlays_at (pos, extend, vec_ptr, len_ptr, next_ptr, prev_ptr, change_req) |
| 2237 int pos; | 2241 int pos; |
| 2238 int extend; | 2242 int extend; |
| 2239 Lisp_Object **vec_ptr; | 2243 Lisp_Object **vec_ptr; |
| 2240 int *len_ptr; | 2244 int *len_ptr; |
| 2241 int *next_ptr; | 2245 int *next_ptr; |
| 2242 int *prev_ptr; | 2246 int *prev_ptr; |
| 2247 int change_req; | |
| 2243 { | 2248 { |
| 2244 Lisp_Object tail, overlay, start, end; | 2249 Lisp_Object tail, overlay, start, end; |
| 2245 int idx = 0; | 2250 int idx = 0; |
| 2246 int len = *len_ptr; | 2251 int len = *len_ptr; |
| 2247 Lisp_Object *vec = *vec_ptr; | 2252 Lisp_Object *vec = *vec_ptr; |
| 2343 if (startpos < pos && startpos > prev) | 2348 if (startpos < pos && startpos > prev) |
| 2344 prev = startpos; | 2349 prev = startpos; |
| 2345 } | 2350 } |
| 2346 else if (endpos < pos && endpos > prev) | 2351 else if (endpos < pos && endpos > prev) |
| 2347 prev = endpos; | 2352 prev = endpos; |
| 2348 else if (endpos == pos && startpos > prev) | 2353 else if (endpos == pos && startpos > prev && !change_req) |
| 2349 prev = startpos; | 2354 prev = startpos; |
| 2350 } | 2355 } |
| 2351 | 2356 |
| 2352 if (next_ptr) | 2357 if (next_ptr) |
| 2353 *next_ptr = next; | 2358 *next_ptr = next; |
| 3515 overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object)); | 3520 overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object)); |
| 3516 | 3521 |
| 3517 /* Put all the overlays we want in a vector in overlay_vec. | 3522 /* Put all the overlays we want in a vector in overlay_vec. |
| 3518 Store the length in len. */ | 3523 Store the length in len. */ |
| 3519 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, | 3524 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, |
| 3520 (int *) 0, (int *) 0); | 3525 (int *) 0, (int *) 0, 0); |
| 3521 | 3526 |
| 3522 /* Make a list of them all. */ | 3527 /* Make a list of them all. */ |
| 3523 result = Flist (noverlays, overlay_vec); | 3528 result = Flist (noverlays, overlay_vec); |
| 3524 | 3529 |
| 3525 xfree (overlay_vec); | 3530 xfree (overlay_vec); |
| 3578 | 3583 |
| 3579 /* Put all the overlays we want in a vector in overlay_vec. | 3584 /* Put all the overlays we want in a vector in overlay_vec. |
| 3580 Store the length in len. | 3585 Store the length in len. |
| 3581 endpos gets the position where the next overlay starts. */ | 3586 endpos gets the position where the next overlay starts. */ |
| 3582 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, | 3587 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, |
| 3583 &endpos, (int *) 0); | 3588 &endpos, (int *) 0, 1); |
| 3584 | 3589 |
| 3585 /* If any of these overlays ends before endpos, | 3590 /* If any of these overlays ends before endpos, |
| 3586 use its ending point instead. */ | 3591 use its ending point instead. */ |
| 3587 for (i = 0; i < noverlays; i++) | 3592 for (i = 0; i < noverlays; i++) |
| 3588 { | 3593 { |
| 3623 | 3628 |
| 3624 /* Put all the overlays we want in a vector in overlay_vec. | 3629 /* Put all the overlays we want in a vector in overlay_vec. |
| 3625 Store the length in len. | 3630 Store the length in len. |
| 3626 prevpos gets the position of the previous change. */ | 3631 prevpos gets the position of the previous change. */ |
| 3627 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, | 3632 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, |
| 3628 (int *) 0, &prevpos); | 3633 (int *) 0, &prevpos, 1); |
| 3629 | 3634 |
| 3630 xfree (overlay_vec); | 3635 xfree (overlay_vec); |
| 3631 return make_number (prevpos); | 3636 return make_number (prevpos); |
| 3632 } | 3637 } |
| 3633 | 3638 |
