-
Notifications
You must be signed in to change notification settings - Fork 69
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
clean-ns: fall back to :relative-path, when given #251
clean-ns: fall back to :relative-path, when given #251
Conversation
Allow the client to send both the absolute path and a relative path to a file, we use the first one that we can find. The absolute path is used when the client (Emacs) and the JVM are on the same filesystem/same machine. The second is used when they are not on the same filesystem (e.g. running nREPL on a remote machine or in a VM), but the JVM runs in the (mounted) project directory, so that relative file lookups still work. See clojure-emacs/clj-refactor.el#380 (comment)
This makes use of a change to refactor-nrepl [1], but should be safe when using older versions of refactor-nrepl, as in that case it simply uses the absolute path, which is generally preferred over the relative one. When used with the change to refactor-nrepl it will try first the absolute, then the relative path, and use the first that can be found. [1]: clojure-emacs/refactor-nrepl#251
This makes use of a change to refactor-nrepl [1], but should be safe when using older versions of refactor-nrepl, as in that case it simply uses the absolute path, which is generally preferred over the relative one. When used with the change to refactor-nrepl it will try first the absolute, then the relative path, and use the first that can be found. [1]: clojure-emacs/refactor-nrepl#251
This seems unrelated, is this a flaky test? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
We also need an update to the readme for the clean-ns
op and a changelog entry 👍
(defn clean-ns [{:keys [path relative-path]}] | ||
{:pre [(seq path) (string? path)]} | ||
;; Try first the absolute, then the relative path | ||
(let [path (first (filter #(some-> % io/file .exists) [path relative-path]))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some
might be better here since we're looking for the first thing that fulfills some pred
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the predicate returns boolean rather than the truthy value I find it awkward to use some
for such cases, as you end up with (some #(and (pred? %) %) coll)
. Would you still prefer some
?
I've updated the CHANGELOG and README, and rewrote that use of It's very annoying that I can't run tests locally, no matter what I do I get clojure.lang.LispReader$ReaderException: java.lang.RuntimeException: No reader function for tag Inf when mranderson loads the ns parallel.core. I've tried forcing the Clojure version to 1.10 but nothing seems to work. |
I'm very sorry, I accidentally pushed this to master, and I can't rewind because master is protected. I hope this looks good! I'll try to do some better testing to make sure, let me know if you think this needs more work @expez and I'll do it on a new PR. |
I tried grepping the project for @benedekfazekas Does it make a huge difference if you use that library or can we drop it from mranderson? If not, we might consider opening an issue over at that repo to let him know that this is causing breakage over here. |
Clojure itself understands It also seems to work on CI so clearly I'm doing something wrong, I just have no clue what. I'm just trying to run |
Aha. Did not know that!
The version of Clojure that we're using is non-deterministic, since multiple versions are specified. It's just lucky that it works on the CI server. If we added proper exclusions to our |
yeah aware of this new limitation of MrAnderson. however, this only means that the MrAnderson step needs to be run with |
ah checked the above comments properly, guessing @plexus that you use an older version of leiningen? |
It would appear so, I was still on 2.8.3 apparently. |
Did a |
nw @plexus, happy it is solved |
This makes use of a change to refactor-nrepl [1], but should be safe when using older versions of refactor-nrepl, as in that case it simply uses the absolute path, which is generally preferred over the relative one. When used with the change to refactor-nrepl it will try first the absolute, then the relative path, and use the first that can be found. [1]: clojure-emacs/refactor-nrepl#251
When I do a clean-ns using the latest snapshot
|
Updated to the latest clj-refactor.el, now I get:
|
that is a know issue with latest snapshot (not really related to this issue) i still have not got around to check. sorry. |
Allow the client to send both the absolute path and a relative path to a file,
we use the first one that we can find.
The absolute path is used when the client (Emacs) and the JVM are on the same
filesystem/same machine. The second is used when they are not on the same
filesystem (e.g. running nREPL on a remote machine or in a VM), but the JVM runs
in the (mounted) project directory, so that relative file lookups still work.
I failed to run the tests locally. Will see what CI says.
See clojure-emacs/clj-refactor.el#380 (comment)