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

Reconnect to the same host:port after cider-restart if the connection was established with cider-connect #1905

Merged
merged 2 commits into from
Jan 4, 2017
Merged

Conversation

ckoparkar
Copy link
Contributor

@ckoparkar ckoparkar commented Jan 3, 2017

It's been a while since I've worked on anything in CIDER. Feels good to be back :-)

This PR fixes #1895.

@bbatsov, the approach is the same as what you outlined in the comment.

  1. Create a new buffer-local var cider-connection-created-with to track how the connection was created. It defaults to 'jack-in, and we set it to 'connect in cider-connect.
  2. In cider--restart-connection, we do the right thing based on the type of conn.
  • The commits are consistent with our contribution guidelines
  • You've added tests (if possible) to cover your change(s)
  • All tests are passing (make test)
  • The new code is not generating bytecode or M-x checkdoc warnings
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the readme (if adding/changing user-visible functionality)
  • You've updated the refcard (if you made changes to the commands listed there)

Thanks!

(buf-name (buffer-name conn)))
(buf-name (buffer-name conn))
;; save these variables before we kill the connection
(conn-type (with-current-buffer conn cider-connection-created-with))
Copy link
Member

Choose a reason for hiding this comment

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

conn-type is a bit misleading here. Maybe conn-creation-method?

@@ -245,6 +245,10 @@ namespace-qualified function of zero arity."
map)
"Minibuffer keymap used for reading Clojure expressions.")

(defvar-local cider-connection-created-with 'jack-in
"Save how the connection was created. Its value can be either 'jack-in or
Copy link
Member

Choose a reason for hiding this comment

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

The second sentence should be on a separate line.

(let ((default-directory project-dir))
(cider-jack-in))
(error "Can't restart CIDER connection for unknown project"))))
(if (eq conn-type 'connect)
Copy link
Member

Choose a reason for hiding this comment

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

I guess you can make this a pcase and add some error handling in case the conn-type is unexpectedly something different than the two possible values.

@bbatsov
Copy link
Member

bbatsov commented Jan 3, 2017

It's good to have you back! I've added a few small remarks.

@ckoparkar
Copy link
Contributor Author

Done :-)

@bbatsov bbatsov merged commit 8ae91ef into clojure-emacs:master Jan 4, 2017
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.

Restarting a repl does not connect to same port
3 participants