next-single-char-property-change on xemacs vs emacs

David Kastrup dak at gnu.org
Fri Feb 11 12:03:29 EST 2011


"Stephen J. Turnbull" <stephen at xemacs.org> writes:

> Raymond Toy writes:
>
>  > > Is this behavior actually useful?
>
>  > Yes.  Slime basically does (goto-char (next-single-char-property-change
>  > <args>)), which obviously breaks with xemacs when n-s-c-p-c returns
>  > nil.
>
> Sure.  But my question is, "is it useful to end up at the end of the
> buffer if there are no more property changes?"  This is basically a
> search function, and there are four behaviors I can think of here:
> error, go to end of text, wrap around, do nothing.  The first is worse
> than useless, but it's not obvious a priori that "return end of text"
> has an advantage over the other two except to avoid a trivial change:
>
>     ;; the "or" is a no-op in Emacs
>     (goto-char (or (next-single-char-property-change ...)
> 		   (the-place-slime-really-wants-to-be)))
>
>  > At least emacs says n-s-c-p-c is supposed to return the end of the
>  > object when there is no more n-s-c-p-c.
>
> It's arguable this is not very useful, since that behavior is already
> available in XEmacs:
>
>     (next-single-char-property-change POS PROP nil (point-max))
>
> So the question is really, is the code of the form
>
>     (while (not (eobp))
>       (goto-char (next-single-char-property-change (point) PROP))
>       ;; It's useful to do something at eob!  Do it there too!
>       (do-something))

It may be worth pointing out that for XEmacs, text properties and
overlays are the same.

Emacs has (for just text properties):

    next-single-property-change is a built-in function in `C source code'.

    (next-single-property-change POSITION PROP &optional OBJECT LIMIT)

    Return the position of next property change for a specific property.

    [...]

    Return nil if the property is constant all the way to the end of OBJECT.


and it has for either text properties and overlays (namely as something
with purportedly more compatibility to XEmacs):

    next-single-char-property-change is a built-in function in `C source
    code'.

    (next-single-char-property-change POSITION PROP &optional OBJECT
    LIMIT)

    Return the position of next text property or overlay change for a
    specific property.

    If the property is constant all the way to the end of OBJECT, return the
    last valid position in OBJECT.

As well as

    next-overlay-change is a built-in function in `C source code'.

    (next-overlay-change POS)

    Return the next position after POS where an overlay starts or ends.
    If there are no overlay boundaries from POS to (point-max),
    the value is (point-max).

If you ask me, it might make sense to ask the Emacs camp whether there
any plans for improving the coherence of the above before deciding how
to mimic what.

-- 
David Kastrup



More information about the XEmacs-Beta mailing list