Context
The track-state namespace cache (cider-repl-ns-cache, a defvar-local in cider-repl.el populated by the track-state middleware) is read independently by three modules. Each forward-declares the variable and reads it via (buffer-local-value 'cider-repl-ns-cache <repl>):
cider-resolve--ns-cache (cider-resolve.el) - returns the whole dict for dynamic font-locking
cider-ns-loaded-p (cider-client.el) - membership check with a find-ns eval fallback
cider-ns-state--refresh (cider-ns-state.el) - cache-only tri-state check for the load-state indicator
Idea
Extract the low-level access into a single accessor (e.g. cider-ns-load-cache) in cider-client.el - the lowest layer all three already require - and have the three readers build their (legitimately different) policies on top of it. This removes two of the three forward declarations and single-sources the coupling to cider-repl.el's internal var.
Caveat
The three readers can't be merged - they differ on purpose (full dict vs membership, eval fallback vs cache-only, and the unknown-vs-not-loaded distinction). And cider-client.el can't reuse the existing cider-resolve--ns-cache because cider-resolve requires cider-client (cycle), which is why the accessor has to live in cider-client.el. One call site is the font-locking hot path, so this is low-priority polish rather than a fix.
Context
The track-state namespace cache (
cider-repl-ns-cache, adefvar-localincider-repl.elpopulated by the track-state middleware) is read independently by three modules. Each forward-declares the variable and reads it via(buffer-local-value 'cider-repl-ns-cache <repl>):cider-resolve--ns-cache(cider-resolve.el) - returns the whole dict for dynamic font-lockingcider-ns-loaded-p(cider-client.el) - membership check with afind-nseval fallbackcider-ns-state--refresh(cider-ns-state.el) - cache-only tri-state check for the load-state indicatorIdea
Extract the low-level access into a single accessor (e.g.
cider-ns-load-cache) incider-client.el- the lowest layer all three already require - and have the three readers build their (legitimately different) policies on top of it. This removes two of the three forward declarations and single-sources the coupling tocider-repl.el's internal var.Caveat
The three readers can't be merged - they differ on purpose (full dict vs membership, eval fallback vs cache-only, and the unknown-vs-not-loaded distinction). And
cider-client.elcan't reuse the existingcider-resolve--ns-cachebecausecider-resolverequirescider-client(cycle), which is why the accessor has to live incider-client.el. One call site is the font-locking hot path, so this is low-priority polish rather than a fix.