Skip to content

Commit

Permalink
[Fix #1720] Add a command to evaluate the form around point
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Apr 29, 2016
1 parent 3698fa0 commit 26bb282
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
used in a project, particular if it is lower than minimum required for CIDER.
* Allow the ns displayed by eldoc to be tailored via `cider-eldoc-ns-function`.
* After connecting a ClojureScript REPL, CIDER will try to figure out if it's being served on a port and will offer to open it in a browser.
* [#1720](https://github.com/clojure-emacs/cider/issues/1720): Add a command `cider-eval-current-sexp` to evaluate the form around point (bound to `C-c C-v`).

### Changes

Expand Down
8 changes: 8 additions & 0 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,14 @@ If invoked with a PREFIX argument, print the result in the current buffer."
(backward-kill-sexp)
(cider-interactive-eval last-sexp (cider-eval-print-handler))))

(defun cider-eval-current-sexp (&optional prefix)
"Evaluate the expression around point.
If invoked with a PREFIX argument, print the result in the current buffer."
(interactive "P")
(save-excursion
(up-list)
(cider-eval-last-sexp prefix)))

(defun cider-eval-defun-to-comment (loc)
"Evaluate the \"top-level\" form and insert result as comment at LOC.
Expand Down
2 changes: 2 additions & 0 deletions cider-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ Configure `cider-cljs-lein-repl' to change the ClojureScript REPL to use."]
(defconst cider-mode-eval-menu
'("CIDER Eval" :visible cider-connections
["Eval top-level sexp" cider-eval-defun-at-point]
["Eval current sexp" cider-eval-current-sexp]
["Eval last sexp" cider-eval-last-sexp]
["Eval selected region" cider-eval-region]
["Eval ns form" cider-eval-ns-form]
Expand Down Expand Up @@ -287,6 +288,7 @@ Configure `cider-cljs-lein-repl' to change the ClojureScript REPL to use."]
(define-key map (kbd "C-x C-e") #'cider-eval-last-sexp)
(define-key map (kbd "C-c C-e") #'cider-eval-last-sexp)
(define-key map (kbd "C-c C-w") #'cider-eval-last-sexp-and-replace)
(define-key map (kbd "C-c C-v") #'cider-eval-current-sexp)
(define-key map (kbd "C-c M-;") #'cider-eval-defun-to-comment)
(define-key map (kbd "C-c M-e") #'cider-eval-last-sexp-to-repl)
(define-key map (kbd "C-c M-p") #'cider-insert-last-sexp-in-repl)
Expand Down
1 change: 1 addition & 0 deletions doc/interactive_programming.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Here's a list of `cider-mode`'s keybindings:
<kbd>C-c C-p</kbd> | Evaluate the form preceding point and pretty-print the result in a popup buffer.
<kbd>C-c C-f</kbd> | Evaluate the top level form under point and pretty-print the result in a popup buffer.
<kbd>C-M-x</kbd> <br/> <kbd>C-c C-c</kbd> | Evaluate the top level form under point and display the result in the echo area.
<kbd>C-c C-v</kbd> | Evaluate the form around point.
<kbd>C-u C-M-x</kbd> <br/> <kbd>C-u C-c C-c</kbd> | Debug the top level form under point and walk through its evaluation
<kbd>C-c C-r</kbd> | Evaluate the region and display the result in the echo area.
<kbd>C-c C-b</kbd> | Interrupt any pending evaluations.
Expand Down

0 comments on commit 26bb282

Please sign in to comment.