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 feature to evaluate list around point #2881

Merged
merged 5 commits into from
Aug 2, 2020

Conversation

gveres
Copy link
Contributor

@gveres gveres commented Aug 1, 2020

This adds a new function cider-eval-list-at-point, that evaluates a list around point [as in: code delimited by the nearest pair of parens surrounding point]. This comes handy to evaluate a function call while the point is anywhere within the function call.
It's modelled after the eval-sexp-at-point solution, and as such, deals with the "deref @" and other quirks intelligently.

In terms of the implementation, it's built on a thingatpoint built-in feature, so no magic text manipulation is happening. Although the thingatpoint code targets Emacs Lisp, it should work fine with Clojure code too.

Sorry, no tests (yet) - I'd appreciate some help or guidance on what to cover for this.


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.

@bbatsov
Copy link
Member

bbatsov commented Aug 2, 2020

Isn't cider-eval-sexp-at-point pretty much the same?

@gveres
Copy link
Contributor Author

gveres commented Aug 2, 2020

Isn't cider-eval-sexp-at-point pretty much the same?

No: as I understand, a symbol is also a sexp in the implementation, so if point is on a symbol, that symbol gets evaluated, not the surrounding list. list-at-point will expand to include the innermost surrounding paren pair, and sends that whole thing ("compound form"?) to eval.

@bbatsov bbatsov merged commit 52945c2 into clojure-emacs:master Aug 2, 2020
@bbatsov
Copy link
Member

bbatsov commented Aug 2, 2020

Yeah, I think you're right. I use only eval-last-sexp and eval-defun, so my memory on everything else is fuzzy. I'll merge this as is and I'll add a couple of tests myself. Thanks!

@gveres
Copy link
Contributor Author

gveres commented Aug 3, 2020

Amazing - thanks a lot, @bbatsov!

practicalli-johnny added a commit to practicalli-johnny/spacemacs-fork that referenced this pull request Sep 28, 2020
New command added to CIDER in version 0.26 to evaluate the list around the
current point, different to evaluate sexp around point which also evaluates
symbols.

clojure-emacs/cider#2881
duianto pushed a commit to syl20bnr/spacemacs that referenced this pull request Oct 1, 2020
New command added to CIDER in version 0.26 to evaluate the list around the
current point, different to evaluate sexp around point which also evaluates
symbols.

clojure-emacs/cider#2881
nobv pushed a commit to nobv/spacemacs that referenced this pull request Oct 9, 2020
New command added to CIDER in version 0.26 to evaluate the list around the
current point, different to evaluate sexp around point which also evaluates
symbols.

clojure-emacs/cider#2881
rgb-24bit pushed a commit to rgb-24bit/spacemacs that referenced this pull request Nov 3, 2020
New command added to CIDER in version 0.26 to evaluate the list around the
current point, different to evaluate sexp around point which also evaluates
symbols.

clojure-emacs/cider#2881
yyoncho pushed a commit to yyoncho/spacemacs that referenced this pull request Jan 26, 2021
New command added to CIDER in version 0.26 to evaluate the list around the
current point, different to evaluate sexp around point which also evaluates
symbols.

clojure-emacs/cider#2881
aam-at pushed a commit to aam-at/spacemacs that referenced this pull request Mar 23, 2021
New command added to CIDER in version 0.26 to evaluate the list around the
current point, different to evaluate sexp around point which also evaluates
symbols.

clojure-emacs/cider#2881
wang-d pushed a commit to wang-d/spacemacs that referenced this pull request Jul 22, 2021
New command added to CIDER in version 0.26 to evaluate the list around the
current point, different to evaluate sexp around point which also evaluates
symbols.

clojure-emacs/cider#2881
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