aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2016-06-09 16:52:08 +0300
committerEli Zaretskii2016-06-09 16:52:08 +0300
commit1c09423880e1c48d6ba02a196430e829d1d87d57 (patch)
tree83147c9a43b4eede274fea481093e55e66fcb7d3 /src
parentfabb558250fca14a2684357a95225241253cdfda (diff)
downloademacs-1c09423880e1c48d6ba02a196430e829d1d87d57.tar.gz
emacs-1c09423880e1c48d6ba02a196430e829d1d87d57.zip
Fix copying text properties by 'format'
* src/editfns.c (styled_format): Fix copying text properties from the format specification to the produced string representation. (Bug#23730) (Fformat) Doc fix. * doc/lispref/strings.texi (Formatting Strings): Document that text properties from the format specifiers are also copied to the produced string.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/editfns.c b/src/editfns.c
index f29fc510a21..a6d13545711 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3883,6 +3883,9 @@ precision specifier says how many decimal places to show; if zero, the
3883decimal point itself is omitted. For %s and %S, the precision 3883decimal point itself is omitted. For %s and %S, the precision
3884specifier truncates the string to the given width. 3884specifier truncates the string to the given width.
3885 3885
3886Text properties, if any, are copied from the format-string to the
3887produced text.
3888
3886usage: (format STRING &rest OBJECTS) */) 3889usage: (format STRING &rest OBJECTS) */)
3887 (ptrdiff_t nargs, Lisp_Object *args) 3890 (ptrdiff_t nargs, Lisp_Object *args)
3888{ 3891{
@@ -4170,6 +4173,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4170 convbytes += padding; 4173 convbytes += padding;
4171 if (convbytes <= buf + bufsize - p) 4174 if (convbytes <= buf + bufsize - p)
4172 { 4175 {
4176 info[n].start = nchars;
4173 if (! minus_flag) 4177 if (! minus_flag)
4174 { 4178 {
4175 memset (p, ' ', padding); 4179 memset (p, ' ', padding);
@@ -4188,9 +4192,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4188 nbytes, 4192 nbytes,
4189 STRING_MULTIBYTE (args[n]), multibyte); 4193 STRING_MULTIBYTE (args[n]), multibyte);
4190 4194
4191 info[n].start = nchars;
4192 nchars += nchars_string; 4195 nchars += nchars_string;
4193 info[n].end = nchars;
4194 4196
4195 if (minus_flag) 4197 if (minus_flag)
4196 { 4198 {
@@ -4198,6 +4200,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4198 p += padding; 4200 p += padding;
4199 nchars += padding; 4201 nchars += padding;
4200 } 4202 }
4203 info[n].end = nchars;
4201 4204
4202 /* If this argument has text properties, record where 4205 /* If this argument has text properties, record where
4203 in the result string it appears. */ 4206 in the result string it appears. */
@@ -4415,6 +4418,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4415 exponent_bytes = src + sprintf_bytes - e; 4418 exponent_bytes = src + sprintf_bytes - e;
4416 } 4419 }
4417 4420
4421 info[n].start = nchars;
4418 if (! minus_flag) 4422 if (! minus_flag)
4419 { 4423 {
4420 memset (p, ' ', padding); 4424 memset (p, ' ', padding);
@@ -4437,9 +4441,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4437 memcpy (p, src, exponent_bytes); 4441 memcpy (p, src, exponent_bytes);
4438 p += exponent_bytes; 4442 p += exponent_bytes;
4439 4443
4440 info[n].start = nchars;
4441 nchars += leading_zeros + sprintf_bytes + trailing_zeros; 4444 nchars += leading_zeros + sprintf_bytes + trailing_zeros;
4442 info[n].end = nchars;
4443 4445
4444 if (minus_flag) 4446 if (minus_flag)
4445 { 4447 {
@@ -4447,6 +4449,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
4447 p += padding; 4449 p += padding;
4448 nchars += padding; 4450 nchars += padding;
4449 } 4451 }
4452 info[n].end = nchars;
4450 4453
4451 continue; 4454 continue;
4452 } 4455 }