Skip to content

Ability to specify context in cljr-magic-require-namespaces #530

Open
@vemv

Description

@vemv

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:

  • Introduce new defcustom, e.g. cljr-jvm-magic-require-namespaces
    • This would be a list like '("clojure.java.io"), specifying which values of cljr-magic-require-namespaces are intended for JVM clojure.
    • Same for cljs
  • (Preferred) Allow cljr-magic-require-namespaces to also include lists
    • Example difference:
(defcustom cljr-magic-require-namespaces
  '(("set"  . "clojure.set")
-   ("io"   . "clojure.java.io")
+   ("io"   "clojure.java.io" "clj")
+   ("io"   "foo.io" "cljs")
    ("str"  . "clojure.string")
    ("walk" . "clojure.walk")
    ("zip"  . "clojure.zip")))

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

  • There are two values that must be expressible: clj, cljs
    • cljc would be a no-op (since by default, entries already are context-agnostic)
  • A value such as "io" "clojure.java.io" "clj" is intended to mean "please only possibly suggest clojure.java.io if the filename is .clj"
    • It does not, however, mean "clojure.java.io is the only acceptable completion if the filename is .clj"
    • refactor-nrepl is ultimately responsible for deciding what choice(s) will be offered.

Final decision

#530 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions