Function: next-property-change

next-property-change is a function defined in textprop.c.

Signature

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

Documentation

Return the position of next property change.

Scans characters forward from POSITION in OBJECT till it finds a change in some text property, then returns the position of the change. If the optional second argument OBJECT is a buffer (or nil, which means the current buffer), POSITION is a buffer position (integer or marker). If OBJECT is a string, POSITION is a 0-based index into it. Return nil if LIMIT is nil or omitted, and the property is constant all the way to the end of OBJECT; if the value is non-nil, it is a position greater than POSITION, never equal.

If the optional third argument LIMIT is non-nil, don't search past position LIMIT; return LIMIT if nothing is found before LIMIT.

Other relevant functions are documented in the text-properties group.

View in manual

Probably introduced at or before Emacs version 19.23.

Shortdoc

;; text-properties
(next-property-change (point) (current-buffer))

Source Code

// Defined in /usr/src/emacs/src/textprop.c
{
  register INTERVAL i, next;

  if (NILP (object))
    XSETBUFFER (object, current_buffer);

  if (!NILP (limit) && !EQ (limit, Qt))
    CHECK_FIXNUM_COERCE_MARKER (limit);

  i = validate_interval_range (object, &position, &position, soft);

  /* If LIMIT is t, return start of next interval--don't
     bother checking further intervals.  */
  if (EQ (limit, Qt))
    {
      if (!i)
	next = i;
      else
	next = next_interval (i);

      if (!next)
	XSETFASTINT (position, (STRINGP (object)
				? SCHARS (object)
				: BUF_ZV (XBUFFER (object))));
      else
	XSETFASTINT (position, next->position);
      return position;
    }

  if (!i)
    return limit;

  next = next_interval (i);

  while (next && intervals_equal (i, next)
	 && (NILP (limit) || next->position < XFIXNUM (limit)))
    next = next_interval (next);

  if (!next
      || (next->position
	  >= (FIXNUMP (limit)
	      ? XFIXNUM (limit)
	      : (STRINGP (object)
		 ? SCHARS (object)
		 : BUF_ZV (XBUFFER (object))))))
    return limit;
  else
    return make_fixnum (next->position);
}