-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to specify context in cljr-magic-require-namespaces
#530
Comments
I'm curious why the defcustom should still be an alist prefixed by the namespace refer. If the intention is to send the entire defcustom to the middleware, can't we parse the recommended as target in the middleware? I wonder if we could make it a list of the recommendation string with a list of valid language contexts, where a nil list indicates all language contexts are allowed.
In the future this could support examples where the recommended namespace contained a refers or a reader conditional. Ie an example like: As a reminder, while I think the majority of users are only encountering this with cljc, cljs, and clj, the official docs for reader conditionals includes This would not be quite as compatible with the existing format, but I think it allows for more flexibility moving forward. |
While desiring such a thing makes sense, I'd like to favor a different approach: real project usage (i.e. whatever you have in your namespace files) is the ultimate indication to refactor-nrepl of what is intended. This is more concise (you have to declare very few, basic preferences), and more flexible (goes on a per-project basis; their different customs don't get mixed up). We also don't require a migration path for users (which can be hard to communicate IME). It also goes well with the CIDER's overall philosophy of gathering insights at runtime, instead of requiring extensive, upfront, static configuration. I'm not definitely closing the door to this feature, but in the end, making the middleware accept more inputs (e.g. a new defcustom, while the old one remains acceptable) is not a breaking change. Thanks! |
I think on further reflection, the major concern I have about this, despite it being backwards compatible is that it feels like a very unintuitive syntax to encounter in Emacs without any context. I'm struggling to think of any other API I've seen using a syntax like this? It's not discoverable without specifically reading the docs for the defcustom (which I'm not sure we can fix), but more importantly if I saw it in the wild I don't know as I would intuitively understand that it was limiting it to those contexts. What if we use keyword like
I believe that is still backwards compatible, but I think that might be easier to follow at first glance? It would also support adding |
Sounds good, let's go for it 👍 |
cljr-magic-require-namespaces
doesn't currently allow specifying its intended context (:clj, :cljs).This can easily cause incorrect suggestions for cljr-slash.
I'd suggest one of the following:
cljr-jvm-magic-require-namespaces
'("clojure.java.io")
, specifying which values ofcljr-magic-require-namespaces
are intended for JVM clojure.i.e. we could mix and match cons cells (
("set" . "clojure.set")
) with lists having the extra property("io" "clojure.java.io" "clj")
.Both approaches are intended to be backwards-compatible.
Notes on semantics
"io" "clojure.java.io" "clj"
is intended to mean "please only possibly suggest clojure.java.io if the filename is .clj"Final decision
#530 (comment)
The text was updated successfully, but these errors were encountered: