diff options
Diffstat (limited to 'doc/lispref')
| -rw-r--r-- | doc/lispref/ChangeLog | 6 | ||||
| -rw-r--r-- | doc/lispref/text.texi | 43 |
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 @@ | |||
| 1 | 2013-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 | |||
| 1 | 2013-12-18 Chong Yidong <cyd@gnu.org> | 7 | 2013-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 | 2828 | This function acts on the text between @var{start} and @var{end}, |
| 2829 | section both italic and green, you can either define a new face that | 2829 | adding the face @var{face} to the @code{face} text property. |
| 2830 | have those attributes, or you can add both these attributes separately | 2830 | @var{face} should be a valid value for the @code{face} property |
| 2831 | to text: | 2831 | (@pxref{Special Properties}), such as a face name or an anonymous face |
| 2832 | (@pxref{Faces}). | ||
| 2833 | |||
| 2834 | If any text in the region already has a non-nil @code{face} property, | ||
| 2835 | those face(s) are retained. This function sets the @code{face} | ||
| 2836 | property to a list of faces, with @var{face} as the first element (by | ||
| 2837 | default) and the pre-existing faces as the remaining elements. If the | ||
| 2838 | optional argument @var{append} is non-@code{nil}, @var{face} is | ||
| 2839 | appended to the end of the list instead. Note that in a face list, | ||
| 2840 | the first occurring value for each attribute takes precedence. | ||
| 2841 | |||
| 2842 | For example, the following code would assign a italicized green face | ||
| 2843 | to 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 | ||
| 2838 | The attribute is (by default) prepended to the list of face | 2851 | The optional argument @var{object}, if non-@code{nil}, specifies a |
| 2839 | attributes, and the first attribute of the same type takes | 2852 | buffer or string to act on, rather than the current buffer. If |
| 2840 | precedence. So if you have two @code{:foreground} specifications, the | 2853 | @var{object} is a string, then @var{start} and @var{end} are |
| 2841 | first one will take effect. | 2854 | zero-based indices into the string. |
| 2842 | |||
| 2843 | If you pass in @var{appendp}, the attribute will be appended instead | ||
| 2844 | of prepended, which means that it will have no effect if there is | ||
| 2845 | already 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 |
| 2850 | is with @code{propertize}: | 2858 | @code{propertize}: |
| 2851 | 2859 | ||
| 2852 | @defun propertize string &rest properties | 2860 | @defun propertize string &rest properties |
| 2853 | This function returns a copy of @var{string} which has the text | 2861 | This 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 | |||
| 3081 | dynamically updating the @code{face} property of characters based on | 3089 | dynamically updating the @code{face} property of characters based on |
| 3082 | the context. | 3090 | the context. |
| 3083 | 3091 | ||
| 3092 | The @code{add-face-text-property} function provides a convenient way | ||
| 3093 | to 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)} |
| 3086 | This property specifies a value for the @code{face} property that Font | 3097 | This property specifies a value for the @code{face} property that Font |