diff options
Diffstat (limited to 'lispref/strings.texi')
| -rw-r--r-- | lispref/strings.texi | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lispref/strings.texi b/lispref/strings.texi index 46c01982f32..17a62b546b4 100644 --- a/lispref/strings.texi +++ b/lispref/strings.texi | |||
| @@ -700,8 +700,8 @@ in the copy with encodings of the corresponding @var{objects}. The | |||
| 700 | arguments @var{objects} are the computed values to be formatted. | 700 | arguments @var{objects} are the computed values to be formatted. |
| 701 | 701 | ||
| 702 | The characters in @var{string}, other than the format specifications, | 702 | The characters in @var{string}, other than the format specifications, |
| 703 | are copied directly into the output; if they have text properties, | 703 | are copied directly into the output, including their text properties, |
| 704 | these are copied into the output also. | 704 | if any. |
| 705 | @end defun | 705 | @end defun |
| 706 | 706 | ||
| 707 | @cindex @samp{%} in format | 707 | @cindex @samp{%} in format |
| @@ -719,6 +719,17 @@ For example: | |||
| 719 | @end group | 719 | @end group |
| 720 | @end example | 720 | @end example |
| 721 | 721 | ||
| 722 | Since @code{format} interprets @samp{%} characters as format | ||
| 723 | specifications, you should @emph{never} pass an arbitrary string as | ||
| 724 | the first argument. This is particularly true when the string is | ||
| 725 | generated by some Lisp code. Unless the string is @emph{known} to | ||
| 726 | never include any @samp{%} characters, pass @code{"%s"}, described | ||
| 727 | below, as the first argument, and the string as the second, like this: | ||
| 728 | |||
| 729 | @example | ||
| 730 | (format "%s" @var{arbitrary-string}) | ||
| 731 | @end example | ||
| 732 | |||
| 722 | If @var{string} contains more than one format specification, the | 733 | If @var{string} contains more than one format specification, the |
| 723 | format specifications correspond to successive values from | 734 | format specifications correspond to successive values from |
| 724 | @var{objects}. Thus, the first format specification in @var{string} | 735 | @var{objects}. Thus, the first format specification in @var{string} |