emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 1c09423: Fix copying text properties by 'format'


From: Eli Zaretskii
Subject: [Emacs-diffs] master 1c09423: Fix copying text properties by 'format'
Date: Thu, 9 Jun 2016 13:52:23 +0000 (UTC)

branch: master
commit 1c09423880e1c48d6ba02a196430e829d1d87d57
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    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.
---
 doc/lispref/strings.texi |    3 ++-
 src/editfns.c            |   11 +++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index cf0505f..fc356af 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 f29fc51..a6d1354 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;
                }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]