Function: remove-list-of-text-properties

remove-list-of-text-properties is a function defined in textprop.c.

Signature

(remove-list-of-text-properties START END LIST-OF-PROPERTIES &optional OBJECT)

Documentation

Remove some properties from text from START to END.

The third argument LIST-OF-PROPERTIES is a list of property names to remove. If the optional fourth argument OBJECT is a buffer (or nil, which means the current buffer), START and END are buffer positions (integers or markers). If OBJECT is a string, START and END are 0-based indices into it. Return t if any property was actually removed, nil otherwise.

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

View in manual

Probably introduced at or before Emacs version 22.1.

Shortdoc

;; text-properties
(remove-list-of-text-properties (point) (1+ (point)) '(face font-lock-face))

Source Code

// Defined in /usr/src/emacs/src/textprop.c
{
  /* Ensure we run the modification hooks for the right buffer,
     without switching buffers twice (bug 36190).  FIXME: Switching
     buffers is slow and often unnecessary.  */
  if (BUFFERP (object) && XBUFFER (object) != current_buffer)
    {
      specpdl_ref count = SPECPDL_INDEX ();
      record_unwind_current_buffer ();
      set_buffer_internal (XBUFFER (object));
      return unbind_to (count,
			Fremove_list_of_text_properties (start, end,
							 list_of_properties,
							 object));
    }

  INTERVAL i, unchanged;
  ptrdiff_t s, len;
  bool modified = false;
  Lisp_Object properties;
  properties = list_of_properties;

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

  i = validate_interval_range (object, &start, &end, soft);
  if (!i)
    return Qnil;

  s = XFIXNUM (start);
  len = XFIXNUM (end) - s;

  /* If there are no properties on the interval, return.  */
  if (! interval_has_some_properties_list (properties, i))
    {
      ptrdiff_t got = LENGTH (i) - (s - i->position);

      do
	{
	  if (got >= len)
	    return Qnil;
	  len -= got;
	  i = next_interval (i);
	  got = LENGTH (i);
	}
      while (! interval_has_some_properties_list (properties, i));
    }
  /* Split away the beginning of this interval; what we don't
     want to modify.  */
  else if (i->position != s)
    {
      unchanged = i;
      i = split_interval_right (unchanged, s - unchanged->position);
      copy_properties (unchanged, i);
    }

  /* We are at the beginning of an interval, with len to scan.
     The flag MODIFIED records if changes have been made.
     When object is a buffer, we must call modify_text_properties
     before changes are made and signal_after_change when we are done.
     Call modify_text_properties before calling remove_properties if !MODIFIED,
     and call signal_after_change before returning if MODIFIED. */
  for (;;)
    {
      eassert (i != 0);

      if (LENGTH (i) >= len)
	{
	  if (! interval_has_some_properties_list (properties, i))
	    {
	      if (modified)
		{
		  if (BUFFERP (object))
		    signal_after_change (XFIXNUM (start),
					 XFIXNUM (end) - XFIXNUM (start),
					 XFIXNUM (end) - XFIXNUM (start));
		  return Qt;
		}
	      else
		return Qnil;
	    }
	  else if (LENGTH (i) == len)
	    {
	      if (!modified && BUFFERP (object))
		modify_text_properties (object, start, end);
	      remove_properties (Qnil, properties, i, object);
	      if (BUFFERP (object))
		signal_after_change (XFIXNUM (start), XFIXNUM (end) - XFIXNUM (start),
				     XFIXNUM (end) - XFIXNUM (start));
	      return Qt;
	    }
	  else
	    { /* i has the properties, and goes past the change limit.  */
	      unchanged = i;
	      i = split_interval_left (i, len);
	      copy_properties (unchanged, i);
	      if (!modified && BUFFERP (object))
		modify_text_properties (object, start, end);
	      remove_properties (Qnil, properties, i, object);
	      if (BUFFERP (object))
		signal_after_change (XFIXNUM (start), XFIXNUM (end) - XFIXNUM (start),
				     XFIXNUM (end) - XFIXNUM (start));
	      return Qt;
	    }
	}
      if (interval_has_some_properties_list (properties, i))
	{
	  if (!modified && BUFFERP (object))
	    modify_text_properties (object, start, end);
	  remove_properties (Qnil, properties, i, object);
	  modified = true;
	}
      len -= LENGTH (i);
      i = next_interval (i);
      if (!i)
        {
          if (modified)
            {
              if (BUFFERP (object))
                signal_after_change (XFIXNUM (start),
                                     XFIXNUM (end) - XFIXNUM (start),
                                     XFIXNUM (end) - XFIXNUM (start));
              return Qt;
            }
          else
            return Qnil;
        }
    }
}