Skip to content

Drop clojure-expected-ns delegation from cider-expected-ns#3924

Merged
bbatsov merged 2 commits into
masterfrom
decouple-expected-ns
May 20, 2026
Merged

Drop clojure-expected-ns delegation from cider-expected-ns#3924
bbatsov merged 2 commits into
masterfrom
decouple-expected-ns

Conversation

@bbatsov
Copy link
Copy Markdown
Member

@bbatsov bbatsov commented May 20, 2026

Step 2 of the decoupling sweep. Inline the path-based namespace derivation that was previously delegated to clojure-expected-ns.

The classpath-based path is preferred (and unchanged); it already used cider-path-to-ns and didn't touch clojure-expected-ns. The fallback now uses a small internal helper cider--ns-from-path that:

  • finds the project root via cider-project-dir (from PR Use project.el directly for project root detection #3922),
  • drops the first directory component of the project-relative path,
  • runs cider-path-to-ns to swap / and _,
  • strips known directory prefixes via a new cider-directory-prefixes defcustom (mirrors clojure-directory-prefixes).

Same algorithm clojure-expected-ns uses today, owned by cider so we don't reach into clojure-mode for it.

Tests rewritten. The old ones asserted the coupling itself ((cider-expected-ns ...) :to-equal (clojure-expected-ns ...)); the new ones assert the actual behavior we want, using a cider-project-dir stub for the fallback path.

Inline the path-based namespace derivation that was previously
delegated to `clojure-expected-ns'.  The new internal helper
`cider--ns-from-path' uses `cider-project-dir' to find the project
root, then applies the same drop-first-dir + path-to-ns +
strip-known-prefixes algorithm clojure-mode uses (with prefixes now
owned by cider via `cider-directory-prefixes').

Behavior is unchanged for files on the classpath (still preferred)
and for files in a recognized project layout.  Tests rewritten to
assert the new behavior directly instead of the old "delegates to
clojure-expected-ns" coupling.
@bbatsov bbatsov force-pushed the decouple-expected-ns branch from 335be71 to 6537c50 Compare May 20, 2026 11:23
Elisp's `foo'` quoting renders correctly in `M-x describe-*` output
but GitHub displays it literally. Switching the CHANGELOG entries I
introduced over recent PRs to plain Markdown backticks so they render
properly in the release notes view.

Cosmetic only.
@bbatsov bbatsov merged commit 6d48422 into master May 20, 2026
13 checks passed
@bbatsov bbatsov deleted the decouple-expected-ns branch May 20, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant