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

Filter and control order of debugging prompt overlay commands #2731

Merged
merged 4 commits into from
Oct 19, 2019

Conversation

yuhan0
Copy link
Contributor

@yuhan0 yuhan0 commented Oct 14, 2019

As per the blocker on clojure-emacs/cider-nrepl#613, which is a feature I'm looking forward to :)

I rearranged the default alphabetical order of the commands to exclude Continue and group them more semantically, here's what it looks like:
image


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)

@bbatsov
Copy link
Member

bbatsov commented Oct 15, 2019

I think that's the wrong approach to solving the problem. As I mentioned in the original ticket I think that the debugger middleware should send back the list of supported commands, the client should decide on the key mappings internally and never send the keys back to the debugger, as it definitely doesn't need to know about those. The client and the middleware should communicate only in terms of the command names.

Is this something you'd be willing to tackle? It's pretty straightforward, I've just been extremely busy with other stuff lately.

@yuhan0
Copy link
Contributor Author

yuhan0 commented Oct 16, 2019

Oh okay, I must have misunderstood the original conversation.

Just to clarify, that would mean a change to cider-nrepl to return a list of supported command names ["continue", "eval"...], and a change to cider.el to introduce a key->command mapping defvar ((?c . "continue") (?e . "eval") ...)?

In that way the communicated list can be considered an unsorted set, and it's the ordering and inclusion in the alist that would determine how the overlay is displayed?

@bbatsov
Copy link
Member

bbatsov commented Oct 16, 2019

Just to clarify, that would mean a change to cider-nrepl to return a list of supported command names ["continue", "eval"...], and a change to cider.el to introduce a key->command mapping defvar ((?c . "continue") (?e . "eval") ...)?

Yeah, exactly. Basically clients need to know only about the supported commands and they have to figure out key mappings themselves.

In that way the communicated list can be considered an unsorted set, and it's the ordering and inclusion in the alist that would determine how the overlay is displayed?

Exactly. As not all commands can be fitted on the screen probably at some point we should have some split between commands that are visible and those that are available, but hidden (e.g. they are not frequently used), but that's something for a later revision of this. The only reason why the keys are hardcoded today is that we didn't envision other clients of cider-nrepl and other commands. We were clearly wrong on both points. :D

@yuhan0
Copy link
Contributor Author

yuhan0 commented Oct 16, 2019

See clojure-emacs/cider-nrepl#654,
Debugging functionality is working as before but tests are not passing for now - if everything looks alright I'll squash the previous commits and tweak the necessary tests / changelog notes

@bbatsov
Copy link
Member

bbatsov commented Oct 16, 2019

Yeah, that's exactly what I had in mind. Apart from picking better names for commands like Continue all is good. Maybe we can keep the names for now and address this later, as it might be nice to have more descriptive names, but some people might prefer to shorten those somehow (e.g. by specifying some alias) to fit more commands.

@yuhan0
Copy link
Contributor Author

yuhan0 commented Oct 16, 2019

I just realised a bug with the current implementation - hidden commands like "Continue" can't be sent to the middleware, because the alist doubles as both the key mapping and the display spec.

I'll go ahead and implement the display-name mapping later this evening, would you prefer it to be a separate alist variable or combined with the current one?
ie. where the 2nd element is the command, and 3rd element is either the display name or nil for a hidden command:

'((?e "eval" "eval")
  (?C "continue-all" nil)
...)

@bbatsov
Copy link
Member

bbatsov commented Oct 16, 2019

I'd go with a single list. I guess the third element can be completely optional, but explicit nils are fine as well.

- This shifts the responsibility of key to command mappings to the client side,
  so the middleware only deals with a list of valid command names and not their
  key character mappings.

- Introduce new custom alist variable `cider-debug-prompt-commands`
  which represents a mapping between characters and debug commands to send
  to the middleware. The ordering and inclusion of pairs in this list determines
  how the debugger overlay is displayed

- Remove the local variable cider--debug-mode-commands-dict,
  since the new alist can perform this mapping.
to a list of (KEY COMMAND-NAME DISPLAY-NAME) specs
Small optimization as the formatting does not change across prompts and can be memoized
@bbatsov bbatsov merged commit c62d3de into clojure-emacs:master Oct 19, 2019
@bbatsov
Copy link
Member

bbatsov commented Oct 19, 2019

💯

@yuhan0 yuhan0 deleted the debug-prompt branch October 19, 2019 16:58
bbatsov added a commit that referenced this pull request Oct 27, 2019
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.

2 participants