Repository navigation
Add magic requires - #4218
Merged
Merged
Add magic requires#4218
Conversation
bbatsov
force-pushed
the
ns-magic-requires
branch
2 times, most recently
from
October 23, 2026 05:53
b7273f5 to
dd2229a
Compare
clj-refactor's cljr-slash adds the require an alias needs as the alias gets typed, and it's the clj-refactor feature people still ask for. With cider-ns-magic-requires on (it's off by default), typing a slash after an alias the ns form doesn't have does the same. The namespace comes from cider-nrepl's cider/resolve-alias, which goes by the aliases the project's source files use, and from cider-ns-magic-require-aliases when the REPL can't tell. An entry there can name the platforms its namespace works on, so io doesn't bring clojure.java.io into ClojureScript. It hooks into post-self-insert-hook rather than binding the slash, so clj-refactor's binding keeps working where it's on. Since it runs while the user types, the request gives up on the next keystroke, failures go to the echo area, an error from evaluating the ns form doesn't select the error buffer, and the require is an undo step of its own. Picking nothing leaves the alias alone in that buffer from then on.
Magic requires go by the project's aliases through its cider/resolve-alias op.
bbatsov
force-pushed
the
ns-magic-requires
branch
from
October 24, 2026 11:32
dd2229a to
90e08c8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An opt-in take on clj-refactor's
cljr-slash, which came up in #3356. With clojure-emacs/cider-nrepl#1062 it goes by the aliases the project already uses, and bycider-ns-magic-require-aliasesalone with an older cider-nrepl. It hooks intopost-self-insert-hookinstead of binding the slash, so clj-refactor's binding wins where both are on.