Delete the dead layer-expansion pair in tp-layer

tp--expand-layer-to-props-list and tp--expand-props-to-remove were an
orphaned early draft of "expand a layer name into the property keys it
contributes": nothing calls them - the only reference in the whole
tree (sources, tests, doctest, README) is the pair calling each other.
The maintained equivalent of this logic is the inline expansion in
tp-ops's tp--remove-property, which is what tp-remove actually runs;
if deduplication is ever wanted, that copy is the one to extract.

Keeping a second, uncalled implementation of layer expansion around
invites the two to drift apart silently, so remove the 67 dead lines.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kinneyzhang 2026-07-27 02:08:41 +08:00
parent 99bd6f7c15
commit 95fb4ae862

View File

@ -132,74 +132,6 @@ The error message names the full cycle, e.g. \"a -> b -> a\"."
(reverse (cons layer-name tp--layer-expansion-stack))
" -> "))))
(defun tp--expand-layer-to-props-list (layer-name str start)
"Expand LAYER-NAME to a list of property keys it contributes.
If LAYER-NAME is a layer defined in `tp-layer-alist', returns a list
of the property keys that the layer adds, plus `tp-name'.
STR and START are used to get the argument value for parameterized layers.
For non-layer symbols, returns a list containing just that symbol."
(if (tp--is-layer-name-p layer-name)
(let* ((existing-props (text-properties-at start str))
(existing-tp-name (plist-get existing-props 'tp-name))
(layer-prop-value (plist-get existing-props layer-name))
;; Proceed if tp-name matches OR if the layer property exists
;; (for cases where layer was used in mixed syntax without tp-name)
(layer-props
(cond
;; tp-name matches - traditional layer application
((eq existing-tp-name layer-name)
(cond
;; Parameterized layer - get property keys it would produce
;; We pass dummy args (t) since we only need the key
;; names, not values
((tp-layer-parameterized-p layer-name)
(tp-layer-props-with-args
layer-name
(make-list (length (tp-layer-arglist layer-name)) t)
nil)) ; include-tp-name=nil
;; Non-parameterized layer
((assoc layer-name tp-layer-alist)
(tp-layer-props layer-name nil)) ; include-tp-name=nil
;; Layer group
((assoc layer-name tp-layer-groups)
(when-let ((layer-props-list (tp-group-props layer-name t)))
(tp--build-layer-props layer-props-list)))))
;; Layer property exists (mixed syntax like `tp-set str 'face 'bold 'layer arg`)
;; In this case, the layer's face properties are merged into face
(layer-prop-value
(cond
((tp-layer-parameterized-p layer-name)
(tp--layer-props-for-arg-value layer-name layer-prop-value nil))
((assoc layer-name tp-layer-alist)
(tp-layer-props layer-name nil))
((assoc layer-name tp-layer-groups)
(when-let ((layer-props-list (tp-group-props layer-name t)))
(tp--build-layer-props layer-props-list))))))))
(if layer-props
;; Return all property keys from the layer plus tp-name and the layer itself
(let ((keys (cl-loop for (key _val) on layer-props by #'cddr
collect key)))
(unless (memq 'tp-name keys)
(push 'tp-name keys))
(unless (memq layer-name keys)
(push layer-name keys))
keys)
;; Layer name doesn't match tp-name and layer property doesn't exist
;; Just remove the literal symbol
(list layer-name)))
;; Not a layer name, just return the symbol itself
(list layer-name)))
(defun tp--expand-props-to-remove (props-to-remove str start)
"Expand PROPS-TO-REMOVE list, expanding any layer names to their property keys.
STR and START are used to determine context for parameterized layers."
(let ((result nil))
(dolist (prop props-to-remove)
(dolist (expanded (tp--expand-layer-to-props-list prop str start))
(unless (memq expanded result)
(push expanded result))))
(nreverse result)))
(defun tp--get-layer-face-contribution (layer-name layer-prop-value)
"Get the face contribution from LAYER-NAME.
LAYER-PROP-VALUE is the value of the layer property (the argument passed to it).