Address code review feedback: improve docstring and null handling

Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-01-08 03:00:59 +00:00
parent 3a0f774c70
commit 89d76fa0cc

18
tp.el
View File

@ -1094,13 +1094,15 @@ it will be applied to the text before updating."
(tp--replace-reactive-text-in-buffer layer-name new-text props))))))))))) (tp--replace-reactive-text-in-buffer layer-name new-text props)))))))))))
(defun tp--merge-props-with-base (base-props new-props) (defun tp--merge-props-with-base (base-props new-props)
"Merge NEW-PROPS into BASE-PROPS, with NEW-PROPS taking precedence. "Merge NEW-PROPS into BASE-PROPS with NEW-PROPS taking precedence.
For face properties (face, font-lock-face, mouse-face), uses `tp--merge-face-values' Face properties are merged using `tp--merge-face-values', while other
to properly merge face values. For other properties, NEW-PROPS values override. properties from NEW-PROPS override those in BASE-PROPS. Properties only
BASE-PROPS are the original properties, NEW-PROPS are the new properties to apply. in BASE-PROPS are preserved. Returns the merged plist, or nil if both
Returns the merged plist." arguments are nil."
(if (null base-props) (cond
new-props ((null base-props) new-props)
((null new-props) base-props)
(t
(let ((result (copy-sequence new-props))) (let ((result (copy-sequence new-props)))
(cl-loop for (key val) on base-props by #'cddr (cl-loop for (key val) on base-props by #'cddr
do (let ((new-val (plist-get result key))) do (let ((new-val (plist-get result key)))
@ -1112,7 +1114,7 @@ Returns the merged plist."
(tp--merge-face-values val new-val)))) (tp--merge-face-values val new-val))))
;; New props doesn't have this key - add from base ;; New props doesn't have this key - add from base
(setq result (plist-put result key val))))) (setq result (plist-put result key val)))))
result))) result))))
(defun tp--replace-reactive-text-in-buffer (layer-name new-text props) (defun tp--replace-reactive-text-in-buffer (layer-name new-text props)
"Replace text in current buffer for reactive text with LAYER-NAME. "Replace text in current buffer for reactive text with LAYER-NAME.