Mercurial > emacs
comparison src/buffer.c @ 12214:c6ee462394fe
(Fprevious_overlay_change): Check for overlays that end at POS.
| author | Richard M. Stallman <rms@gnu.org> |
|---|---|
| date | Wed, 14 Jun 1995 14:09:53 +0000 |
| parents | d7d7f15f3a92 |
| children | dfcab1d5249d |
comparison
equal
deleted
inserted
replaced
| 12213:59bfaac6cee2 | 12214:c6ee462394fe |
|---|---|
| 2661 } | 2661 } |
| 2662 | 2662 |
| 2663 DEFUN ("previous-overlay-change", Fprevious_overlay_change, | 2663 DEFUN ("previous-overlay-change", Fprevious_overlay_change, |
| 2664 Sprevious_overlay_change, 1, 1, 0, | 2664 Sprevious_overlay_change, 1, 1, 0, |
| 2665 "Return the previous position before POS where an overlay starts or ends.\n\ | 2665 "Return the previous position before POS where an overlay starts or ends.\n\ |
| 2666 If there are no more overlay boundaries after POS, return (point-min).") | 2666 If there are no more overlay boundaries before POS, return (point-min).") |
| 2667 (pos) | 2667 (pos) |
| 2668 Lisp_Object pos; | 2668 Lisp_Object pos; |
| 2669 { | 2669 { |
| 2670 int noverlays; | 2670 int noverlays; |
| 2671 int prevpos; | 2671 int prevpos; |
| 2672 Lisp_Object *overlay_vec; | 2672 Lisp_Object *overlay_vec; |
| 2673 int len; | 2673 int len; |
| 2674 int i; | 2674 int i; |
| 2675 Lisp_Object tail; | |
| 2675 | 2676 |
| 2676 CHECK_NUMBER_COERCE_MARKER (pos, 0); | 2677 CHECK_NUMBER_COERCE_MARKER (pos, 0); |
| 2677 | 2678 |
| 2678 len = 10; | 2679 len = 10; |
| 2679 overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object)); | 2680 overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object)); |
| 2681 | |
| 2682 /* At beginning of buffer, we know the answer; | |
| 2683 avoid bug subtracting 1 below. */ | |
| 2684 if (XINT (pos) == BEGV) | |
| 2685 return pos; | |
| 2680 | 2686 |
| 2681 /* Put all the overlays we want in a vector in overlay_vec. | 2687 /* Put all the overlays we want in a vector in overlay_vec. |
| 2682 Store the length in len. | 2688 Store the length in len. |
| 2683 prevpos gets the position of an overlay end. */ | 2689 prevpos gets the position of an overlay end. */ |
| 2684 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, | 2690 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, |
| 2685 (int *) 0, &prevpos); | 2691 (int *) 0, &prevpos); |
| 2686 | 2692 |
| 2687 /* If any of these overlays starts before endpos, | 2693 /* If any of these overlays starts after prevpos, |
| 2688 maybe use its starting point instead. */ | 2694 maybe use its starting point instead. */ |
| 2689 for (i = 0; i < noverlays; i++) | 2695 for (i = 0; i < noverlays; i++) |
| 2690 { | 2696 { |
| 2691 Lisp_Object ostart; | 2697 Lisp_Object ostart; |
| 2692 int ostartpos; | 2698 int ostartpos; |
| 2693 | 2699 |
| 2694 ostart = OVERLAY_START (overlay_vec[i]); | 2700 ostart = OVERLAY_START (overlay_vec[i]); |
| 2701 ostartpos = OVERLAY_POSITION (ostart); | |
| 2702 if (ostartpos > prevpos && ostartpos < XINT (pos)) | |
| 2703 prevpos = ostartpos; | |
| 2704 } | |
| 2705 | |
| 2706 /* If any overlay ends at pos, consider its starting point too. */ | |
| 2707 for (tail = current_buffer->overlays_before; | |
| 2708 GC_CONSP (tail); | |
| 2709 tail = XCONS (tail)->cdr) | |
| 2710 { | |
| 2711 Lisp_Object overlay, ostart; | |
| 2712 int ostartpos; | |
| 2713 | |
| 2714 overlay = XCONS (tail)->car; | |
| 2715 | |
| 2716 ostart = OVERLAY_START (overlay); | |
| 2695 ostartpos = OVERLAY_POSITION (ostart); | 2717 ostartpos = OVERLAY_POSITION (ostart); |
| 2696 if (ostartpos > prevpos && ostartpos < XINT (pos)) | 2718 if (ostartpos > prevpos && ostartpos < XINT (pos)) |
| 2697 prevpos = ostartpos; | 2719 prevpos = ostartpos; |
| 2698 } | 2720 } |
| 2699 | 2721 |
