Mercurial > emacs
comparison lispref/text.texi @ 71645:0fc55b1cc3c9
(Buffer Contents): Add example of text props in result of buffer-substring.
(Text Properties): Explain better about use of specific property names.
(Property Search): Some cleanups; reorder some functions.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 05 Jul 2006 17:09:30 +0000 |
parents | a358bd87a242 |
children | e00b85e33a53 138ce2701550 |
comparison
equal
deleted
inserted
replaced
71644:ac52c6d8a154 | 71645:0fc55b1cc3c9 |
---|---|
174 | 174 |
175 It is not necessary for @var{start} to be less than @var{end}; the | 175 It is not necessary for @var{start} to be less than @var{end}; the |
176 arguments can be given in either order. But most often the smaller | 176 arguments can be given in either order. But most often the smaller |
177 argument is written first. | 177 argument is written first. |
178 | 178 |
179 If the text being copied has any text properties, these are copied into | 179 Here's an example which assumes Font-Lock mode is not enabled: |
180 the string along with the characters they belong to. @xref{Text | |
181 Properties}. However, overlays (@pxref{Overlays}) in the buffer and | |
182 their properties are ignored, not copied. | |
183 | 180 |
184 @example | 181 @example |
185 @group | 182 @group |
186 ---------- Buffer: foo ---------- | 183 ---------- Buffer: foo ---------- |
187 This is the contents of buffer foo | 184 This is the contents of buffer foo |
194 @result{} "This is t" | 191 @result{} "This is t" |
195 @end group | 192 @end group |
196 @group | 193 @group |
197 (buffer-substring (point-max) 10) | 194 (buffer-substring (point-max) 10) |
198 @result{} "he contents of buffer foo\n" | 195 @result{} "he contents of buffer foo\n" |
196 @end group | |
197 @end example | |
198 | |
199 If the text being copied has any text properties, these are copied into | |
200 the string along with the characters they belong to. @xref{Text | |
201 Properties}. However, overlays (@pxref{Overlays}) in the buffer and | |
202 their properties are ignored, not copied. | |
203 | |
204 For example, if Font-Lock mode is enabled, you might get results like | |
205 these: | |
206 | |
207 @example | |
208 @group | |
209 (buffer-substring 1 10) | |
210 @result{} #("This is t" 0 1 (fontified t) 1 9 (fontified t)) | |
199 @end group | 211 @end group |
200 @end example | 212 @end example |
201 @end defun | 213 @end defun |
202 | 214 |
203 @defun buffer-substring-no-properties start end | 215 @defun buffer-substring-no-properties start end |
2528 Each character position in a buffer or a string can have a @dfn{text | 2540 Each character position in a buffer or a string can have a @dfn{text |
2529 property list}, much like the property list of a symbol (@pxref{Property | 2541 property list}, much like the property list of a symbol (@pxref{Property |
2530 Lists}). The properties belong to a particular character at a | 2542 Lists}). The properties belong to a particular character at a |
2531 particular place, such as, the letter @samp{T} at the beginning of this | 2543 particular place, such as, the letter @samp{T} at the beginning of this |
2532 sentence or the first @samp{o} in @samp{foo}---if the same character | 2544 sentence or the first @samp{o} in @samp{foo}---if the same character |
2533 occurs in two different places, the two occurrences generally have | 2545 occurs in two different places, the two occurrences in general have |
2534 different properties. | 2546 different properties. |
2535 | 2547 |
2536 Each property has a name and a value. Both of these can be any Lisp | 2548 Each property has a name and a value. Both of these can be any Lisp |
2537 object, but the name is normally a symbol. The usual way to access the | 2549 object, but the name is normally a symbol. Typically each property |
2538 property list is to specify a name and ask what value corresponds to it. | 2550 name symbol is used for a particular purpose; for instance, the text |
2551 property @code{face} specifies the faces for displaying the character | |
2552 (@pxref{Special Properties}). The usual way to access the property | |
2553 list is to specify a name and ask what value corresponds to it. | |
2539 | 2554 |
2540 If a character has a @code{category} property, we call it the | 2555 If a character has a @code{category} property, we call it the |
2541 @dfn{category} of the character. It should be a symbol. The properties | 2556 @dfn{category} of the character. It should be a symbol. The properties |
2542 of the symbol serve as defaults for the properties of the character. | 2557 of the symbol serve as defaults for the properties of the character. |
2543 | 2558 |
2836 @r{Process text from point to @var{next-change}@dots{}} | 2851 @r{Process text from point to @var{next-change}@dots{}} |
2837 (goto-char next-change))) | 2852 (goto-char next-change))) |
2838 @end smallexample | 2853 @end smallexample |
2839 @end defun | 2854 @end defun |
2840 | 2855 |
2841 @defun next-single-property-change pos prop &optional object limit | |
2842 The function scans the text forward from position @var{pos} in the | |
2843 string or buffer @var{object} till it finds a change in the @var{prop} | |
2844 property, then returns the position of the change. In other words, it | |
2845 returns the position of the first character beyond @var{pos} whose | |
2846 @var{prop} property differs from that of the character just after | |
2847 @var{pos}. | |
2848 | |
2849 If @var{limit} is non-@code{nil}, then the scan ends at position | |
2850 @var{limit}. If there is no property change before that point, | |
2851 @code{next-single-property-change} returns @var{limit}. | |
2852 | |
2853 The value is @code{nil} if the property remains unchanged all the way to | |
2854 the end of @var{object} and @var{limit} is @code{nil}. If the value is | |
2855 non-@code{nil}, it is a position greater than or equal to @var{pos}; it | |
2856 equals @var{pos} only if @var{limit} equals @var{pos}. | |
2857 @end defun | |
2858 | |
2859 @defun previous-property-change pos &optional object limit | 2856 @defun previous-property-change pos &optional object limit |
2860 This is like @code{next-property-change}, but scans back from @var{pos} | 2857 This is like @code{next-property-change}, but scans back from @var{pos} |
2861 instead of forward. If the value is non-@code{nil}, it is a position | 2858 instead of forward. If the value is non-@code{nil}, it is a position |
2862 less than or equal to @var{pos}; it equals @var{pos} only if @var{limit} | 2859 less than or equal to @var{pos}; it equals @var{pos} only if @var{limit} |
2863 equals @var{pos}. | 2860 equals @var{pos}. |
2861 @end defun | |
2862 | |
2863 @defun next-single-property-change pos prop &optional object limit | |
2864 The function scans text for a change in the @var{prop} property, then | |
2865 returns the position of the change. The scan goes forward from | |
2866 position @var{pos} in the string or buffer @var{object}. In other | |
2867 words, this function returns the position of the first character | |
2868 beyond @var{pos} whose @var{prop} property differs from that of the | |
2869 character just after @var{pos}. | |
2870 | |
2871 If @var{limit} is non-@code{nil}, then the scan ends at position | |
2872 @var{limit}. If there is no property change before that point, | |
2873 @code{next-single-property-change} returns @var{limit}. | |
2874 | |
2875 The value is @code{nil} if the property remains unchanged all the way to | |
2876 the end of @var{object} and @var{limit} is @code{nil}. If the value is | |
2877 non-@code{nil}, it is a position greater than or equal to @var{pos}; it | |
2878 equals @var{pos} only if @var{limit} equals @var{pos}. | |
2864 @end defun | 2879 @end defun |
2865 | 2880 |
2866 @defun previous-single-property-change pos prop &optional object limit | 2881 @defun previous-single-property-change pos prop &optional object limit |
2867 This is like @code{next-single-property-change}, but scans back from | 2882 This is like @code{next-single-property-change}, but scans back from |
2868 @var{pos} instead of forward. If the value is non-@code{nil}, it is a | 2883 @var{pos} instead of forward. If the value is non-@code{nil}, it is a |