diff options
| author | Jim Porter | 2025-05-28 09:55:58 -0700 |
|---|---|---|
| committer | Jim Porter | 2025-06-10 22:09:26 -0700 |
| commit | 4a3c8e6e1df44b187b7286747e363232e8b4e0ea (patch) | |
| tree | 415ffb4422e3457bb37ad8e15e892b74b448a405 /test | |
| parent | 7416595e2fc0ff676ef98a139328722ac9220ca0 (diff) | |
| download | emacs-4a3c8e6e1df44b187b7286747e363232e8b4e0ea.tar.gz emacs-4a3c8e6e1df44b187b7286747e363232e8b4e0ea.zip | |
Don't delete in-place when replacing a display property
When calling 'add-display-text-property' on a region of text that
already contains PROP, we first delete the old display specification
from the region. If the region's 'display' property is a list of
display specifications, we need to avoid destructively modifying the
list; other regions of text could be using the same list object. (For a
'display' property that's a vector or a single display spec, this
doesn't matter since we first make a new list in the code.)
In addition, be more careful when working with a display property like
((margin ...) ...). This is a single display specification, not a list
of display specs.
* lisp/emacs-lisp/subr-x.el (add-display-text-property): Don't delete
in-place for list values. Handle (margin ...) display specification
type correctly.
* test/lisp/emacs-lisp/subr-x-tests.el
(subr-x-test-add-display-text-property): Update test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/subr-x-tests.el | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/test/lisp/emacs-lisp/subr-x-tests.el b/test/lisp/emacs-lisp/subr-x-tests.el index f6675637fef..5ffbe64ae40 100644 --- a/test/lisp/emacs-lisp/subr-x-tests.el +++ b/test/lisp/emacs-lisp/subr-x-tests.el | |||
| @@ -696,18 +696,39 @@ | |||
| 696 | (insert "Foo bar zot gazonk") | 696 | (insert "Foo bar zot gazonk") |
| 697 | (add-display-text-property 4 8 'height 2.0) | 697 | (add-display-text-property 4 8 'height 2.0) |
| 698 | (add-display-text-property 2 12 'raise 0.5) | 698 | (add-display-text-property 2 12 'raise 0.5) |
| 699 | (should (equal (get-text-property 2 'display) '(raise 0.5))) | 699 | (add-display-text-property 6 10 'height 1.0) |
| 700 | (should (equal (get-text-property 5 'display) | 700 | (should (equal-including-properties |
| 701 | '((raise 0.5) (height 2.0)))) | 701 | (buffer-string) |
| 702 | (should (equal (get-text-property 9 'display) '(raise 0.5)))) | 702 | #("Foo bar zot gazonk" |
| 703 | 1 3 (display (raise 0.5)) | ||
| 704 | 3 5 (display ((raise 0.5) (height 2.0))) | ||
| 705 | 5 9 (display ((height 1.0) (raise 0.5))) | ||
| 706 | 9 11 (display (raise 0.5)))))) | ||
| 703 | (with-temp-buffer | 707 | (with-temp-buffer |
| 704 | (insert "Foo bar zot gazonk") | 708 | (insert "Foo bar zot gazonk") |
| 705 | (put-text-property 4 8 'display [(height 2.0)]) | 709 | (put-text-property 4 8 'display [(height 2.0)]) |
| 706 | (add-display-text-property 2 12 'raise 0.5) | 710 | (add-display-text-property 2 12 'raise 0.5) |
| 707 | (should (equal (get-text-property 2 'display) '(raise 0.5))) | 711 | (add-display-text-property 6 10 'height 1.0) |
| 708 | (should (equal (get-text-property 5 'display) | 712 | (should (equal-including-properties |
| 709 | [(raise 0.5) (height 2.0)])) | 713 | (buffer-string) |
| 710 | (should (equal (get-text-property 9 'display) '(raise 0.5)))) | 714 | #("Foo bar zot gazonk" |
| 715 | 1 3 (display (raise 0.5)) | ||
| 716 | 3 5 (display [(raise 0.5) (height 2.0)]) | ||
| 717 | 5 7 (display [(height 1.0) (raise 0.5)]) | ||
| 718 | 7 9 (display ((height 1.0) (raise 0.5))) | ||
| 719 | 9 11 (display (raise 0.5)))))) | ||
| 720 | (with-temp-buffer | ||
| 721 | (insert "Foo bar zot gazonk") | ||
| 722 | (add-display-text-property 4 8 '(margin nil) "Hi") | ||
| 723 | (add-display-text-property 2 12 'raise 0.5) | ||
| 724 | (add-display-text-property 6 10 '(margin nil) "Bye") | ||
| 725 | (should (equal-including-properties | ||
| 726 | (buffer-string) | ||
| 727 | #("Foo bar zot gazonk" | ||
| 728 | 1 3 (display (raise 0.5)) | ||
| 729 | 3 5 (display ((raise 0.5) ((margin nil) "Hi"))) | ||
| 730 | 5 9 (display (((margin nil) "Bye") (raise 0.5))) | ||
| 731 | 9 11 (display (raise 0.5)))))) | ||
| 711 | (with-temp-buffer | 732 | (with-temp-buffer |
| 712 | (should (equal-including-properties | 733 | (should (equal-including-properties |
| 713 | (let ((str (copy-sequence "some useless string"))) | 734 | (let ((str (copy-sequence "some useless string"))) |