The primitives for changing properties apply to a specified range of
text. The function set-text-properties (see end of section) sets
the entire property list of the text in that range; more often, it is
useful to add, change, or delete just certain properties specified by
name.
Since text properties are considered part of the buffer's contents, and can affect how the buffer looks on the screen, any change in the text properties is considered a buffer modification. Buffer text property changes are undoable (see Undo).
This function sets the prop property to value for the text between start and end in the string or buffer object. If object is
nil, it defaults to the current buffer.
This function modifies the text properties for the text between start and end in the string or buffer object. If object is
nil, it defaults to the current buffer.The argument props specifies which properties to change. It should have the form of a property list (see Property Lists): a list whose elements include the property names followed alternately by the corresponding values.
The return value is
tif the function actually changed some property's value;nilotherwise (if props isnilor its values agree with those in the text).For example, here is how to set the
commentandfaceproperties of a range of text:(add-text-properties start end '(comment t face highlight))
This function deletes specified text properties from the text between start and end in the string or buffer object. If object is
nil, it defaults to the current buffer.The argument props specifies which properties to delete. It should have the form of a property list (see Property Lists): a list whose elements are property names alternating with corresponding values. But only the names matter—the values that accompany them are ignored. For example, here's how to remove the
faceproperty.(remove-text-properties start end '(face nil))The return value is
tif the function actually changed some property's value;nilotherwise (if props isnilor if no character in the specified text had any of those properties).
This function completely replaces the text property list for the text between start and end in the string or buffer object. If object is
nil, it defaults to the current buffer.The argument props is the new property list. It should be a list whose elements are property names alternating with corresponding values.
After
set-text-propertiesreturns, all the characters in the specified range have identical properties.If props is
nil, the effect is to get rid of all properties from the specified range of text. Here's an example:(set-text-properties start end nil)
See also the function buffer-substring-without-properties
(see Buffer Contents) which copies text from the buffer
but does not copy its properties.