[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/cider 33baff8d13 1/2: Introduce `cider-eval-dwim`
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/cider 33baff8d13 1/2: Introduce `cider-eval-dwim` |
Date: |
Sat, 7 Oct 2023 03:59:59 -0400 (EDT) |
branch: elpa/cider
commit 33baff8d131fe2c3f8dbf21854182ed5a33415e8
Author: samhedin <samhedin@users.noreply.github.com>
Commit: vemv <vemv@users.noreply.github.com>
Introduce `cider-eval-dwim`
Closes https://github.com/clojure-emacs/cider/pull/3496
---
CHANGELOG.md | 17 ++++++++++-------
cider-eval.el | 13 +++++++++++++
cider-mode.el | 1 +
cider-util.el | 1 +
doc/modules/ROOT/pages/usage/cider_mode.adoc | 5 +++++
5 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3fec80839e..0ffa103e47 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,18 +4,21 @@
### New features
+- [#3364](https://github.com/clojure-emacs/cider/pull/3364): Update
enrich-classpath, adding Clojure CLI compatibility, and reworking its
integration into CIDER.
+ * It will be progressively refined and
[documented](https://docs.cider.mx/cider/config/basic_config.html#use-enrich-classpath),
please consider this alpha software.
+- [#3472](https://github.com/clojure-emacs/cider/pull/3472): render Java doc
comments and arglists with an improved format, and improve Java interop type
inference.
+ * Requires enrich-classpath to be enabled (see previous bullet point).
- [#3352](https://github.com/clojure-emacs/cider/pull/3352) Add CIDER Log
Mode, a major mode that allows you to capture, debug, inspect and view log
events emitted by Java logging frameworks.
-- `cider-test`: add timing information.
-- `cider-test`: fail-fast by default, as controlled by the new
`cider-test-fail-fast` defcustom and `cider-test-toggle-fail-fast` keybinding.
-- Infer indentation specs when possible
([doc](https://docs.cider.mx/cider/indent_spec.html#indentation-inference)).
- [#3418](https://github.com/clojure-emacs/cider/issues/3418): Introduce
`cider-clojure-compilation-error-phases`.
- This prevents stacktraces from showing up whenever the
[:clojure.error/phase](https://clojure.org/reference/repl_and_main#_at_repl)
indicates that it's a compilation error.
-- Add new customization variable `cider-clojurec-eval-destination` to allow
specifying which REPL CLJC evals are sent to.
-- [#3354](https://github.com/clojure-emacs/cider/issues/3354): Add new
customization variable `cider-reuse-dead-repls` to control how dead REPL
buffers are reused on new connections.
-- [#3364](https://github.com/clojure-emacs/cider/pull/3364): Update
enrich-classpath, adding Clojure CLI compatibility, and reworking its
integration into CIDER.
- * It will be progressively refined and documented, please consider this
alpha software.
+- Infer indentation specs when possible
([doc](https://docs.cider.mx/cider/indent_spec.html#indentation-inference)).
- [#2958](https://github.com/clojure-emacs/cider/issues/2958),
[#3279](https://github.com/clojure-emacs/cider/issues/3279):
`cider-test-run-test`: support arbitrary deftest-like forms, defns with :test
metadata, and search for a `-test` counterpart for a given defn (following
`cider-test-infer-test-ns` logic).
- This also makes obsolete the `cider-test-defining-forms` customization
variable.
+- `cider-test`: add timing information.
+- `cider-test`: fail-fast by default, as controlled by the new
`cider-test-fail-fast` defcustom and `cider-test-toggle-fail-fast` keybinding.
+- [#3352](https://github.com/clojure-emacs/cider/pull/3496) Introduce
[`cider-eval-dwim`](https://docs.cider.mx/cider/usage/cider_mode.html#key-reference).
+- Add new customization variable `cider-clojurec-eval-destination` to allow
specifying which REPL CLJC evals are sent to.
+- [#3354](https://github.com/clojure-emacs/cider/issues/3354): Add new
customization variable `cider-reuse-dead-repls` to control how dead REPL
buffers are reused on new connections.
### Bugs fixed
diff --git a/cider-eval.el b/cider-eval.el
index 511d4182bf..adbe94a513 100644
--- a/cider-eval.el
+++ b/cider-eval.el
@@ -1361,6 +1361,17 @@ buffer, else display in a popup buffer."
'help-echo "Breakpoint. Reevaluate this form to remove it."
:type 'cider-fragile))))
+(defun cider-eval-dwim (&optional debug-it)
+ "If no region is active, call `cider-eval-defun-at-point' with DEBUG-IT.
+If a region is active, run `cider-eval-region'.
+
+Always binds `clojure-toplevel-inside-comment-form' to t."
+ (interactive "P")
+ (let ((clojure-toplevel-inside-comment-form t))
+ (if (use-region-p)
+ (cider-eval-region (region-beginning) (region-end))
+ (cider-eval-defun-at-point debug-it))))
+
(defun cider-eval-defun-at-point (&optional debug-it)
"Evaluate the current toplevel form, and print result in the minibuffer.
With DEBUG-IT prefix argument, also debug the entire form as with the
@@ -1543,6 +1554,7 @@ passing arguments."
(define-key map (kbd "w") #'cider-eval-last-sexp-and-replace)
(define-key map (kbd "r") #'cider-eval-region)
(define-key map (kbd "n") #'cider-eval-ns-form)
+ (define-key map (kbd "s") #'cider-eval-dwim)
(define-key map (kbd "d") #'cider-eval-defun-at-point)
(define-key map (kbd "e") #'cider-eval-last-sexp)
(define-key map (kbd "q") #'cider-tap-last-sexp)
@@ -1561,6 +1573,7 @@ passing arguments."
(define-key map (kbd "C-w") #'cider-eval-last-sexp-and-replace)
(define-key map (kbd "C-r") #'cider-eval-region)
(define-key map (kbd "C-n") #'cider-eval-ns-form)
+ (define-key map (kbd "C-s") #'cider-eval-dwim)
(define-key map (kbd "C-d") #'cider-eval-defun-at-point)
(define-key map (kbd "C-e") #'cider-eval-last-sexp)
(define-key map (kbd "C-q") #'cider-tap-last-sexp)
diff --git a/cider-mode.el b/cider-mode.el
index 96ff6ebe0c..b23442cb7d 100644
--- a/cider-mode.el
+++ b/cider-mode.el
@@ -338,6 +338,7 @@ If invoked with a prefix ARG eval the expression after
inserting it."
["Eval last sexp and pretty-print to REPL"
cider-pprint-eval-last-sexp-to-repl]
["Eval last sexp and pretty-print to comment"
cider-pprint-eval-last-sexp-to-comment]
"--"
+ ["Eval selected region if active, otherwise top-level sexp"
cider-eval-dwim]
["Eval selected region" cider-eval-region]
["Eval ns form" cider-eval-ns-form]
"--"
diff --git a/cider-util.el b/cider-util.el
index 4ec1c8fb4f..df532596f3 100644
--- a/cider-util.el
+++ b/cider-util.el
@@ -734,6 +734,7 @@ through a stack of help buffers. Variables
`help-back-label' and
"Press <\\[cider-apropos]> to look for a symbol by some search string."
"Press <\\[cider-apropos-documentation]> to look for a symbol that has
some string in its docstring."
"Press <\\[cider-eval-defun-at-point]> to eval the top-level form at
point."
+ "Press <\\[cider-eval-dwim]> to eval to run cider-eval-region if a region
is active, and cider-eval-defun-at-point otherwise."
"Press <\\[cider-eval-defun-up-to-point]> to eval the top-level form up to
the point."
"Press <\\[cider-eval-sexp-up-to-point]> to eval the current form up to
the point."
"Press <\\[cider-eval-sexp-at-point]> to eval the current form around the
point."
diff --git a/doc/modules/ROOT/pages/usage/cider_mode.adoc
b/doc/modules/ROOT/pages/usage/cider_mode.adoc
index 38d5803571..2e6c58b50e 100644
--- a/doc/modules/ROOT/pages/usage/cider_mode.adoc
+++ b/doc/modules/ROOT/pages/usage/cider_mode.adoc
@@ -86,6 +86,11 @@ kbd:[C-c C-e]
kbd:[C-c C-c]
| Evaluate the top level form under point and display the result in the echo
area.
+| `cider-eval-dwim`
+| kbd:[C-c C-v s] +
+kbd:[C-c C-v C-s]
+| If no region is active, eval the toplevel form with
cider-eval-defun-at-point. If a region is active, run cider-eval-region
+
| `cider-eval-list-at-point`
| kbd:[C-c C-v l] +
kbd:[C-c C-v C-l]