Improve tp-put parameter naming for clarity

Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-13 10:04:41 +00:00
parent c285fb20eb
commit 243904f490

18
tp.el
View File

@ -100,7 +100,7 @@ Appends 'tp-name property to identify the layer."
;;; Basic text property functions (similar to ov.el) ;;; Basic text property functions (similar to ov.el)
(defun tp-put (start-or-string &optional end props-or-prop &rest rest) (defun tp-put (start-or-string &optional end-or-prop props-or-val &rest rest)
"Set text properties on string or buffer region. "Set text properties on string or buffer region.
This function supports four calling conventions: This function supports four calling conventions:
@ -123,25 +123,27 @@ Return the modified object (string) or region (START . END) for buffer."
;; Determine calling convention based on first argument type ;; Determine calling convention based on first argument type
(cond (cond
;; First arg is a string - apply to entire string ;; First arg is a string - apply to entire string
;; In this case: end-or-prop is first property, props-or-val is first value
((stringp start-or-string) ((stringp start-or-string)
(setq object start-or-string (setq object start-or-string
start 0 start 0
finish (length start-or-string) finish (length start-or-string)
props (if end props (if end-or-prop
(if props-or-prop (if props-or-val
(cons end (cons props-or-prop rest)) (cons end-or-prop (cons props-or-val rest))
(list end)) (list end-or-prop))
nil))) nil)))
;; First arg is a number - region convention ;; First arg is a number - region convention
;; In this case: end-or-prop is end position, props-or-val is plist
((numberp start-or-string) ((numberp start-or-string)
(setq start start-or-string (setq start start-or-string
finish end) finish end-or-prop)
;; Check if 4th arg (first of rest) is a buffer or string ;; Check if 4th arg (first of rest) is a buffer or string
(if (and rest (or (bufferp (car rest)) (stringp (car rest)))) (if (and rest (or (bufferp (car rest)) (stringp (car rest))))
(setq object (car rest) (setq object (car rest)
props props-or-prop) props props-or-val)
(setq object nil (setq object nil
props props-or-prop))) props props-or-val)))
(t (error "Invalid first argument: %S" start-or-string))) (t (error "Invalid first argument: %S" start-or-string)))
;; Handle properties as a list ;; Handle properties as a list
(when (listp (car-safe props)) (when (listp (car-safe props))