Closed chpill closed 9 months ago
I've just confirmed that the feature works as expected when I manually override the files in .emacs.d/elpa/28.2/develop/clj-refactor-20231202.445
with the files from the 3.11.0
version of this repo, and then rm *.elc
files.
Thanks for the report!
What's your value of cljr-magic-require-namespaces
? and cljr-slash-uses-suggest-libspec
?
Does it get fixed if you remove ("io" "clojure.java.io" :only ("clj"))
from the former?
cljr-magic-require-namespaces
:
(("edn" . "clojure.edn")
("io" "clojure.java.io" :only
("clj"))
("math" . "clojure.math")
("set" . "clojure.set")
("str" . "clojure.string")
("walk" . "clojure.walk")
("zip" . "clojure.zip"))
cljr-slash-uses-suggest-libspec
: t
Indeed, when I remove ("io" "clojure.java.io" :only ("clj"))
from cljr-magic-require-namespaces
, the issue goes away.
Indeed, when I remove ("io" "clojure.java.io" :only ("clj")) from cljr-magic-require-namespaces, the issue goes away.
Thanks!
Feel free to give it a go @dgtized
Yea I'm seeing that now. I believe that's on the parsing side in the middleware given it's a java stacktrace though. The clj-refactor client is sending across "preferred-aliases" with prin1-to-string
, which has the default value:
"((\"edn\" . \"clojure.edn\")
(\"io\" \"clojure.java.io\" :only (\"clj\"))
(\"math\" . \"clojure.math\")
(\"set\" . \"clojure.set\")
(\"str\" . \"clojure.string\")
(\"walk\" . \"clojure.walk\")
(\"zip\" . \"clojure.zip\"))"
See https://github.com/clojure-emacs/clj-refactor.el/blob/master/clj-refactor.el#L2032.
So I suspect the failure here is that the middleware is having difficulty in parse-preferred-aliases. It might be that read-string
is having trouble reading back ("clj")
as it's not actually a list because it's not '("clj")
or (list "clj")
. Alternatively, it looks like the first pass of the parser may be assuming a syntax like: ["io" "clojure.java.io" :only :clj]"
and not accounting for a list of language contexts for the value of :only
. However, that is the syntax we decided on in https://github.com/clojure-emacs/clj-refactor.el/issues/530#issuecomment-1221624825. Specifically, by supporting a set of contexts instead of singular context, we can future proof our syntax for something like ("io" "clojure.java.io" :only ("bb" "clj"))
.
Looking through the suggest_libspec tests it looks like they may all assume a single value for :only
instead of a set of accepted language contexts. I'm not sure if that's just a simplification in the tests or if that is also a constraint in the implementation. If it's the latter it seems reasonable to update the middleware to accept a list, but not accept any lists with multiple values yet.
So short term, it seems reasonable to revert to the old syntax here until the middleware can parse :only
statements with a list. We can't add tests to verify this here as they all mock the interface with the middleware. I think just reverting https://github.com/clojure-emacs/clj-refactor.el/pull/555/commits/8806352a64ac7207138eb990915fdd33e93218ca would be sufficient for now?
Thanks much for the accurate analysis @dgtized !
I went ahead and fixed the middleware.
I've cut a new clj-refactor.el release, to be melpa-visible within the next few hours.
Hi, thanks for this amazing package!
I've refreshed my spacemacs packages and I see an error message each time I type a namespace alias that is not already in the namespace declaration (for example, I will see the error if I type
str/
and the[clojure.string :as str]
is not in thens
form).Expected behavior
Adds the correct missing libspec.
Actual behavior
Error with the following stacktrace:
Steps to reproduce the problem
Environment & Version information
clj-refactor.el version information
3.11.1
CIDER version information
Include here the version string displayed when CIDER's REPL is launched. Here's an example:
This was injected when jacking in
Leiningen or Boot version
Clojure CLI version 1.11.1.1413
Emacs version
GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.18.0, Xaw3d scroll bars)
Operating system
Linux NixOS 23.11