Mercurial > emacs
comparison src/buffer.c @ 92975:ca18807830f1
(overlays_in, Foverlays_in): Include empty overlays
at end of range when it coincides with the end of the buffer.
| author | Martin Rudalics <rudalics@gmx.at> |
|---|---|
| date | Sat, 15 Mar 2008 09:13:59 +0000 |
| parents | b0c32527b009 |
| children | 87f463ae1530 |
comparison
equal
deleted
inserted
replaced
| 92974:ea61d2529bd4 | 92975:ca18807830f1 |
|---|---|
| 1632 | 1632 |
| 1633 XSETCDR (link, Vbuffer_alist); | 1633 XSETCDR (link, Vbuffer_alist); |
| 1634 Vbuffer_alist = link; | 1634 Vbuffer_alist = link; |
| 1635 | 1635 |
| 1636 /* Effectively do a delq on buried_buffer_list. */ | 1636 /* Effectively do a delq on buried_buffer_list. */ |
| 1637 | 1637 |
| 1638 prev = Qnil; | 1638 prev = Qnil; |
| 1639 for (link = XFRAME (frame)->buried_buffer_list; CONSP (link); | 1639 for (link = XFRAME (frame)->buried_buffer_list; CONSP (link); |
| 1640 link = XCDR (link)) | 1640 link = XCDR (link)) |
| 1641 { | 1641 { |
| 1642 if (EQ (XCAR (link), buf)) | 1642 if (EQ (XCAR (link), buf)) |
| 2811 if (prev_ptr) | 2811 if (prev_ptr) |
| 2812 *prev_ptr = prev; | 2812 *prev_ptr = prev; |
| 2813 return idx; | 2813 return idx; |
| 2814 } | 2814 } |
| 2815 | 2815 |
| 2816 /* Find all the overlays in the current buffer that overlap the range BEG-END | 2816 /* Find all the overlays in the current buffer that overlap the range |
| 2817 or are empty at BEG. | 2817 BEG-END, or are empty at BEG, or are empty at END provided END |
| 2818 denotes the position at the end of the current buffer. | |
| 2818 | 2819 |
| 2819 Return the number found, and store them in a vector in *VEC_PTR. | 2820 Return the number found, and store them in a vector in *VEC_PTR. |
| 2820 Store in *LEN_PTR the size allocated for the vector. | 2821 Store in *LEN_PTR the size allocated for the vector. |
| 2821 Store in *NEXT_PTR the next position after POS where an overlay starts, | 2822 Store in *NEXT_PTR the next position after POS where an overlay starts, |
| 2822 or ZV if there are no more overlays. | 2823 or ZV if there are no more overlays. |
| 2847 int len = *len_ptr; | 2848 int len = *len_ptr; |
| 2848 Lisp_Object *vec = *vec_ptr; | 2849 Lisp_Object *vec = *vec_ptr; |
| 2849 int next = ZV; | 2850 int next = ZV; |
| 2850 int prev = BEGV; | 2851 int prev = BEGV; |
| 2851 int inhibit_storing = 0; | 2852 int inhibit_storing = 0; |
| 2853 int end_is_Z = end == Z; | |
| 2852 | 2854 |
| 2853 for (tail = current_buffer->overlays_before; tail; tail = tail->next) | 2855 for (tail = current_buffer->overlays_before; tail; tail = tail->next) |
| 2854 { | 2856 { |
| 2855 int startpos, endpos; | 2857 int startpos, endpos; |
| 2856 | 2858 |
| 2864 if (prev < endpos) | 2866 if (prev < endpos) |
| 2865 prev = endpos; | 2867 prev = endpos; |
| 2866 break; | 2868 break; |
| 2867 } | 2869 } |
| 2868 startpos = OVERLAY_POSITION (ostart); | 2870 startpos = OVERLAY_POSITION (ostart); |
| 2869 /* Count an interval if it either overlaps the range | 2871 /* Count an interval if it overlaps the range, is empty at the |
| 2870 or is empty at the start of the range. */ | 2872 start of the range, or is empty at END provided END denotes the |
| 2873 end of the buffer. */ | |
| 2871 if ((beg < endpos && startpos < end) | 2874 if ((beg < endpos && startpos < end) |
| 2872 || (startpos == endpos && beg == endpos)) | 2875 || (startpos == endpos |
| 2876 && (beg == endpos || (end_is_Z && endpos == end)))) | |
| 2873 { | 2877 { |
| 2874 if (idx == len) | 2878 if (idx == len) |
| 2875 { | 2879 { |
| 2876 /* The supplied vector is full. | 2880 /* The supplied vector is full. |
| 2877 Either make it bigger, or don't store any more in it. */ | 2881 Either make it bigger, or don't store any more in it. */ |
| 2912 if (startpos < next) | 2916 if (startpos < next) |
| 2913 next = startpos; | 2917 next = startpos; |
| 2914 break; | 2918 break; |
| 2915 } | 2919 } |
| 2916 endpos = OVERLAY_POSITION (oend); | 2920 endpos = OVERLAY_POSITION (oend); |
| 2917 /* Count an interval if it either overlaps the range | 2921 /* Count an interval if it overlaps the range, is empty at the |
| 2918 or is empty at the start of the range. */ | 2922 start of the range, or is empty at END provided END denotes the |
| 2923 end of the buffer. */ | |
| 2919 if ((beg < endpos && startpos < end) | 2924 if ((beg < endpos && startpos < end) |
| 2920 || (startpos == endpos && beg == endpos)) | 2925 || (startpos == endpos |
| 2926 && (beg == endpos || (end_is_Z && endpos == end)))) | |
| 2921 { | 2927 { |
| 2922 if (idx == len) | 2928 if (idx == len) |
| 2923 { | 2929 { |
| 2924 if (extend) | 2930 if (extend) |
| 2925 { | 2931 { |
| 4111 | 4117 |
| 4112 DEFUN ("overlays-in", Foverlays_in, Soverlays_in, 2, 2, 0, | 4118 DEFUN ("overlays-in", Foverlays_in, Soverlays_in, 2, 2, 0, |
| 4113 doc: /* Return a list of the overlays that overlap the region BEG ... END. | 4119 doc: /* Return a list of the overlays that overlap the region BEG ... END. |
| 4114 Overlap means that at least one character is contained within the overlay | 4120 Overlap means that at least one character is contained within the overlay |
| 4115 and also contained within the specified region. | 4121 and also contained within the specified region. |
| 4116 Empty overlays are included in the result if they are located at BEG | 4122 Empty overlays are included in the result if they are located at BEG, |
| 4117 or between BEG and END. */) | 4123 between BEG and END, or at END provided END denotes the position at the |
| 4124 end of the buffer. */) | |
| 4118 (beg, end) | 4125 (beg, end) |
| 4119 Lisp_Object beg, end; | 4126 Lisp_Object beg, end; |
| 4120 { | 4127 { |
| 4121 int noverlays; | 4128 int noverlays; |
| 4122 Lisp_Object *overlay_vec; | 4129 Lisp_Object *overlay_vec; |
