Next: , Previous: , Up: Text Properties   [Contents][Index]


43.18.1 Examining Text Properties

The simplest way to examine text properties is to ask for the value of a particular property of a particular character. For that, use get-text-property. Use text-properties-at to get the entire property list of a character. See Property Search, for functions to examine the properties of a number of characters at once.

These functions handle both strings and buffers. (Keep in mind that positions in a string start from 0, whereas positions in a buffer start from 1.)

Function: get-text-property pos prop &optional object at-flag

This function returns the value of the prop property of the character after position pos in object (a buffer or string). The argument object is optional and defaults to the current buffer.

Function: get-char-property pos prop &optional object at-flag

This function is like get-text-property, except that it checks all extents, not just text-property extents.

Function: text-properties-at position &optional object

This function returns the entire property list of the character at position in the string or buffer object. If object is nil, it defaults to the current buffer.

Variable: default-text-properties

This variable holds a property list giving default values for text properties. Whenever a character does not specify a value for a property, the value stored in this list is used instead. Here is an example:

(setq default-text-properties '(foo 69))
;; Make sure character 1 has no properties of its own.
(set-text-properties 1 2 nil)
;; What we get, when we ask, is the default value.
(get-text-property 1 'foo)
     ⇒ 69

Next: , Previous: , Up: Text Properties   [Contents][Index]