(format "The name of this buffer is ‘%s’." (buffer-name))
@result{} "The name of this buffer is ‘strings.texi’."
-(format "The buffer object prints as ‘%s’." (current-buffer))
+(format "The buffer object prints as %qs." (current-buffer))
@result{} "The buffer object prints as ‘strings.texi’."
(format "The octal value of %d is %o,
If both @samp{-} and @samp{0} are present, the @samp{0} flag is
ignored.
+ The flag @samp{q} quotes the printed representation as per the
+variable @samp{text-quoting-style} described below.
+
@example
@group
(format "%06d is padded on the left with zeros" 123)
@result{} "000123 is padded on the left with zeros"
-(format "%-6d is padded on the right" 123)
- @result{} "123 is padded on the right"
+(format "%q-6d is padded on the right" 123)
+ @result{} "‘123 ’ is padded on the right"
(format "The word ‘%-7s’ actually has %d letters in it."
"foo" (length "foo"))
create a string, and may return its first argument if the argument
already has the correct value.
++++
+** New ‘format’ flag ‘q’
+The new ‘q’ flag causes ‘format’ to quote the output representation as
+per the value of ‘text quoting-style’. E.g., (format "%qs failed"
+"foo") might return "‘foo’ failed".
+
+++
** substitute-command-keys now replaces quotes.
That is, it converts documentation strings' quoting style as per the
-value of ‘text-quoting-style’ as described above. Doc strings in
-source code can use either curved quotes or grave accent and
-apostrophe. As before, isolated apostrophes and characters preceded
-by \= are output as-is.
+value of ‘text-quoting-style’. Doc strings in source code can use
+either curved quotes or grave accent and apostrophe. As before,
+isolated apostrophes and characters preceded by \= are output as-is.
+++
** The character classes [:alpha:] and [:alnum:] in regular expressions
%<flags><width><precision>character
-where flags is [+ #-0]+, width is [0-9]+, and precision is .[0-9]+
+where flags is [+ #-0q]+, width is [0-9]+, and precision is .[0-9]+
The + flag character inserts a + before any positive number, while a
space inserts a space before any positive number; these flags only
for %e, %f, and %g, it causes a decimal point to be included even if
the precision is zero.
+The q flag means to quote the printed representation as per
+‘text-quoting-style’. E.g., "%qs" is equivalent to "‘%s’".
+
The width specifier supplies a lower limit for the length of the
printed representation. The padding, if any, normally goes on the
left, but it goes on the right if the - flag is present. The padding
digits to print after the '.' for floats, or the max.
number of chars to print from a string. */
- bool minus_flag = 0;
- bool plus_flag = 0;
- bool space_flag = 0;
- bool sharp_flag = 0;
- bool zero_flag = 0;
+ bool minus_flag = false;
+ bool plus_flag = false;
+ bool space_flag = false;
+ bool sharp_flag = false;
+ bool zero_flag = false;
+ bool quote_flag = false;
ptrdiff_t field_width;
bool precision_given;
uintmax_t precision = UINTMAX_MAX;
{
switch (*++format)
{
- case '-': minus_flag = 1; continue;
- case '+': plus_flag = 1; continue;
- case ' ': space_flag = 1; continue;
- case '#': sharp_flag = 1; continue;
- case '0': zero_flag = 1; continue;
+ case '-': minus_flag = true; continue;
+ case '+': plus_flag = true; continue;
+ case ' ': space_flag = true; continue;
+ case '#': sharp_flag = true; continue;
+ case '0': zero_flag = true; continue;
+ case 'q': quote_flag = true; continue;
}
break;
}
if (convbytes && multibyte && ! STRING_MULTIBYTE (args[n]))
convbytes = count_size_as_multibyte (SDATA (args[n]), nbytes);
+ if (quote_flag)
+ {
+ convbytes += 2;
+ if (quoting_style == CURVE_QUOTING_STYLE)
+ {
+ if (!multibyte)
+ {
+ multibyte = true;
+ goto retry;
+ }
+ convbytes += 4;
+ }
+ }
+
padding = width < field_width ? field_width - width : 0;
if (max_bufsize - padding <= convbytes)
convbytes += padding;
if (convbytes <= buf + bufsize - p)
{
+
+ if (quote_flag)
+ {
+ switch (quoting_style)
+ {
+ case CURVE_QUOTING_STYLE:
+ memcpy (p, uLSQM, 3);
+ p += 3;
+ break;
+
+ case GRAVE_QUOTING_STYLE:
+ *p++ = '`';
+ break;
+
+ case STRAIGHT_QUOTING_STYLE:
+ *p++ = '\'';
+ break;
+ }
+ nchars++;
+ }
+
if (! minus_flag)
{
memset (p, ' ', padding);
nchars += padding;
}
+ if (quote_flag)
+ {
+ switch (quoting_style)
+ {
+ case CURVE_QUOTING_STYLE:
+ memcpy (p, uRSQM, 3);
+ p += 3;
+ break;
+
+ default:
+ *p++ = '\'';
+ break;
+ }
+ nchars++;
+ }
+
/* If this argument has text properties, record where
in the result string it appears. */
if (string_intervals (args[n]))