Skip to content

Consolidate track-state ns-cache access behind a shared accessor #3981

@bbatsov

Description

@bbatsov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions