From: Paul Eggert Date: Sat, 3 Jun 2017 08:31:04 +0000 (-0700) Subject: Document uniqueness limitation of ‘format’ X-Git-Tag: emacs-26.0.90~521^2~177 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0147cdd4d96f1eaeef720ee0b89bddd27eaf4233;p=emacs.git Document uniqueness limitation of ‘format’ * doc/lispref/strings.texi (Formatting Strings): * src/editfns.c (Fformat): Document that field numbers should be unique within a format. --- diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi index e80e778bece..f365c80493d 100644 --- a/doc/lispref/strings.texi +++ b/doc/lispref/strings.texi @@ -965,9 +965,10 @@ extra values to be formatted are ignored. decimal number immediately after the initial @samp{%}, followed by a literal dollar sign @samp{$}. It causes the format specification to convert the argument with the given number instead of the next -argument. Field numbers start at 1. A format can contain either -numbered or unnumbered format specifications but not both, except that -@samp{%%} can be mixed with numbered specifications. +argument. Field numbers start at 1. A field number should differ +from the other field numbers in the same format. A format can contain +either numbered or unnumbered format specifications but not both, +except that @samp{%%} can be mixed with numbered specifications. @example (format "%2$s, %3$s, %%, %1$s" "x" "y" "z") diff --git a/src/editfns.c b/src/editfns.c index 29af25aab4f..a5088b0a1fd 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3901,9 +3901,10 @@ where field is [0-9]+ followed by a literal dollar "$", flags is followed by [0-9]+. If a %-sequence is numbered with a field with positive value N, the -Nth argument is substituted instead of the next one. A format can -contain either numbered or unnumbered %-sequences but not both, except -that %% can be mixed with numbered %-sequences. +Nth argument is substituted instead of the next one. A field number +should differ from the other field numbers in the same format. A +format can contain either numbered or unnumbered %-sequences but not +both, except that %% can be mixed with numbered %-sequences. The + flag character inserts a + before any positive number, while a space inserts a space before any positive number; these flags only