diff options
| author | Eli Zaretskii <eliz@gnu.org> | 2016-06-09 16:52:08 +0300 |
|---|---|---|
| committer | Eli Zaretskii <eliz@gnu.org> | 2016-06-09 16:52:08 +0300 |
| commit | 1c09423880e1c48d6ba02a196430e829d1d87d57 (patch) | |
| tree | 83147c9a43b4eede274fea481093e55e66fcb7d3 | |
| parent | fabb558250fca14a2684357a95225241253cdfda (diff) | |
| download | emacs-1c09423880e1c48d6ba02a196430e829d1d87d57.tar.gz | |
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.
| -rw-r--r-- | doc/lispref/strings.texi | 3 | ||||
| -rw-r--r-- | src/editfns.c | 11 |
2 files changed, 9 insertions, 5 deletions
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi index cf0505f4467..fc356af51ba 100644 --- a/doc/lispref/strings.texi +++ b/doc/lispref/strings.texi @@ -833,7 +833,8 @@ arguments @var{objects} are the computed values to be formatted. The characters in @var{string}, other than the format specifications, are copied directly into the output, including their text properties, -if any. +if any. Any text properties of the format specifications are copied +to the produced string representations of the argument @var{objects}. @end defun @defun format-message string &rest objects 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 decimal point itself is omitted. For %s and %S, the precision specifier truncates the string to the given width. +Text properties, if any, are copied from the format-string to the +produced text. + usage: (format STRING &rest OBJECTS) */) (ptrdiff_t nargs, Lisp_Object *args) { @@ -4170,6 +4173,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) convbytes += padding; if (convbytes <= buf + bufsize - p) { + info[n].start = nchars; if (! minus_flag) { memset (p, ' ', padding); @@ -4188,9 +4192,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) nbytes, STRING_MULTIBYTE (args[n]), multibyte); - info[n].start = nchars; nchars += nchars_string; - info[n].end = nchars; if (minus_flag) { @@ -4198,6 +4200,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) p += padding; nchars += padding; } + info[n].end = nchars; /* If this argument has text properties, record where in the result string it appears. */ @@ -4415,6 +4418,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) exponent_bytes = src + sprintf_bytes - e; } + info[n].start = nchars; if (! minus_flag) { memset (p, ' ', padding); @@ -4437,9 +4441,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) memcpy (p, src, exponent_bytes); p += exponent_bytes; - info[n].start = nchars; nchars += leading_zeros + sprintf_bytes + trailing_zeros; - info[n].end = nchars; if (minus_flag) { @@ -4447,6 +4449,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) p += padding; nchars += padding; } + info[n].end = nchars; continue; } |
