- tp-set: props override embedded text properties in tp-text value
- tp-add: props are merged with embedded text properties
- tp-reset: embedded properties are ignored, only props used
Added merge-mode parameter to tp--handle-tp-text-property:
- :override - props take precedence (tp-set)
- :merge - embedded props merged with props (tp-add)
- :reset - embedded props ignored (tp-reset)
Updated tests to reflect correct semantics.
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
- Add tp--merge-string-props-into-plist to merge embedded properties
from tp-text value into props plist with proper face merging
- Simplify tp--handle-tp-text-property to use the new merge function
and return merged props directly
- Simplify tp-set, tp-reset, tp-add by removing marker-based handling
- Fix tp-add to avoid duplicate face merging for strings with tp-text
- Remove unused tp--apply-string-props-to-region and
tp--remove-internal-markers functions
- Update tests to match the simplified implementation
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
Use tp--string-has-properties-p helper function instead of checking
only position 0. This properly detects text properties that start at
non-zero positions in the string.
Added test tp-test-tp-text-with-properties-starting-at-nonzero to
verify this fix.
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
- Modify tp--handle-tp-text-property to detect and preserve embedded text
properties in tp-text values for both strings and buffers
- Add tp--apply-string-props-to-region helper to apply string properties
- Update tp-set, tp-reset, tp-add to preserve embedded tp-text properties
by using put-text-property instead of set-text-properties when needed
- Update tp--replace-reactive-text-in-buffer to preserve embedded properties
- Add tests for tp-text with embedded text properties
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
The bug occurred because tp--parse-args was incorrectly omitting nil values
from the property list, producing (face) instead of (face nil).
Fixed the same bug pattern in:
- tp--parse-args (used by tp-set, tp-reset, tp-add)
- tp-add-to-layers
- tp-add-to-all-layers
Added 6 new regression tests for nil property values.
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
When a define-tp layer returns a plist containing other custom layer names,
those are now recursively expanded to their built-in text properties.
This fixes the issue where tp-button using tp-palette internally would
leave tp-palette as a text property instead of resolving it to the
actual face properties.
Changes:
- Added tp--plist-has-layer-key-p helper function
- Updated tp--expand-layer-in-plist to recursively expand layer props
- Updated tp-layer-props to expand nested layers in returned plist
- Updated tp-layer-props-with-arg to expand nested layers in returned plist
- Added 3 tests for nested layer resolution
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
When using tp-set on a string with tp-text, the returned string now
contains the tp-text value instead of the original string content.
For example, (tp-set "2" 'tp-text "6") now returns "6" with properties.
- Updated tp--handle-tp-text-property to return new string object
- Updated tp-set, tp-reset, tp-add to handle the new return format
- Added test for string object tp-text replacement
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
- Modified tp--resolve-props to not add tp-name for non-reactive plists
- Added tp-text property support for reactive text content
- Created tp--handle-tp-text-property helper for code reuse
- Added tp--update-reactive-text and tp--replace-reactive-text-in-buffer
- Updated tp-set, tp-reset, tp-add to handle tp-text property
- Added comprehensive tests for tp-text functionality
- Updated documentation with reactive text examples
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
- Convert tp-define-layer from macro to function that accepts evaluated args
- Add define-tp macro wrapper for convenient syntax
- Convert tp-define-layer-group from macro to function that accepts evaluated args
- Add define-tp-group macro wrapper for convenient syntax
- Update all tests to use new quoted format
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
When calling (tp-set str 'layer-name), the layer name symbol was wrapped
in a list by tp--parse-args. tp--resolve-props then incorrectly treated
this single-element list as a plist and generated an anonymous tp-anon-X
name instead of using the actual layer name.
The fix adds detection in tp--resolve-props for single-element lists
containing a defined layer/group name symbol, and correctly resolves
them by recursing with just the symbol.
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
1. When using setq-local, only update the current buffer
2. When using setq, update all buffers that have the text property
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
- Add tp--generate-anonymous-layer-name to create unique layer names (tp-anon-*)
- Update tp--resolve-props to handle anonymous plists:
- If plist has reactive variables ($...), generate tp-name and register dependencies
- All anonymous plists now get a tp-name for reactive support
- Update tp--parse-args to process all props through tp--resolve-props
- Update tp--ensure-props to handle plists with reactive variables
- Add tests for anonymous reactive layers with tp-set, tp-match-set, tp-regexp-set
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
- tp--resolve-props now uses tp-layer-props (includes tp-name) for layers
- For groups, uses tp--build-layer-props to include tp-layers structure
- Updated tests to verify tp-name and tp-layers are preserved
- Added new test for groups with multiple layers
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
- Add tp--resolve-props helper function to resolve layer/group names to property lists
- Modify tp--parse-args to handle layer name symbols for tp-set, tp-reset, tp-add
- Update tp-match-set, tp-match-reset, tp-match-add to accept layer names
- Update tp-regexp-set, tp-regexp-reset, tp-regexp-add to accept layer names
- Update docstrings to document the new functionality
- Add comprehensive tests for all affected functions
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
- Updated tp-search-map signature to (function property &optional value object start end)
- Updated tp-forward-do signature to (function property &optional value object times start end)
- Updated tp-backward-do signature to (function property &optional value object times start end)
- Function callback for tp-search-map now accepts (text &optional start end idx)
- Function callback for tp-forward-do/tp-backward-do now accepts (text &optional start end)
- Updated internal helper functions tp--search-do, tp--forward-do, tp--backward-do
- Added new tests for the updated APIs
- Updated documentation in README.md and README_CN.md with examples
Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>