diff options
author | Bozhidar Batsov <bozhidar@batsov.com> | 2016-04-29 00:13:51 -0700 |
---|---|---|
committer | Bozhidar Batsov <bozhidar@batsov.com> | 2016-04-29 00:13:51 -0700 |
commit | 26bb28226136145e41e2eed65d33ed2772b4c5a3 (patch) | |
tree | 200cc053a7912ae2447eb6c83435d63a113e3c8b | |
parent | 3698fa0459ba2243d857f5d3f4d7bedf0d3f666d (diff) |
[Fix #1720] Add a command to evaluate the form around point
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | cider-interaction.el | 8 | ||||
-rw-r--r-- | cider-mode.el | 2 | ||||
-rw-r--r-- | doc/interactive_programming.md | 1 |
4 files changed, 12 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 252d603e..32611ce6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cider-interaction.el b/cider-interaction.el index 13388a20..c9b41622 100644 --- a/cider-interaction.el +++ b/cider-interaction.el @@ -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. diff --git a/cider-mode.el b/cider-mode.el index 0d1205df..d02c886a 100644 --- a/cider-mode.el +++ b/cider-mode.el @@ -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] @@ -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) diff --git a/doc/interactive_programming.md b/doc/interactive_programming.md index 862dafc4..1591601c 100644 --- a/doc/interactive_programming.md +++ b/doc/interactive_programming.md @@ -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. |