Move the anonymous-layer counter and name generator into tp-layer
tp--anonymous-layer-counter and tp--generate-anonymous-layer-name lived in tp-core, two modules below their only caller tp--anonymous-layer-name-for - and the counter was tp-core's only piece of mutable non-defcustom state. Anonymous-layer naming is layer machinery, so move both into tp-layer.el right beside the registry and the interning function. tp-core is now pure utilities plus defcustoms. Also document a deliberate asymmetry that was easy to mistake for an oversight: tp-layer-reset clears the anonymous-layer registry but the counter INTENTIONALLY survives it. Detached strings can outlive a reset while still carrying tp-anon-N property values, so the counter must keep increasing monotonically - a post-reset anonymous layer must never be minted under a name a stale string still holds. The comment protects the future registry refactor from "fixing" this wrongly. Internal symbols only; no API or behavior change. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
95fb4ae862
commit
e870b87941
@ -29,9 +29,6 @@
|
||||
:prefix "tp-"
|
||||
:group 'development)
|
||||
|
||||
(defvar tp--anonymous-layer-counter 0
|
||||
"Counter for generating unique anonymous layer names.")
|
||||
|
||||
(defcustom tp-debug-mode nil
|
||||
"When non-nil, enable debug logging for reactive updates.
|
||||
Debug messages are logged to the *tp-debug* buffer and optionally
|
||||
@ -110,11 +107,6 @@ FORMAT-STRING and ARGS are passed to `format'."
|
||||
(interactive)
|
||||
(pop-to-buffer (get-buffer-create "*tp-debug*")))
|
||||
|
||||
(defun tp--generate-anonymous-layer-name ()
|
||||
"Generate a unique symbol for anonymous reactive layers."
|
||||
(setq tp--anonymous-layer-counter (1+ tp--anonymous-layer-counter))
|
||||
(intern (format "tp-anon-%d" tp--anonymous-layer-counter)))
|
||||
|
||||
(defmacro tp-with-current-buffer (buffer-or-name &rest body)
|
||||
"Execute BODY in BUFFER-OR-NAME with `inhibit-read-only' bound to t."
|
||||
(declare (indent defun))
|
||||
|
||||
17
tp-layer.el
17
tp-layer.el
@ -51,6 +51,23 @@ named elements) are recorded here; layers merely referenced by name
|
||||
are not. Used to clean up orphaned layers when a group is redefined
|
||||
or undefined.")
|
||||
|
||||
;; The counter below INTENTIONALLY survives `tp-layer-reset' (which
|
||||
;; clears `tp--anonymous-layer-registry' but not this): detached
|
||||
;; strings can outlive a reset while still carrying `tp-anon-N'
|
||||
;; property values, so the counter must keep increasing monotonically
|
||||
;; - a post-reset anonymous layer must never be minted under a name a
|
||||
;; stale string still holds. Do not "fix" this by resetting it.
|
||||
(defvar tp--anonymous-layer-counter 0
|
||||
"Counter for generating unique anonymous layer names.
|
||||
Never reset - not even by `tp-layer-reset' - so freshly minted
|
||||
`tp-anon-N' names cannot collide with names living on in detached
|
||||
strings (see the comment above).")
|
||||
|
||||
(defun tp--generate-anonymous-layer-name ()
|
||||
"Generate a unique symbol for anonymous reactive layers."
|
||||
(setq tp--anonymous-layer-counter (1+ tp--anonymous-layer-counter))
|
||||
(intern (format "tp-anon-%d" tp--anonymous-layer-counter)))
|
||||
|
||||
(defvar tp--anonymous-layer-registry nil
|
||||
"Alist interning anonymous reactive layers: (PROPS-SPEC . LAYER-NAME).
|
||||
PROPS-SPEC is the original (unresolved) props spec passed to
|
||||
|
||||
Loading…
Reference in New Issue
Block a user