aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2017-06-03 01:31:04 -0700
committerPaul Eggert2017-06-03 01:31:52 -0700
commit0147cdd4d96f1eaeef720ee0b89bddd27eaf4233 (patch)
tree30e3d37cad364e793b4a34d9c64d08f3244ad1fe
parent73635edb43e0e4a31cfe8af41ccb07c32836b148 (diff)
downloademacs-0147cdd4d96f1eaeef720ee0b89bddd27eaf4233.tar.gz
emacs-0147cdd4d96f1eaeef720ee0b89bddd27eaf4233.zip
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.
-rw-r--r--doc/lispref/strings.texi7
-rw-r--r--src/editfns.c7
2 files changed, 8 insertions, 6 deletions
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.
965decimal number immediately after the initial @samp{%}, followed by a 965decimal number immediately after the initial @samp{%}, followed by a
966literal dollar sign @samp{$}. It causes the format specification to 966literal dollar sign @samp{$}. It causes the format specification to
967convert the argument with the given number instead of the next 967convert the argument with the given number instead of the next
968argument. Field numbers start at 1. A format can contain either 968argument. Field numbers start at 1. A field number should differ
969numbered or unnumbered format specifications but not both, except that 969from the other field numbers in the same format. A format can contain
970@samp{%%} can be mixed with numbered specifications. 970either numbered or unnumbered format specifications but not both,
971except that @samp{%%} can be mixed with numbered specifications.
971 972
972@example 973@example
973(format "%2$s, %3$s, %%, %1$s" "x" "y" "z") 974(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
3901followed by [0-9]+. 3901followed by [0-9]+.
3902 3902
3903If a %-sequence is numbered with a field with positive value N, the 3903If a %-sequence is numbered with a field with positive value N, the
3904Nth argument is substituted instead of the next one. A format can 3904Nth argument is substituted instead of the next one. A field number
3905contain either numbered or unnumbered %-sequences but not both, except 3905should differ from the other field numbers in the same format. A
3906that %% can be mixed with numbered %-sequences. 3906format can contain either numbered or unnumbered %-sequences but not
3907both, except that %% can be mixed with numbered %-sequences.
3907 3908
3908The + flag character inserts a + before any positive number, while a 3909The + flag character inserts a + before any positive number, while a
3909space inserts a space before any positive number; these flags only 3910space inserts a space before any positive number; these flags only