Skip to content
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

Inject cider REPL dependencies at cider-jack-in #1552

Merged
merged 1 commit into from
Feb 14, 2016

Conversation

benedekfazekas
Copy link
Member

So users don't have to fiddle with profiles.clj and the like, see
details in #1531 Supports both leiningen and boot. Additionally there is
a defcustom cider-skip-repl-dependencies-at-jack-in to switch this
functionality off (defaults to nil); and an extension point
defun (cider-add-repl-dependencies) so other tools like clj-refactor
can inject to their own dependencies, middlewares

Fix #1531 and #1534

@@ -165,6 +165,11 @@ This variable is used by `cider-connect'."
:type 'boolean
:version "0.9.0")

(defcustom cider-skip-repl-dependencies-at-jack-in nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use a negation here? Why not call it cider-inject-dependencies or something with a default of t?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess to stress the fact that we default to inject. but I am easy, happy to rename.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @expez.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@bbatsov
Copy link
Member

bbatsov commented Feb 9, 2016

This should also be in the README and the changelog. In particular the README's installation section will need some updating.

(defvar cider-repl-dependencies
`((("org.clojure/tools.nrepl" "0.2.12"))
(("cider/cider-nrepl" ,(upcase cider-version)))
("cider.nrepl/cider-middleware"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we split this var in two: cider-repl-dependencies and cider-repl-middleware or something similar.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking to leave this as is but rather split cider-add-repl-dependencies into add-middlewares and add-dependencies

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why introduce complexity (var which holds two types of data) when simplification also makes it easier to work with?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @expez. It's confusing right now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and we should definitely mark these variables as risky-local.

@benedekfazekas
Copy link
Member Author

@bbatsov changelog and README is done

"List of Clojure artifacts for starting the REPL.
First item is a list of dependencies where elements are lists of artifact name and version.
Second item is a list of leiningen plugins where elements are lists of artifact name and version.
Third item is a list of nrepl middleware names.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nrepl -> nREPL

@bbatsov
Copy link
Member

bbatsov commented Feb 9, 2016

Just to be clear, as it's kind of hard to figure out what the code does without tests - this simply passes more params to lein and boot, right?

I think it should also account for cider-jack-in-clojurescript as there we have additional params (e.g. piggieback).

(concat
(mapconcat
'identity
(seq-map (lambda (dep) (format "-d %s:%s" (car dep) (cadr dep))) dependencies)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seq-map can be removed by replacing that 'identity above with this (lambda ...).
Same thing for the ones below.

@Malabarba
Copy link
Member

Thanks for working on this Benedek.

I agree that the functions that manipulate the parameters need tests. Right now, it's a little hard to guess what they're supposed to do, so a couple of tests for each of them are sure to be helpful in the future.

@bbatsov
Copy link
Member

bbatsov commented Feb 9, 2016

@benedekfazekas Btw, just to be clear - this will take precedence over something in profiles.clj, right?

@benedekfazekas
Copy link
Member Author

Just to be clear, as it's kind of hard to figure out what the code does without tests - this simply passes more params to lein and boot, right?

if you jack in you should see what it generates to start up the repl. if there is additional params (for cljs): code only modifies params so it should be fine. but you are right I deffo need to test it.

Btw, just to be clear - this will take precedence over something in profiles.clj, right?

I assumed so but noted: need to explicitly test this too.

@benedekfazekas
Copy link
Member Author

@bbatsov
Copy link
Member

bbatsov commented Feb 9, 2016

Guess you'll have to test it and see what happens.

@benedekfazekas
Copy link
Member Author

thanks for the review, I think I made all the changes requested.

Tested precedence: CLI params win over ~/lein/profiles.clj.

Postponed syncing with master as master build seems to be broken atm.

@benedekfazekas
Copy link
Member Author

it seems I have the same test failure as master. suppose I still wait until that is fixed on master...

@bbatsov
Copy link
Member

bbatsov commented Feb 11, 2016

Postponed syncing with master as master build seems to be broken atm.

Actually it seems the fucked up tests are broken. I'm 100% sure that the code I wrote is correct, but the I'm not nearly as sure about the odd logic of the failing 2 tests. I'll likely just delete them...

@@ -177,6 +182,18 @@ Sub-match 1 must be the project path.")
(defvar cider-host-history nil
"Completion history for connection hosts.")

(defvar cider-jack-in-dependencies
'(("org.clojure/tools.nrepl" "0.2.12"))
"Clojure artifacts for starting the REPL. List of dependencies where elements are lists of artifact name and version.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 3 docstring start in more or less the same manner. This looks like some mistake to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha that was intentional. I guess my semi-conscious attempt to group them. happy to remove the first sentence if you'd like.

"-d org.clojure/tools.nrepl:0.2.12 -d cider/cider-nrepl:0.11.0-SNAPSHOT repl -m cider.nrepl/cider-middleware -s wait")))

(ert-deftest cider-inject-jack-in-dependencies-add-refactor-nrepl ()
(setq cider-jack-in-lein-plugins (seq-concatenate 'list cider-jack-in-lein-plugins '(("refactor-nrepl" "2.0.0"))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use let instead of setq. Those are dynamic variables and you don't want the tests to affect the defaults.

@@ -655,3 +655,17 @@
(should (equal (cider-project-name "") "-"))
(should (equal (cider-project-name "path/to/project") "project"))
(should (equal (cider-project-name "path/to/project/") "project")))

(ert-deftest cider-inject-jack-in-dependencies ()
(should (string= (cider-inject-jack-in-dependencies "repl :headless" "lein")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest stubbing the version and having one test for a snapshot version and one test for a stable version.

So users don't have to fiddle with profiles.clj and the like, see
details in clojure-emacs#1531 Supports both leiningen and boot. Additionally there is
a defcustom `cider-inject-dependencies-at-jack-in` to control this
functionality (defaults to t); other tools (like clj-refactor) can
modify `cider-jack-in-dependencies`, `cider-jack-in-lein-plugins` and
`cider-jack-in-nrepl-middlewares` to inject their own dependencies.

Fix clojure-emacs#1531, clojure-emacs#1534
bbatsov added a commit that referenced this pull request Feb 14, 2016
Inject cider REPL dependencies at cider-jack-in
@bbatsov bbatsov merged commit c9e8d61 into clojure-emacs:master Feb 14, 2016
@bbatsov
Copy link
Member

bbatsov commented Feb 14, 2016

👍

@benedekfazekas
Copy link
Member Author

Woot! :)

@phillord
Copy link
Contributor

Thank you all. This will have a big impact on the usability of cider, I think.

@benedekfazekas
Copy link
Member Author

I hope you are right. As I said on twitter thx for bringing this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants