map-extents, etc. What is the order of extents in these functions?

Ben Wing ben at benwing.com
Fri Mar 12 20:23:04 EST 2010


On Fri, Mar 12, 2010 at 3:49 AM, Alan Mackenzie <acm at muc.de> wrote:
> Hi, Stephen!
>
> On Thu, Mar 11, 2010 at 04:59:52PM +0900, Stephen J. Turnbull wrote:
>> Alan Mackenzie writes:
>
>>  > It would be nice to use map-extents for the forward version here.  Can I
>>  > assume that map-extents processes extents in "display order"?  The
>>  > doc string and the fine manual forget to mention this.
>
>> Yes, you may assume that.
>
> Thanks1!

Actually, I think it would be best not to assume this.  I wrote the
implementation of map-extents, and although I can't remember exactly
how it works any more, it's pretty complicated and involves two
different stages, the first of which uses a cache (aka "stack of
extents"), consisting of extents that overlaps a known position, and
the second of which just iterates normally over extents.  Almost
certainly the second stage uses display order, but it's far from
obvious (to me at least, without looking at the code more closely)
that the first stage does, or that the extents seen in the first stage
are always before (in display order) the ones in the second stage.
Also, even if map-extents happens to always map in display order, it's
an undocumented feature that is subject to change.

You might want to consider instead looping with `next-extent-change'
or `next-single-char-property-change' or something like that.

ben



More information about the XEmacs-Beta mailing list