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

Fix shortcut for REPL buffers when type is "any" #2484

Merged
merged 4 commits into from
Nov 18, 2018

Conversation

kommen
Copy link
Contributor

@kommen kommen commented Oct 12, 2018

This fixes a regression from #2467 where in clojure repl buffers the cider eldoc feature stopped working.


Before submitting the PR make sure the following things have been done (and denote this
by checking the relevant checkboxes):

  • 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)
  • All code passes the linter (make lint) which is based on elisp-lint and includes
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the user manual (if adding/changing user-visible functionality)

Thanks!

If you're just starting out to hack on CIDER you might find this section of its
manual
extremely useful.

@kommen
Copy link
Contributor Author

kommen commented Oct 12, 2018

Test failures seem to be due to an upstream change: vspinu/sesman#10

@@ -702,7 +702,8 @@ are synonyms. If ENSURE is non-nil, throw an error if either there is
no linked session or there is no REPL of TYPE within the current session."
(if (and (derived-mode-p 'cider-repl-mode)
(or (null type)
(string= cider-repl-type type)))
(string= cider-repl-type type)
(string= "any" type)))
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, as any and multi can't be synonyms here maybe we should treat them differently by default? It also seems to me that this check should be after the null check, so the code reads better.

On a related note - can you please change these types to be symbols instead of strings everywhere. It's very weird to pass around types as strings in Elisp and I guess this was just some oversight of ours when REPL types were added. For backward compatibility you can just coerce type arguments to symbol in methods like this one (there's a function cider-maybe-symbol or something like this.

Copy link
Member

Choose a reason for hiding this comment

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

Also - if we're using symbols we can use the more effecient eq checks instead of string= and equal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, as any and multi can't be synonyms here maybe we should treat them differently by default?

How do you men differently?

I can take care of the rest.

Copy link
Member

Choose a reason for hiding this comment

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

Well, in this particular code snippet passing "multi" will result in the same bug. :-) I'm saying this because in some places we treat "multi" and "any" as the same and somewhere differently. Probably we should agree they are different.

Copy link
Contributor

Choose a reason for hiding this comment

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

The fix doesn't look quite right to me. This function becomes unreadable with all those if-else and cons.

Any objection against reverting #2467 and just adding (when (equal type "any") (setq type "multi")) as the first line in the function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any objection against reverting #2467 and just adding (when (equal type "any") (setq type "multi")) as the first line in the function?

How would this address the original issue #2467 fixed?

Copy link
Member

Choose a reason for hiding this comment

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

I think it'd better to use something like (member type '(any multi)) instead of converting any to multi. As a said - there are cases where semantically they won't be exactly the same, so I'd rather keep them separate.

Copy link
Contributor

Choose a reason for hiding this comment

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

This would need to be done at least twice in this function and at least once in the utility function. Plus there is already a re-assignment to "multi" in the let part. I If the semantics of this function ever diverges one can modify it later, for now the simplicity of the code is more important. None of us noticed the issue with the original PR.

@kommen
sorry, by reverting I meant reverting the "any" implementation for this function only, not the whole patch

@bbatsov
Copy link
Member

bbatsov commented Oct 28, 2018

@kommen Ping :-)

@kommen
Copy link
Contributor Author

kommen commented Oct 28, 2018

@bbatsov I've addressed two of your comments.

Regarding changing the "clj", "cljs", "any" and "multi" repl types from strings to symbols:
I don't think I fully grasp the implications of changing it everywhere, e.g here:

cider/cider.el

Line 1011 in d1eef83

(plist-put :repl-type "clj")

You think it is fine to change it here as well?

@bbatsov
Copy link
Member

bbatsov commented Oct 28, 2018

Yep. In the end there should be not strings referring to repl types, only symbols.

(scored-repls
(delq nil
(mapcar (lambda (b)
(let ((bparams (cider--gather-connect-params nil b)))
(when (eq cljsp (string-match-p "cljs" (plist-get bparams :repl-type)))
(when (eq cljsp (string-match-p "cljs"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Anybody knows what cljsp is supposed to be about? I assume it is to consider pending-cljs repls to be reused by cljs repls? But not sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's non-nil when it's either cljs or pending-cljs.

@kommen
Copy link
Contributor Author

kommen commented Oct 29, 2018

@bbatsov I've pushed the current state of my branch. Things still needed:

  • figure out which functions need to be made backwards compatible by accepting strings and turn them into symbols with cider-maybe-intern
  • ensure fec7691#r228822378 is doing the right thing
  • investigate ci failure
  • update doc strings
  • add changelog

Not sure I will have time this week to address these though.

@kommen
Copy link
Contributor Author

kommen commented Nov 3, 2018

This is ready for review.

@bbatsov
Copy link
Member

bbatsov commented Nov 6, 2018

@kommen The code looks good. You just need to squash together all commits related to the transition from strings to symbols.

CHANGELOG.md Outdated

### Changes

* [#2484](https://github.com/clojure-emacs/cider/pull/2484): REPL types are now symbols instead of strings
Copy link
Member

Choose a reason for hiding this comment

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

You forgot the . here.

@kommen
Copy link
Contributor Author

kommen commented Nov 6, 2018

Thanks @bbatsov! I'll test this branch in day to day work somewhen this week to be more confident it doesn't break anything and then will address your comments.

@bbatsov
Copy link
Member

bbatsov commented Nov 6, 2018

Sounds like a plan to me!

@bbatsov
Copy link
Member

bbatsov commented Nov 16, 2018

Is the PR ready to go?

@kommen
Copy link
Contributor Author

kommen commented Nov 16, 2018

using it the branch for day to day stuff i found some more issues stilll. i’d rather test it a bit more.

@kommen
Copy link
Contributor Author

kommen commented Nov 16, 2018

but i don’t know of any remaining issues right now

@bbatsov
Copy link
Member

bbatsov commented Nov 16, 2018

Well, if you work it day-to-day I guess it doesn't break anything major. :-) Anyways, I'm fine with you testing it longer if you prefer that.

Make public functions backwards compatible by converting type string to symbol
@kommen
Copy link
Contributor Author

kommen commented Nov 18, 2018

@bbatsov I've squashed the commits to combine them logically.

As pauld on the slack also tried the branch and confirmed it fixed an issue for him, I think this should be good to merge.

@bbatsov bbatsov merged commit 1fd1275 into clojure-emacs:master Nov 18, 2018
@bbatsov
Copy link
Member

bbatsov commented Nov 18, 2018

Thanks!

@kommen kommen deleted the fix-current-repl-shortcut branch November 19, 2018 19:10
@arichiardi
Copy link
Contributor

Awesome job folks I have just bumped into this and wanted to say thanks!

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.

None yet

4 participants