emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 70a2eb4a0b3: Fix 'add-display-text-property' when OBJECT is non


From: Eli Zaretskii
Subject: emacs-29 70a2eb4a0b3: Fix 'add-display-text-property' when OBJECT is non-nil
Date: Tue, 6 Dec 2022 07:42:39 -0500 (EST)

branch: emacs-29
commit 70a2eb4a0b315c3e66ab89508c9c62ca8b84ef29
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Fix 'add-display-text-property' when OBJECT is non-nil
    
    * lisp/emacs-lisp/subr-x.el (add-display-text-property): Fix the
    case where OBJECT is not nil.  (Bug#59857)
    
    * test/lisp/emacs-lisp/subr-x-tests.el
    (subr-x-test-add-display-text-property): Add test for this case.
---
 lisp/emacs-lisp/subr-x.el            |  5 +++--
 test/lisp/emacs-lisp/subr-x-tests.el | 11 ++++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/subr-x.el b/lisp/emacs-lisp/subr-x.el
index 18087bc937f..0486baba83c 100644
--- a/lisp/emacs-lisp/subr-x.el
+++ b/lisp/emacs-lisp/subr-x.el
@@ -370,7 +370,8 @@ this defaults to the current buffer."
                                                    (min end (point-max)))))
       (if (not (setq disp (get-text-property sub-start 'display object)))
           ;; No old properties in this range.
-          (put-text-property sub-start sub-end 'display (list prop value))
+          (put-text-property sub-start sub-end 'display (list prop value)
+                             object)
         ;; We have old properties.
         (let ((vector nil))
           ;; Make disp into a list.
@@ -390,7 +391,7 @@ this defaults to the current buffer."
           (when vector
             (setq disp (seq-into disp 'vector)))
           ;; Finally update the range.
-          (put-text-property sub-start sub-end 'display disp)))
+          (put-text-property sub-start sub-end 'display disp object)))
       (setq sub-start sub-end))))
 
 ;;;###autoload
diff --git a/test/lisp/emacs-lisp/subr-x-tests.el 
b/test/lisp/emacs-lisp/subr-x-tests.el
index 7a3efe9db62..e80d2e17e8d 100644
--- a/test/lisp/emacs-lisp/subr-x-tests.el
+++ b/test/lisp/emacs-lisp/subr-x-tests.el
@@ -707,7 +707,16 @@
     (should (equal (get-text-property 2 'display) '(raise 0.5)))
     (should (equal (get-text-property 5 'display)
                    [(raise 0.5) (height 2.0)]))
-    (should (equal (get-text-property 9 'display) '(raise 0.5)))))
+    (should (equal (get-text-property 9 'display) '(raise 0.5))))
+  (with-temp-buffer
+    (should (equal (let ((str "some useless string"))
+                     (add-display-text-property 4 8 'height 2.0 str)
+                     (add-display-text-property 2 12 'raise 0.5 str)
+                     str)
+                   #("some useless string"
+                     2 4 (display (raise 0.5))
+                     4 8 (display ((raise 0.5) (height 2.0)))
+                     8 12 (display (raise 0.5)))))))
 
 (ert-deftest subr-x-named-let ()
   (let ((funs ()))



reply via email to

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