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

Add cider-eval-dwim #3496

Closed
wants to merge 6 commits into from
Closed

Conversation

samhedin
Copy link
Contributor

@samhedin samhedin commented Oct 5, 2023

If no region is active, eval the toplevel form with cider-eval-defun-at-point.
If a region is active, run cider-eval-region.
Tiny function, but I find it useful. If there are any other situations/commands to add I'm all ears.


  • The commits are consistent with our contribution guidelines. checkdoc stuck: "Documentation style: Checking..."
  • You've added tests (if possible) to cover your change(s). No tests. Are they possible?
  • All tests are passing (eldev test)
  • All code passes the linter (eldev lint) which is based on elisp-lint. There are warnings but they are unrelated to my changes.
  • You've updated the changelog (if adding/changing user-visible functionality)
  • You've updated the user manual (if adding/changing user-visible functionality).

@samhedin samhedin force-pushed the cider-eval-dwim branch 2 times, most recently from 647fac8 to bda7809 Compare October 5, 2023 09:07
@vemv
Copy link
Member

vemv commented Oct 5, 2023

Thanks for the PR!

You can merge master in, in order for the CI warning to disappear.

cider-mode.el Outdated
@@ -495,6 +496,7 @@ higher precedence."
(define-key map (kbd "M-TAB") #'complete-symbol)
(define-key map (kbd "C-M-x") #'cider-eval-defun-at-point)
(define-key map (kbd "C-c C-c") #'cider-eval-defun-at-point)
(define-key map (kbd "C-c C-d") #'cider-eval-dwim)
Copy link
Member

Choose a reason for hiding this comment

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

Please use a keybinding in the eval keymap, instead of this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is C-c C-v C-d appropriate?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that's fine, just keep in mind that all keybindings in the eval keymap should have both a variant with and without Control - C-c C-v d and C-c C-v C-d. (some people don't like letting go of Control in complex keybindings)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

C-c C-v C-d was already taken by eval-defun so I changed d to s.

cider-eval.el Show resolved Hide resolved
cider-mode.el Outdated Show resolved Hide resolved
@samhedin samhedin force-pushed the cider-eval-dwim branch 2 times, most recently from 2cdb98b to 89a746d Compare October 6, 2023 07:57
CHANGELOG.md Show resolved Hide resolved
(if (use-region-p)
(cider-eval-region (region-beginning) (region-end))
(cider-eval-defun-at-point debug-it)))
(let ((clojure-toplevel-inside-comment-form t))
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing you should also mention this in the docstring.

@vemv vemv closed this in 33baff8 Oct 7, 2023
@vemv
Copy link
Member

vemv commented Oct 7, 2023

Thanks much for your contribution! I squashed it with some docstring and changelog tweaks, preserving attribution.

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.

3 participants