[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 0a2aedf: Minor tweaks of copying text properties wh
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] master 0a2aedf: Minor tweaks of copying text properties when padding strings |
Date: |
Sat, 9 Jul 2016 08:02:15 +0000 (UTC) |
branch: master
commit 0a2aedfe6d650e825a50f25f972bac20d669f5cb
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Minor tweaks of copying text properties when padding strings
* src/editfns.c (styled_format): Don't include padding on the left
in the properties at the beginning of the string. (Bug#23897)
* test/src/editfns-tests.el (format-properties): Add tests for
faces when the string is padded on the left or on the right.
---
src/editfns.c | 2 +-
test/src/editfns-tests.el | 28 ++++++++++++++++++++++++++--
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/src/editfns.c b/src/editfns.c
index 73f0244..4c8336b 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -4175,13 +4175,13 @@ 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);
p += padding;
nchars += padding;
}
+ info[n].start = nchars;
if (p > buf
&& multibyte
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el
index 62d7bc4..507ceef 100644
--- a/test/src/editfns-tests.el
+++ b/test/src/editfns-tests.el
@@ -54,7 +54,7 @@
;; Bug #23859
(should (ert-equal-including-properties
(format "%4s" (propertize "hi" 'face 'bold))
- #(" hi" 0 4 (face bold))))
+ #(" hi" 2 4 (face bold))))
;; Bug #23897
(should (ert-equal-including-properties
@@ -64,4 +64,28 @@
(format "%s" (concat (propertize "01" 'face 'bold)
(propertize "23" 'face 'underline)
"45"))
- #("012345" 0 2 (face bold) 2 4 (face underline)))))
+ #("012345" 0 2 (face bold) 2 4 (face underline))))
+ ;; The last property range is extended to include padding on the
+ ;; right, but the first range is not extended to the left to include
+ ;; padding on the left!
+ (should (ert-equal-including-properties
+ (format "%12s" (concat (propertize "01234" 'face 'bold) "56789"))
+ #(" 0123456789" 2 7 (face bold))))
+ (should (ert-equal-including-properties
+ (format "%-12s" (concat (propertize "01234" 'face 'bold) "56789"))
+ #("0123456789 " 0 5 (face bold))))
+ (should (ert-equal-including-properties
+ (format "%10s" (concat (propertize "01" 'face 'bold)
+ (propertize "23" 'face 'underline)
+ "45"))
+ #(" 012345" 4 6 (face bold) 6 8 (face underline))))
+ (should (ert-equal-including-properties
+ (format "%-10s" (concat (propertize "01" 'face 'bold)
+ (propertize "23" 'face 'underline)
+ "45"))
+ #("012345 " 0 2 (face bold) 2 4 (face underline))))
+ (should (ert-equal-including-properties
+ (format "%-10s" (concat (propertize "01" 'face 'bold)
+ (propertize "23" 'face 'underline)
+ (propertize "45" 'face 'italic)))
+ #("012345 " 0 2 (face bold) 2 4 (face underline) 4 10 (face
italic)))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 0a2aedf: Minor tweaks of copying text properties when padding strings,
Eli Zaretskii <=