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 more commands to cider-eval-dwim #3502

Open
samhedin opened this issue Oct 7, 2023 · 2 comments
Open

Add more commands to cider-eval-dwim #3502

samhedin opened this issue Oct 7, 2023 · 2 comments

Comments

@samhedin
Copy link
Contributor

samhedin commented Oct 7, 2023

Creating this issue to come up with more ideas for cider-eval-dwim. Right now, it's very close to covering all my eval-needs in one nice command.

Currently, it runs cider-eval-region and cider-eval-defun-at-point depending on whether a region is active.
It would be cool if it could run cider-eval-defun-to-comment.

But how to support this intuitively is not clear to me.
I considered prefix args, but that's already taken for cider-eval-defun-at-point.
Suggestions welcome for both how to add cider-eval-defun-to-comment, and other commands to include.

@bbatsov
Copy link
Member

bbatsov commented Oct 7, 2023

You can do this with more complex prefix args, but I guess that won't fit very well the dwim semantics. Perhaps it can detect the presence a comment placeholder after the line in question (e.g. ;; => ).

@vemv
Copy link
Member

vemv commented Oct 7, 2023

that won't fit very well the dwim semantics

I agree - it would be very hard/risky to guess that the user possibly wants a "comment" output.

There's nothing wrong to have multiple commands.


An unrelated possible point for expanding "dwim semantics" is guessing what sexpr we want to eval depending on where POINT (|) is:

|()

;; or:

()|
  • If it's at beggining of line, and at the beginning of the top-level sexpr, very likely we want to eval the next sexpr.
  • If it's at the end of line, and at the end of the top-level sexpr, very likely we want to eval the previous sexpr.

Now, say that point is here:

(defn foo []
   ;; here:
  |(+ 3 2))

Do we mean to eval (+ 3 2) or the whole defn?

A reasonable criterion is: if we're in a defn (or deftest, etc), eval the whole defn, if we're in a comment, only eval (+ 3 2).

And perhaps in certain cases, ask the user (completing-read makes this fairly low-friction).

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

No branches or pull requests

3 participants