docs: add tp-reactive-reset documentation section

Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-20 11:29:11 +00:00
parent dde320314f
commit 738ef6c34f
2 changed files with 56 additions and 2 deletions

View File

@ -1368,7 +1368,7 @@ Remove layer or group definition.
(tp-layer-reset)
```
Clear all layer and group definitions.
Clear all layer and group definitions, including all reactive dependencies and watchers.
**Examples:**
@ -1382,6 +1382,33 @@ Clear all layer and group definitions.
---
#### `tp-reactive-reset`
```elisp
(tp-reactive-reset)
```
Clear all reactive text property watchers and dependencies, without affecting layer definitions.
This is useful when you want to remove all reactive bindings but keep the layer definitions intact.
**Examples:**
```elisp
;; Define a reactive layer
(progn
(defvar my-reactive-color "red")
(tp-define-layer reactive-layer
:props (face (:foreground $my-reactive-color)))
;; Clear reactive bindings only
(tp-reactive-reset)
;; Layer still exists, but changing my-reactive-color no longer updates it
(tp-layer-props 'reactive-layer))
;; => (face (:foreground "red") tp-name reactive-layer)
```
---
### Property Layer Placement
#### `tp-put-layer` - Set Layer at Index

View File

@ -1365,7 +1365,7 @@ Emacs 的 `text-property-search-forward` 和 `text-property-search-backward` 的
(tp-layer-reset)
```
清除所有属性层和属性层组定义。
清除所有属性层和属性层组定义,包括所有响应式依赖和监听器
**示例:**
@ -1379,6 +1379,33 @@ Emacs 的 `text-property-search-forward` 和 `text-property-search-backward` 的
---
#### `tp-reactive-reset`
```elisp
(tp-reactive-reset)
```
清除所有响应式文本属性的监听器和依赖关系,但不影响层定义。
当你想要移除所有响应式绑定但保留层定义时,这个函数很有用。
**示例:**
```elisp
;; 定义一个响应式层
(progn
(defvar my-reactive-color "red")
(tp-define-layer reactive-layer
:props (face (:foreground $my-reactive-color)))
;; 仅清除响应式绑定
(tp-reactive-reset)
;; 层仍然存在,但改变 my-reactive-color 不再更新它
(tp-layer-props 'reactive-layer))
;; => (face (:foreground "red") tp-name reactive-layer)
```
---
### 属性层放置
#### `tp-put-layer` - 在指定位置设置属性层