Remove tp-set-face/tp-set-display, rename tp-match to tp-match-set, tp-regexp to tp-regexp-set

Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-15 12:32:56 +00:00
parent 9ecb5d6b5b
commit 091b4fa15f
4 changed files with 84 additions and 268 deletions

View File

@ -114,16 +114,16 @@ Native APIs only have simple set and get. tp.el provides three clear operation s
Native APIs require manual searching and looping. tp.el provides convenient pattern matching functionality:
- ✅ **String Matching**: `tp-match`, `tp-match-reset`, `tp-match-add`
- ✅ **Regexp Matching**: `tp-regexp`, `tp-regexp-reset`, `tp-regexp-add`
- ✅ **String Matching**: `tp-match-set`, `tp-match-reset`, `tp-match-add`
- ✅ **Regexp Matching**: `tp-regexp-set`, `tp-regexp-reset`, `tp-regexp-add`
- ✅ **Three Semantic Variants**: Each match type supports set/reset/add operation semantics
```elisp
;; Highlight all TODOs
(tp-match "TODO" '(face warning))
(tp-match-set "TODO" '(face warning))
;; Regexp match all numbers
(tp-regexp "[0-9]+" '(face font-lock-number-face))
(tp-regexp-set "[0-9]+" '(face font-lock-number-face))
;; Add properties with deep merge
(tp-match-add "TODO" '(face (:underline t)))
@ -178,8 +178,6 @@ A complete overview of all tp.el functions organized by category:
| [`tp-set`](#tp-set---set-text-properties) | Set text properties (replaces specified properties only) |
| [`tp-reset`](#tp-reset---replace-all-properties) | Replace ALL text properties |
| [`tp-add`](#tp-add---addmerge-properties) | Add/merge properties with deep merge support |
| [`tp-set-face`](#tp-set-face---set-face-property) | Set only the face property |
| [`tp-set-display`](#tp-set-display---set-display-property) | Set only the display property |
| [`tp-get`](#tp-get---get-property-value) | Get property value(s) from range or string |
| [`tp-at`](#tp-at---get-property-at-position) | Get property value(s) at a single position |
| [`tp-remove`](#tp-remove---remove-property) | Remove a property or sub-property |
@ -188,10 +186,10 @@ A complete overview of all tp.el functions organized by category:
#### Pattern Matching Functions
| Function | Description |
|----------|-------------|
| [`tp-match`](#tp-match---match-string) | Set properties on string pattern matches |
| [`tp-match-set`](#tp-match-set---match-string) | Set properties on string pattern matches |
| [`tp-match-reset`](#tp-match-reset---match-and-reset) | Reset all properties on string matches |
| [`tp-match-add`](#tp-match-add---match-and-add) | Add/merge properties on string matches |
| [`tp-regexp`](#tp-regexp---match-regexp) | Set properties on regexp matches |
| [`tp-regexp-set`](#tp-regexp-set---match-regexp) | Set properties on regexp matches |
| [`tp-regexp-reset`](#tp-regexp-reset---regexp-and-reset) | Reset all properties on regexp matches |
| [`tp-regexp-add`](#tp-regexp-add---regexp-and-add) | Add/merge properties on regexp matches |
@ -342,43 +340,6 @@ Add or update properties with deep merge support for nested plists.
---
#### `tp-set-face` - Set Face Property
Set only the face property, preserving other properties.
```elisp
(tp-set-face START END FACE &optional OBJECT)
(tp-set-face STRING FACE)
```
**Examples:**
```elisp
(tp-set-face 1 10 'bold)
(tp-set-face 1 10 '(:foreground "red" :weight bold))
(tp-set-face "Hello" 'italic)
```
---
#### `tp-set-display` - Set Display Property
Set only the display property, preserving other properties.
```elisp
(tp-set-display START END DISPLAY &optional OBJECT)
(tp-set-display STRING DISPLAY)
```
**Examples:**
```elisp
(tp-set-display 1 10 '(space :width 10))
(tp-set-display " " '(space :width 20))
```
---
#### `tp-get` - Get Property Value
Get property value(s) from range or string, with support for nested sub-properties.
@ -565,17 +526,17 @@ Clear all text properties from a region.
### Pattern Matching Functions
#### `tp-match` - Match String
#### `tp-match-set` - Match String
```elisp
;; Buffer
(tp-match PATTERN '(PROPERTY VALUE ...))
(tp-match-set PATTERN '(PROPERTY VALUE ...))
;; String or Buffer object
(tp-match PATTERN OBJECT '(PROPERTY VALUE ...))
(tp-match-set PATTERN OBJECT '(PROPERTY VALUE ...))
;; Pattern as (PATTERN STRING) format
(tp-match '(PATTERN STRING) '(PROPERTY VALUE ...))
(tp-match-set '(PATTERN STRING) '(PROPERTY VALUE ...))
```
Set properties on all occurrences of a string pattern.
@ -584,15 +545,15 @@ Set properties on all occurrences of a string pattern.
```elisp
;; In buffer - returns list of (START . END) pairs
(tp-match "TODO" '(face warning))
(tp-match-set "TODO" '(face warning))
;; => ((10 . 14) (50 . 54) ...)
;; On string - returns modified string
(tp-match "o" "Hello World" '(face bold))
(tp-match-set "o" "Hello World" '(face bold))
;; => #("Hello World" 4 5 (face bold) 7 8 (face bold))
;; Using (PATTERN STRING) format
(tp-match '("world" "Hello world") '(face bold))
(tp-match-set '("world" "Hello world") '(face bold))
;; => #("Hello world" 6 11 (face bold))
```
@ -632,14 +593,14 @@ Add/merge properties on matches with deep merge support.
---
#### `tp-regexp` - Match Regexp
#### `tp-regexp-set` - Match Regexp
```elisp
;; Buffer
(tp-regexp PATTERN '(PROPERTY VALUE ...))
(tp-regexp-set PATTERN '(PROPERTY VALUE ...))
;; String or Buffer object
(tp-regexp PATTERN OBJECT '(PROPERTY VALUE ...))
(tp-regexp-set PATTERN OBJECT '(PROPERTY VALUE ...))
```
Set properties on all matches of a regular expression.
@ -648,10 +609,10 @@ Set properties on all matches of a regular expression.
```elisp
;; Highlight all numbers in buffer
(tp-regexp "[0-9]+" '(face font-lock-number-face))
(tp-regexp-set "[0-9]+" '(face font-lock-number-face))
;; On string
(tp-regexp "[A-Z]+" "Hello WORLD" '(face bold))
(tp-regexp-set "[A-Z]+" "Hello WORLD" '(face bold))
;; => #("Hello WORLD" 6 11 (face bold))
```

View File

@ -113,16 +113,16 @@
原生 API 需要手动搜索和循环tp.el 提供了便捷的模式匹配功能:
- ✅ **字符串匹配**`tp-match`、`tp-match-reset`、`tp-match-add`
- ✅ **正则匹配**`tp-regexp`、`tp-regexp-reset`、`tp-regexp-add`
- ✅ **字符串匹配**`tp-match-set`、`tp-match-reset`、`tp-match-add`
- ✅ **正则匹配**`tp-regexp-set`、`tp-regexp-reset`、`tp-regexp-add`
- ✅ **三种语义变体**:每种匹配都支持 set/reset/add 三种操作语义
```elisp
;; 高亮所有 TODO
(tp-match "TODO" '(face warning))
(tp-match-set "TODO" '(face warning))
;; 正则匹配所有数字
(tp-regexp "[0-9]+" '(face font-lock-number-face))
(tp-regexp-set "[0-9]+" '(face font-lock-number-face))
;; 深度合并方式添加属性
(tp-match-add "TODO" '(face (:underline t)))
@ -177,8 +177,6 @@ tp.el 所有函数按类别组织的完整概览:
| [`tp-set`](#tp-set---设置文本属性) | 设置文本属性(仅替换指定属性) |
| [`tp-reset`](#tp-reset---替换所有属性) | 替换所有文本属性 |
| [`tp-add`](#tp-add---添加合并属性) | 添加/合并属性,支持深度合并 |
| [`tp-set-face`](#tp-set-face---设置-face-属性) | 仅设置 face 属性 |
| [`tp-set-display`](#tp-set-display---设置-display-属性) | 仅设置 display 属性 |
| [`tp-get`](#tp-get---获取属性值) | 从范围或字符串获取属性值 |
| [`tp-at`](#tp-at---获取位置属性) | 获取单个位置的属性值 |
| [`tp-remove`](#tp-remove---移除属性) | 移除属性或子属性 |
@ -187,10 +185,10 @@ tp.el 所有函数按类别组织的完整概览:
#### 模式匹配函数
| 函数 | 描述 |
|------|------|
| [`tp-match`](#tp-match---匹配字符串) | 在字符串匹配处设置属性 |
| [`tp-match-set`](#tp-match-set---匹配字符串) | 在字符串匹配处设置属性 |
| [`tp-match-reset`](#tp-match-reset---匹配并重置) | 在字符串匹配处重置所有属性 |
| [`tp-match-add`](#tp-match-add---匹配并添加) | 在字符串匹配处添加/合并属性 |
| [`tp-regexp`](#tp-regexp---匹配正则表达式) | 在正则匹配处设置属性 |
| [`tp-regexp-set`](#tp-regexp-set---匹配正则表达式) | 在正则匹配处设置属性 |
| [`tp-regexp-reset`](#tp-regexp-reset---正则匹配并重置) | 在正则匹配处重置所有属性 |
| [`tp-regexp-add`](#tp-regexp-add---正则匹配并添加) | 在正则匹配处添加/合并属性 |
@ -341,43 +339,6 @@ tp.el 所有函数按类别组织的完整概览:
---
#### `tp-set-face` - 设置 Face 属性
只设置 face 属性,保留其他属性。
```elisp
(tp-set-face START END FACE &optional OBJECT)
(tp-set-face STRING FACE)
```
**示例:**
```elisp
(tp-set-face 1 10 'bold)
(tp-set-face 1 10 '(:foreground "red" :weight bold))
(tp-set-face "Hello" 'italic)
```
---
#### `tp-set-display` - 设置 Display 属性
只设置 display 属性,保留其他属性。
```elisp
(tp-set-display START END DISPLAY &optional OBJECT)
(tp-set-display STRING DISPLAY)
```
**示例:**
```elisp
(tp-set-display 1 10 '(space :width 10))
(tp-set-display " " '(space :width 20))
```
---
#### `tp-get` - 获取属性值
从范围或字符串获取属性值,支持嵌套子属性访问。
@ -564,17 +525,17 @@ tp.el 所有函数按类别组织的完整概览:
### 模式匹配函数
#### `tp-match` - 匹配字符串
#### `tp-match-set` - 匹配字符串
```elisp
;; 缓冲区
(tp-match PATTERN '(PROPERTY VALUE ...))
(tp-match-set PATTERN '(PROPERTY VALUE ...))
;; 字符串或缓冲区对象
(tp-match PATTERN OBJECT '(PROPERTY VALUE ...))
(tp-match-set PATTERN OBJECT '(PROPERTY VALUE ...))
;; 使用 (PATTERN STRING) 格式
(tp-match '(PATTERN STRING) '(PROPERTY VALUE ...))
(tp-match-set '(PATTERN STRING) '(PROPERTY VALUE ...))
```
在所有字符串模式匹配处设置属性。
@ -583,15 +544,15 @@ tp.el 所有函数按类别组织的完整概览:
```elisp
;; 在缓冲区中 - 返回 (START . END) 对的列表
(tp-match "TODO" '(face warning))
(tp-match-set "TODO" '(face warning))
;; => ((10 . 14) (50 . 54) ...)
;; 在字符串上 - 返回修改后的字符串
(tp-match "o" "Hello World" '(face bold))
(tp-match-set "o" "Hello World" '(face bold))
;; => #("Hello World" 4 5 (face bold) 7 8 (face bold))
;; 使用 (PATTERN STRING) 格式
(tp-match '("world" "Hello world") '(face bold))
(tp-match-set '("world" "Hello world") '(face bold))
;; => #("Hello world" 6 11 (face bold))
```
@ -631,14 +592,14 @@ tp.el 所有函数按类别组织的完整概览:
---
#### `tp-regexp` - 匹配正则表达式
#### `tp-regexp-set` - 匹配正则表达式
```elisp
;; 缓冲区
(tp-regexp PATTERN '(PROPERTY VALUE ...))
(tp-regexp-set PATTERN '(PROPERTY VALUE ...))
;; 字符串或缓冲区对象
(tp-regexp PATTERN OBJECT '(PROPERTY VALUE ...))
(tp-regexp-set PATTERN OBJECT '(PROPERTY VALUE ...))
```
在所有正则表达式匹配处设置属性。
@ -647,10 +608,10 @@ tp.el 所有函数按类别组织的完整概览:
```elisp
;; 高亮缓冲区中的所有数字
(tp-regexp "[0-9]+" '(face font-lock-number-face))
(tp-regexp-set "[0-9]+" '(face font-lock-number-face))
;; 在字符串上
(tp-regexp "[A-Z]+" "Hello WORLD" '(face bold))
(tp-regexp-set "[A-Z]+" "Hello WORLD" '(face bold))
;; => #("Hello WORLD" 6 11 (face bold))
```

View File

@ -545,38 +545,38 @@
;;; Match and Regexp Tests
;;; ============================================================
(ert-deftest tp-test-match ()
"Test tp-match sets properties on string matches."
(ert-deftest tp-test-match-set ()
"Test tp-match-set sets properties on string matches."
(tp-test-with-temp-buffer
(insert "Hello World Hello")
(let ((regions (tp-match "Hello" 'face 'bold)))
(let ((regions (tp-match-set "Hello" 'face 'bold)))
(should (= (length regions) 2))
(should (eq (tp-at 1 'face) 'bold))
(should (eq (tp-at 13 'face) 'bold)))))
(ert-deftest tp-test-match-returns-regions ()
"Test tp-match returns correct region pairs."
(ert-deftest tp-test-match-set-returns-regions ()
"Test tp-match-set returns correct region pairs."
(tp-test-with-temp-buffer
(insert "Hello World Hello")
(let ((regions (tp-match "Hello")))
(let ((regions (tp-match-set "Hello")))
(should (= (length regions) 2))
(should (equal (car regions) '(1 . 6)))
(should (equal (cadr regions) '(13 . 18))))))
(ert-deftest tp-test-regexp ()
"Test tp-regexp sets properties on regexp matches."
(ert-deftest tp-test-regexp-set ()
"Test tp-regexp-set sets properties on regexp matches."
(tp-test-with-temp-buffer
(insert "abc 123 def 456")
(let ((regions (tp-regexp "[0-9]+" 'face 'bold)))
(let ((regions (tp-regexp-set "[0-9]+" 'face 'bold)))
(should (= (length regions) 2))
(should (eq (tp-at 5 'face) 'bold))
(should (eq (tp-at 13 'face) 'bold)))))
(ert-deftest tp-test-regexp-returns-regions ()
"Test tp-regexp returns correct region pairs."
(ert-deftest tp-test-regexp-set-returns-regions ()
"Test tp-regexp-set returns correct region pairs."
(tp-test-with-temp-buffer
(insert "abc 123 def 456")
(let ((regions (tp-regexp "[0-9]+")))
(let ((regions (tp-regexp-set "[0-9]+")))
(should (= (length regions) 2)))))
;;; ============================================================
@ -942,19 +942,19 @@
(should (equal (get-text-property 0 'help-echo result) "test"))
(should (eq (get-text-property 4 'face result) 'bold))))
(ert-deftest tp-test-match-on-string ()
"Test tp-match works on string objects."
(ert-deftest tp-test-match-set-on-string ()
"Test tp-match-set works on string objects."
(let* ((str (copy-sequence "Hello World Hello"))
(result (tp-match "Hello" str 'face 'bold)))
(result (tp-match-set "Hello" str 'face 'bold)))
(should (stringp result))
(should (eq (get-text-property 0 'face result) 'bold))
(should (eq (get-text-property 12 'face result) 'bold))
(should (null (get-text-property 6 'face result)))))
(ert-deftest tp-test-regexp-on-string ()
"Test tp-regexp works on string objects."
(ert-deftest tp-test-regexp-set-on-string ()
"Test tp-regexp-set works on string objects."
(let* ((str (copy-sequence "abc 123 def 456"))
(result (tp-regexp "[0-9]+" str 'face 'bold)))
(result (tp-regexp-set "[0-9]+" str 'face 'bold)))
(should (stringp result))
(should (eq (get-text-property 4 'face result) 'bold))
(should (eq (get-text-property 12 'face result) 'bold))
@ -1040,38 +1040,6 @@ Returns list of (START END VALUE) intervals."
(should (eq (tp-at 1 'face) 'italic))
(should (equal (tp-at 1 'help-echo) "test"))))
(ert-deftest tp-test-set-face ()
"Test tp-set-face sets only face property."
(tp-test-with-temp-buffer
(insert "Hello")
(tp-set 1 6 '(face bold help-echo "test"))
(tp-set-face 1 6 'italic)
(should (eq (tp-at 1 'face) 'italic))
(should (equal (tp-at 1 'help-echo) "test"))))
(ert-deftest tp-test-set-face-on-string ()
"Test tp-set-face on string."
(let ((str (copy-sequence "Hello")))
(tp-set 0 5 '(help-echo "test") str)
(tp-set-face 0 5 'bold str)
(should (eq (get-text-property 0 'face str) 'bold))
(should (equal (get-text-property 0 'help-echo str) "test"))))
(ert-deftest tp-test-set-face-entire-string ()
"Test tp-set-face on entire string."
(let* ((str (copy-sequence "Hello"))
(result (tp-set-face str 'bold)))
(should (eq (get-text-property 0 'face result) 'bold))))
(ert-deftest tp-test-set-display ()
"Test tp-set-display sets only display property."
(tp-test-with-temp-buffer
(insert "Hello")
(tp-set 1 6 '(face bold help-echo "test"))
(tp-set-display 1 6 '(space :width 10))
(should (equal (tp-at 1 'display) '(space :width 10)))
(should (eq (tp-at 1 'face) 'bold))))
(ert-deftest tp-test-add ()
"Test tp-add adds/updates properties without replacing."
(tp-test-with-temp-buffer
@ -1156,10 +1124,10 @@ Returns list of (START END VALUE) intervals."
;;; Match Pattern Format Tests
;;; ============================================================
(ert-deftest tp-test-match-pattern-string-format ()
"Test tp-match with (pattern string) format."
(ert-deftest tp-test-match-set-pattern-string-format ()
"Test tp-match-set with (pattern string) format."
(let* ((str (copy-sequence "Hello world"))
(result (tp-match '("world" "Hello world") '(face bold))))
(result (tp-match-set '("world" "Hello world") '(face bold))))
(should (stringp result))
(should (eq (get-text-property 6 'face result) 'bold))
(should (null (get-text-property 0 'face result)))))
@ -1219,19 +1187,19 @@ Returns list of (START END VALUE) intervals."
(should (eq (get-text-property 4 'face str) 'bold))
(should (equal (get-text-property 4 'help-echo str) "original"))))
(ert-deftest tp-test-match-string-as-last-arg ()
"Test tp-match with string as last argument."
(ert-deftest tp-test-match-set-string-as-last-arg ()
"Test tp-match-set with string as last argument."
(let ((str (copy-sequence "Hello World Hello")))
(let ((result (tp-match "Hello" '(face bold) str)))
(let ((result (tp-match-set "Hello" '(face bold) str)))
(should (stringp result))
(should (eq (get-text-property 0 'face result) 'bold))
(should (eq (get-text-property 12 'face result) 'bold))
(should (null (get-text-property 6 'face result))))))
(ert-deftest tp-test-regexp-string-as-last-arg ()
"Test tp-regexp with string as last argument."
(ert-deftest tp-test-regexp-set-string-as-last-arg ()
"Test tp-regexp-set with string as last argument."
(let ((str (copy-sequence "abc 123 def 456")))
(let ((result (tp-regexp "[0-9]+" '(face italic) str)))
(let ((result (tp-regexp-set "[0-9]+" '(face italic) str)))
(should (stringp result))
(should (eq (get-text-property 4 'face result) 'italic))
(should (eq (get-text-property 12 'face result) 'italic))

116
tp.el
View File

@ -272,80 +272,6 @@ Return the modified object (string) or region (START . END) for buffer."
object
(cons start finish))))
(defun tp--parse-single-prop-args (start-or-string end-or-val val-or-object rest)
"Parse arguments for single-property functions like tp-set-face.
Returns (OBJECT START END VALUE)."
(let (object start finish value)
(cond
;; First arg is a string - apply to entire string
((stringp start-or-string)
(setq object start-or-string
start 0
finish (length start-or-string)
value end-or-val))
;; First arg is a number - region convention
((numberp start-or-string)
(setq start start-or-string
finish end-or-val
value val-or-object
object (car rest)))
(t (error "Invalid first argument: %S" start-or-string)))
(list object start finish value)))
(defun tp-set-face (start-or-string &optional end-or-face face-or-object &rest rest)
"Set face property on string or buffer region.
This function supports four calling conventions:
1. Current buffer:
(tp-set-face START END FACE)
2. Specific buffer:
(tp-set-face START END FACE BUFFER)
3. Specific string (0-indexed positions):
(tp-set-face START END FACE STRING)
4. Entire string:
(tp-set-face STRING FACE)
This replaces only the face property, preserving other properties.
Return the modified object (string) or region (START . END) for buffer."
(pcase-let ((`(,object ,start ,finish ,face)
(tp--parse-single-prop-args
start-or-string end-or-face face-or-object rest)))
(put-text-property start finish 'face face object)
(if (stringp object)
object
(cons start finish))))
(defun tp-set-display (start-or-string &optional end-or-display display-or-object &rest rest)
"Set display property on string or buffer region.
This function supports four calling conventions:
1. Current buffer:
(tp-set-display START END DISPLAY)
2. Specific buffer:
(tp-set-display START END DISPLAY BUFFER)
3. Specific string (0-indexed positions):
(tp-set-display START END DISPLAY STRING)
4. Entire string:
(tp-set-display STRING DISPLAY)
This replaces only the display property, preserving other properties.
Return the modified object (string) or region (START . END) for buffer."
(pcase-let ((`(,object ,start ,finish ,display)
(tp--parse-single-prop-args
start-or-string end-or-display display-or-object rest)))
(put-text-property start finish 'display display object)
(if (stringp object)
object
(cons start finish))))
(defun tp--get-nested (value path)
"Get nested value from VALUE following PATH.
PATH is a list of keys/symbols to traverse nested structures.
@ -926,22 +852,22 @@ Merges nested plists instead of replacing them."
(put-text-property pos next-pos key new-val obj)))
(setq pos next-pos)))))
(defun tp-match (pattern &rest args)
(defun tp-match-set (pattern &rest args)
"Set properties on all occurrences of PATTERN.
This function supports multiple calling conventions:
1. With OBJECT (string or buffer):
(tp-match PATTERN OBJECT PROPERTY VALUE ...)
(tp-match PATTERN OBJECT \\='(PROPERTY VALUE ...))
(tp-match PATTERN \\='(PROPERTY VALUE ...) OBJECT)
(tp-match-set PATTERN OBJECT PROPERTY VALUE ...)
(tp-match-set PATTERN OBJECT \\='(PROPERTY VALUE ...))
(tp-match-set PATTERN \\='(PROPERTY VALUE ...) OBJECT)
2. Without OBJECT (current buffer):
(tp-match PATTERN PROPERTY VALUE ...)
(tp-match PATTERN \\='(PROPERTY VALUE ...))
(tp-match-set PATTERN PROPERTY VALUE ...)
(tp-match-set PATTERN \\='(PROPERTY VALUE ...))
3. With pattern as (PATTERN STRING) to match within STRING:
(tp-match \\='(\"world\" \"Hello world\") \\='(face bold))
(tp-match-set \\='(\"world\" \"Hello world\") \\='(face bold))
PATTERN is the string to search for.
PROPERTIES is a plist of property-value pairs.
@ -958,8 +884,8 @@ Returns:
(defun tp-match-reset (pattern &rest args)
"Reset (completely replace) properties on all occurrences of PATTERN.
Same calling conventions as `tp-match'.
Unlike `tp-match', this completely replaces all existing properties."
Same calling conventions as `tp-match-set'.
Unlike `tp-match-set', this completely replaces all existing properties."
(let* ((parsed (tp--parse-match-args args))
(object (car parsed))
(properties (cdr parsed))
@ -973,8 +899,8 @@ Unlike `tp-match', this completely replaces all existing properties."
(defun tp-match-add (pattern &rest args)
"Add/update properties on all occurrences of PATTERN.
Same calling conventions as `tp-match'.
Unlike `tp-match', this deeply merges nested properties."
Same calling conventions as `tp-match-set'.
Unlike `tp-match-set', this deeply merges nested properties."
(let* ((parsed (tp--parse-match-args args))
(object (car parsed))
(properties (cdr parsed))
@ -983,19 +909,19 @@ Unlike `tp-match', this deeply merges nested properties."
object (cdr parsed-pattern))
(tp--match-apply pattern properties #'tp--deep-merge-apply object)))
(defun tp-regexp (pattern &rest args)
(defun tp-regexp-set (pattern &rest args)
"Set properties on all matches of PATTERN (regexp).
This function supports multiple calling conventions:
1. With OBJECT (string or buffer):
(tp-regexp PATTERN OBJECT PROPERTY VALUE ...)
(tp-regexp PATTERN OBJECT \\='(PROPERTY VALUE ...))
(tp-regexp PATTERN \\='(PROPERTY VALUE ...) OBJECT)
(tp-regexp-set PATTERN OBJECT PROPERTY VALUE ...)
(tp-regexp-set PATTERN OBJECT \\='(PROPERTY VALUE ...))
(tp-regexp-set PATTERN \\='(PROPERTY VALUE ...) OBJECT)
2. Without OBJECT (current buffer):
(tp-regexp PATTERN PROPERTY VALUE ...)
(tp-regexp PATTERN \\='(PROPERTY VALUE ...))
(tp-regexp-set PATTERN PROPERTY VALUE ...)
(tp-regexp-set PATTERN \\='(PROPERTY VALUE ...))
PATTERN is the regexp to search for.
PROPERTIES is a plist of property-value pairs.
@ -1009,8 +935,8 @@ Returns:
(defun tp-regexp-reset (pattern &rest args)
"Reset (completely replace) properties on all regexp matches of PATTERN.
Same calling conventions as `tp-regexp'.
Unlike `tp-regexp', this completely replaces all existing properties."
Same calling conventions as `tp-regexp-set'.
Unlike `tp-regexp-set', this completely replaces all existing properties."
(let* ((parsed (tp--parse-match-args args))
(object (car parsed))
(properties (cdr parsed)))
@ -1021,8 +947,8 @@ Unlike `tp-regexp', this completely replaces all existing properties."
(defun tp-regexp-add (pattern &rest args)
"Add/update properties on all regexp matches of PATTERN.
Same calling conventions as `tp-regexp'.
Unlike `tp-regexp', this deeply merges nested properties."
Same calling conventions as `tp-regexp-set'.
Unlike `tp-regexp-set', this deeply merges nested properties."
(let* ((parsed (tp--parse-match-args args))
(object (car parsed))
(properties (cdr parsed)))