Make two doctest assertions property-order-insensitive for Emacs 28
Emacs 28 stores/prints text-property plists in a different order than 29+; the S-mystyle and L-paramgroup assertions compared whole prin1 strings and failed on 28.1 only. Compare per property instead (face, tp-name, tp-layers — the stack order inside tp-layers is stable), and note the version-dependent print order beside both README examples. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
ca405f977d
commit
b454cbb061
@ -597,6 +597,8 @@ LAYER-NAME can be a symbol representing a layer defined by `define-tp` or a grou
|
|||||||
:data '((my-color . "blue")))
|
:data '((my-color . "blue")))
|
||||||
(tp-set " " 'my-style)
|
(tp-set " " 'my-style)
|
||||||
;; => #(" " 0 1 (face (:foreground "blue") tp-name my-style))
|
;; => #(" " 0 1 (face (:foreground "blue") tp-name my-style))
|
||||||
|
;; (the printed ORDER of properties may differ across Emacs
|
||||||
|
;; versions; the values are identical)
|
||||||
|
|
||||||
;; Merge multiple faces in a single call (duplicate properties auto-merged)
|
;; Merge multiple faces in a single call (duplicate properties auto-merged)
|
||||||
(tp-set "emacs"
|
(tp-set "emacs"
|
||||||
@ -1827,6 +1829,8 @@ The first layer in the definition is the top layer (visible by default).
|
|||||||
;; => #("emacs" 0 5 (face (:foreground "orange") tp-name tp-test-l1
|
;; => #("emacs" 0 5 (face (:foreground "orange") tp-name tp-test-l1
|
||||||
;; tp-layers ((face (:foreground "red") tp-name tp-test-l2)
|
;; tp-layers ((face (:foreground "red") tp-name tp-test-l2)
|
||||||
;; (face (:background "green") tp-name tp-test-l3))))
|
;; (face (:background "green") tp-name tp-test-l3))))
|
||||||
|
;; (top-level property print order may differ across Emacs versions;
|
||||||
|
;; the tp-layers stack order itself is stable)
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@ -587,6 +587,7 @@ LAYER-NAME 可以是通过 `define-tp` 定义的自定义文本属性名称或
|
|||||||
:data '((my-color . "blue")))
|
:data '((my-color . "blue")))
|
||||||
(tp-set " " 'my-style)
|
(tp-set " " 'my-style)
|
||||||
;; => #(" " 0 1 (face (:foreground "blue") tp-name my-style))
|
;; => #(" " 0 1 (face (:foreground "blue") tp-name my-style))
|
||||||
|
;; (属性的打印顺序在不同 Emacs 版本间可能不同,值本身一致)
|
||||||
|
|
||||||
;; 单次调用中合并多个 face(重复属性自动合并)
|
;; 单次调用中合并多个 face(重复属性自动合并)
|
||||||
(tp-set "emacs"
|
(tp-set "emacs"
|
||||||
@ -1813,6 +1814,8 @@ Emacs 的 `text-property-search-forward` 和 `text-property-search-backward` 的
|
|||||||
;; => #("emacs" 0 5 (face (:foreground "orange") tp-name tp-test-l1
|
;; => #("emacs" 0 5 (face (:foreground "orange") tp-name tp-test-l1
|
||||||
;; tp-layers ((face (:foreground "red") tp-name tp-test-l2)
|
;; tp-layers ((face (:foreground "red") tp-name tp-test-l2)
|
||||||
;; (face (:background "green") tp-name tp-test-l3))))
|
;; (face (:background "green") tp-name tp-test-l3))))
|
||||||
|
;; (顶层属性的打印顺序在不同 Emacs 版本间可能不同,
|
||||||
|
;; tp-layers 栈内顺序本身是稳定的)
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@ -98,12 +98,15 @@
|
|||||||
(tp-layer-props 'full-name-layer)))
|
(tp-layer-props 'full-name-layer)))
|
||||||
|
|
||||||
;; ---- tp-set my-style ----
|
;; ---- tp-set my-style ----
|
||||||
(chk-str "S-mystyle" "#(\" \" 0 1 (face (:foreground \"blue\") tp-name my-style))"
|
;; Compared per property: the ORDER properties print in varies across
|
||||||
(progn
|
;; Emacs versions (28 vs 29+), the values do not.
|
||||||
(define-tp my-style ()
|
(chk "S-mystyle" '((:foreground "blue") my-style)
|
||||||
:props '(face (:foreground $my-color))
|
(progn
|
||||||
:data '((my-color . "blue")))
|
(define-tp my-style ()
|
||||||
(tp-set " " 'my-style)))
|
:props '(face (:foreground $my-color))
|
||||||
|
:data '((my-color . "blue")))
|
||||||
|
(let ((r (tp-set " " 'my-style)))
|
||||||
|
(list (tp-at 0 'face r) (tp-at 0 'tp-name r)))))
|
||||||
|
|
||||||
;; ---- tp-member ----
|
;; ---- tp-member ----
|
||||||
(chk "M-member-str" '((face nil) nil)
|
(chk "M-member-str" '((face nil) nil)
|
||||||
@ -232,21 +235,29 @@
|
|||||||
'("first-quarter" . (display "🌓"))
|
'("first-quarter" . (display "🌓"))
|
||||||
'("full" . (display "🌕")))
|
'("full" . (display "🌕")))
|
||||||
(tp-layer-props 'moon-phases-full)))
|
(tp-layer-props 'moon-phases-full)))
|
||||||
(chk-str "L-paramgroup"
|
;; Compared per property (print order of the top-level plist varies
|
||||||
"#(\"emacs\" 0 5 (face (:foreground \"orange\") tp-name tp-test-l1 tp-layers ((face (:foreground \"red\") tp-name tp-test-l2) (face (:background \"green\") tp-name tp-test-l3))))"
|
;; across Emacs versions; the tp-layers stack order itself is stable).
|
||||||
(progn
|
(chk "L-paramgroup"
|
||||||
(tp-layer-reset)
|
'((:foreground "orange")
|
||||||
(define-tp tp-test-l1 (color)
|
tp-test-l1
|
||||||
`(face (:foreground ,color)))
|
((face (:foreground "red") tp-name tp-test-l2)
|
||||||
(define-tp tp-test-l2 (color)
|
(face (:background "green") tp-name tp-test-l3)))
|
||||||
`(face (:foreground ,color)))
|
(progn
|
||||||
(define-tp tp-test-l3 ()
|
(tp-layer-reset)
|
||||||
'(face (:background "green")))
|
(define-tp tp-test-l1 (color)
|
||||||
(define-tps tp-test-group1 (color)
|
`(face (:foreground ,color)))
|
||||||
`(tp-test-l1 ,color)
|
(define-tp tp-test-l2 (color)
|
||||||
'(tp-test-l2 "red")
|
`(face (:foreground ,color)))
|
||||||
'tp-test-l3)
|
(define-tp tp-test-l3 ()
|
||||||
(tp-set "emacs" 'tp-test-group1 "orange")))
|
'(face (:background "green")))
|
||||||
|
(define-tps tp-test-group1 (color)
|
||||||
|
`(tp-test-l1 ,color)
|
||||||
|
'(tp-test-l2 "red")
|
||||||
|
'tp-test-l3)
|
||||||
|
(let ((r (tp-set "emacs" 'tp-test-group1 "orange")))
|
||||||
|
(list (tp-at 0 'face r)
|
||||||
|
(tp-at 0 'tp-name r)
|
||||||
|
(tp-at 0 'tp-layers r)))))
|
||||||
(chk "L-props" '((face bold help-echo "tip")
|
(chk "L-props" '((face bold help-echo "tip")
|
||||||
(face bold help-echo "tip" tp-name my-layer))
|
(face bold help-echo "tip" tp-name my-layer))
|
||||||
(progn
|
(progn
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user