aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref
diff options
context:
space:
mode:
authorChong Yidong2013-12-20 15:12:04 +0800
committerChong Yidong2013-12-20 15:12:04 +0800
commitf5df4cebdb5e2edfddd8b8e16b1c237e2dd45855 (patch)
tree1adb7cc9be1a1ba3ba7d0e90f5c3b59a2a414b1f /doc/lispref
parentca65efcc2ea7f6876fee2f7d2d929dffa4093f96 (diff)
downloademacs-f5df4cebdb5e2edfddd8b8e16b1c237e2dd45855.tar.gz
emacs-f5df4cebdb5e2edfddd8b8e16b1c237e2dd45855.zip
Add/fix docs for add-face-text-property
* doc/lispref/text.texi (Changing Properties): Improve documentation for add-face-text-property. (Special Properties): Mention add-face-text-property. * src/textprop.c (Fadd_face_text_property): Doc fix. Rename `appendp' argument to `append'.
Diffstat (limited to 'doc/lispref')
-rw-r--r--doc/lispref/ChangeLog6
-rw-r--r--doc/lispref/text.texi43
2 files changed, 33 insertions, 16 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index af09f4371f9..3ae7e0040cc 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,3 +1,9 @@
12013-12-20 Chong Yidong <cyd@gnu.org>
2
3 * text.texi (Changing Properties): Improve documentation for
4 add-face-text-property.
5 (Special Properties): Mention add-face-text-property.
6
12013-12-18 Chong Yidong <cyd@gnu.org> 72013-12-18 Chong Yidong <cyd@gnu.org>
2 8
3 * customize.texi (Custom Themes): Document custom-known-themes 9 * customize.texi (Custom Themes): Document custom-known-themes
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index aa19338ddaf..b814d553296 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -2825,29 +2825,37 @@ Do not rely on the return value of this function.
2825@end defun 2825@end defun
2826 2826
2827@defun add-face-text-property start end face &optional appendp object 2827@defun add-face-text-property start end face &optional appendp object
2828@code{face} text attributes can be combined. If you want to make a 2828This function acts on the text between @var{start} and @var{end},
2829section both italic and green, you can either define a new face that 2829adding the face @var{face} to the @code{face} text property.
2830have those attributes, or you can add both these attributes separately 2830@var{face} should be a valid value for the @code{face} property
2831to text: 2831(@pxref{Special Properties}), such as a face name or an anonymous face
2832(@pxref{Faces}).
2833
2834If any text in the region already has a non-nil @code{face} property,
2835those face(s) are retained. This function sets the @code{face}
2836property to a list of faces, with @var{face} as the first element (by
2837default) and the pre-existing faces as the remaining elements. If the
2838optional argument @var{append} is non-@code{nil}, @var{face} is
2839appended to the end of the list instead. Note that in a face list,
2840the first occurring value for each attribute takes precedence.
2841
2842For example, the following code would assign a italicized green face
2843to the text between @var{start} and @var{end}:
2832 2844
2833@example 2845@example
2834(add-face-text-property @var{start} @var{end} 'italic) 2846(add-face-text-property @var{start} @var{end} 'italic)
2835(add-face-text-property @var{start} @var{end} '(:foreground "#00ff00")) 2847(add-face-text-property @var{start} @var{end} '(:foreground "red"))
2848(add-face-text-property @var{start} @var{end} '(:foreground "green"))
2836@end example 2849@end example
2837 2850
2838The attribute is (by default) prepended to the list of face 2851The optional argument @var{object}, if non-@code{nil}, specifies a
2839attributes, and the first attribute of the same type takes 2852buffer or string to act on, rather than the current buffer. If
2840precedence. So if you have two @code{:foreground} specifications, the 2853@var{object} is a string, then @var{start} and @var{end} are
2841first one will take effect. 2854zero-based indices into the string.
2842
2843If you pass in @var{appendp}, the attribute will be appended instead
2844of prepended, which means that it will have no effect if there is
2845already an attribute of the same type.
2846
2847@end defun 2855@end defun
2848 2856
2849 The easiest way to make a string with text properties 2857 The easiest way to make a string with text properties is with
2850is with @code{propertize}: 2858@code{propertize}:
2851 2859
2852@defun propertize string &rest properties 2860@defun propertize string &rest properties
2853This function returns a copy of @var{string} which has the text 2861This function returns a copy of @var{string} which has the text
@@ -3081,6 +3089,9 @@ Font Lock mode (@pxref{Font Lock Mode}) works in most buffers by
3081dynamically updating the @code{face} property of characters based on 3089dynamically updating the @code{face} property of characters based on
3082the context. 3090the context.
3083 3091
3092The @code{add-face-text-property} function provides a convenient way
3093to set this text property. @xref{Changing Properties}.
3094
3084@item font-lock-face 3095@item font-lock-face
3085@kindex font-lock-face @r{(text property)} 3096@kindex font-lock-face @r{(text property)}
3086This property specifies a value for the @code{face} property that Font 3097This property specifies a value for the @code{face} property that Font