aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorPaul Eggert2017-06-01 16:03:12 -0700
committerPaul Eggert2017-06-01 16:06:38 -0700
commit8de2581a64dac3785fc3877f7cd87c4164fd2936 (patch)
treeaf8885c43a57dee86b17c05118a78d6f1d0361ac /doc
parent178d0cb5f530e6d7eb36eb9987ff405c854ccdb3 (diff)
downloademacs-8de2581a64dac3785fc3877f7cd87c4164fd2936.tar.gz
emacs-8de2581a64dac3785fc3877f7cd87c4164fd2936.zip
Limit format fields to more POSIX-like spec
* doc/lispref/strings.texi (Formatting Strings): Don’t allow mixing numbered with unnumbered format specs. * src/editfns.c (styled_format): Don’t bother checking for field 0, since it doesn’t crash and the behavior is not specified. * test/src/editfns-tests.el (format-with-field): Adjust tests to match current doc. Add more tests for out-of-range fields.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/strings.texi13
1 files changed, 5 insertions, 8 deletions
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index 4d33e55b018..e80e778bece 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -965,16 +965,13 @@ 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. Argument 1 is the argument just after the format. 968argument. Field numbers start at 1. A format can contain either
969 969numbered or unnumbered format specifications but not both, except that
970 You can mix specifications with and without field numbers. A 970@samp{%%} can be mixed with numbered specifications.
971specification without a field number that follows a specification with
972a field number will convert the argument after the one specified by
973the field number:
974 971
975@example 972@example
976(format "Argument %2$s, then %s, then %1$s" "x" "y" "z") 973(format "%2$s, %3$s, %%, %1$s" "x" "y" "z")
977 @result{} "Argument y, then z, then x" 974 @result{} "y, z, %, x"
978@end example 975@end example
979 976
980@cindex flags in format specifications 977@cindex flags in format specifications