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

implement cider-eval-enclosing-form #2899

Closed
xificurC opened this issue Sep 7, 2020 · 7 comments
Closed

implement cider-eval-enclosing-form #2899

xificurC opened this issue Sep 7, 2020 · 7 comments
Labels
feature request good first issue A simple tasks suitable for first-time contributors

Comments

@xificurC
Copy link

xificurC commented Sep 7, 2020

Is your feature request related to a problem? Please describe.

I'm often with the cursor inside a form I'd like to evaluate. Typically in rich comments I edit an argument and want to try reevaluating the wrapping form. If it's in the middle of the (comment) block I need to go to the beginning of the next line (evil/vim curse, can't put cursor past last character) and run cider-eval-last-sexp.

Describe the solution you'd like

Ideally I'd want to stay where I am with the cursor and run the parenthesized expression that encloses it. Finding the enclosing paren is done by searching for the first opening paren to the left. The function could be easily enriched by searching for the second highest enclosing paren via universal-argument.

Describe alternatives you've considered

I've looked through all cider-eval-* functions and found none that meet my needs. Maybe I'm just blind though :)

Another option that would cover 80-90% of my use cases would be if cider-eval-defun-at-point would treat (comment) blocks as special and thought of each inner form as a separate toplevel form.

Additional context

@bbatsov
Copy link
Member

bbatsov commented Sep 11, 2020

Another option that would cover 80-90% of my use cases would be if cider-eval-defun-at-point would treat (comment) blocks as special and thought of each inner form as a separate toplevel form.

I thought @dpsutton already implemented something like this a while ago.

Ideally I'd want to stay where I am with the cursor and run the parenthesized expression that encloses it.

cider-eval-sexp-at-point doesn't work for you?

@xificurC
Copy link
Author

Let | be the cursor. Then for

(comment (+ 2| 3))

cider-eval-defun-at-point returns nil

cider-eval-sexp-at-point returns 2

I want to evaluate the (+ 2 3) part and get 5 as the result.

@dakra
Copy link

dakra commented Sep 11, 2020

@xificurC did you (setq clojure-toplevel-inside-comment-form t) ?

@xificurC
Copy link
Author

Hi @dakra , no, since I didn't know of that variable. Surprisingly (to me at least) it's in clojure and not cider.

I'd still consider the original suggestion, but I'll play around with this and see it fills my use cases. Thanks!

@bbatsov
Copy link
Member

bbatsov commented Sep 11, 2020

Surprisingly (to me at least) it's in clojure and not cider.

Because the logic for sexp boundaries lives in clojure-mode.

@bbatsov bbatsov added feature request good first issue A simple tasks suitable for first-time contributors labels Oct 8, 2020
@vemv
Copy link
Member

vemv commented Aug 21, 2023

Given it has a fix/workaround, I'll close this issue.

PRs (accompanied by a convincing pitch) most welcome!

@vemv vemv closed this as completed Aug 21, 2023
@xificurC
Copy link
Author

I found a reasonable solution

  (defun my/cider-ppe-list ()
    (interactive)
    (cider--pprint-eval-form (cider-list-at-point 'bounds)))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request good first issue A simple tasks suitable for first-time contributors
Projects
None yet
Development

No branches or pull requests

4 participants