emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/cider 90561f1ce4 1/4: Add evaluate and tap commands for la


From: ELPA Syncer
Subject: [nongnu] elpa/cider 90561f1ce4 1/4: Add evaluate and tap commands for last-sexp and sexp-at-point (#3240)
Date: Wed, 24 Aug 2022 02:58:18 -0400 (EDT)

branch: elpa/cider
commit 90561f1ce426a142a89bbe72fb89aab756ffe2b4
Author: Sebastian Andersen <sebastian@skjoenberg.com>
Commit: GitHub <noreply@github.com>

    Add evaluate and tap commands for last-sexp and sexp-at-point (#3240)
---
 CHANGELOG.md                                      |  1 +
 cider-eval.el                                     | 23 +++++++++++++++++++++++
 cider-mode.el                                     |  2 ++
 doc/modules/ROOT/pages/usage/code_evaluation.adoc | 10 ++++++++++
 4 files changed, 36 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 370639f26b..64ad8a4b99 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@
 - [#2946](https://github.com/clojure-emacs/cider/issues/2946): Add custom var 
`cider-merge-sessions` to allow combining sessions in two different ways: 
Setting `cider-merge-sessions` to `'host` will merge all sessions associated 
with the same host within a project. Setting it to `'project` will combine all 
sessions of a project irrespective of their host.
 - Support Gradle jack-in via the Gradle wrapper (`gradlew`), instead of just a 
globally installed `gradle` on the `PATH`.
 - Gradle projects can now inject dependencies and middleware as with other 
build tools (dependency injection requires 
[Clojurephant](https://github.com/clojurephant/clojurephant) 0.7.0 or higher).
+- [#3239](https://github.com/clojure-emacs/cider/issues/3239): Added commands 
to evaluate and tap last sexp and sexp at point.
 
 ## Changes
 
diff --git a/cider-eval.el b/cider-eval.el
index ff14730134..6e1fd4440e 100644
--- a/cider-eval.el
+++ b/cider-eval.el
@@ -1016,6 +1016,25 @@ If invoked with OUTPUT-TO-CURRENT-BUFFER, output the 
result to current buffer."
     (goto-char (cadr (cider-sexp-at-point 'bounds)))
     (cider-eval-last-sexp output-to-current-buffer)))
 
+(defun cider-tap-last-sexp (&optional output-to-current-buffer)
+  "Evaluate and tap the expression preceding point.
+If invoked with OUTPUT-TO-CURRENT-BUFFER, print the result in the current
+buffer."
+  (interactive "P")
+  (let ((tapped-form (concat "(clojure.core/doto " (cider-last-sexp) " 
(clojure.core/tap>))")))
+    (cider-interactive-eval tapped-form
+                            (when output-to-current-buffer 
(cider-eval-print-handler))
+                            nil
+                            (cider--nrepl-pr-request-map))))
+
+(defun cider-tap-sexp-at-point (&optional output-to-current-buffer)
+  "Evaluate and tap the expression around point.
+If invoked with OUTPUT-TO-CURRENT-BUFFER, output the result to current buffer."
+  (interactive "P")
+  (save-excursion
+    (goto-char (cadr (cider-sexp-at-point 'bounds)))
+    (cider-tap-last-sexp output-to-current-buffer)))
+
 (defvar-local cider-previous-eval-context nil
   "The previous evaluation context if any.
 That's set by commands like `cider-eval-last-sexp-in-context'.")
@@ -1422,8 +1441,10 @@ passing arguments."
     (define-key map (kbd "n") #'cider-eval-ns-form)
     (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)
     (define-key map (kbd "l") #'cider-eval-list-at-point)
     (define-key map (kbd "v") #'cider-eval-sexp-at-point)
+    (define-key map (kbd "t") #'cider-tap-sexp-at-point)
     (define-key map (kbd "o") #'cider-eval-sexp-up-to-point)
     (define-key map (kbd ".") #'cider-read-and-eval-defun-at-point)
     (define-key map (kbd "z") #'cider-eval-defun-up-to-point)
@@ -1438,8 +1459,10 @@ passing arguments."
     (define-key map (kbd "C-n") #'cider-eval-ns-form)
     (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)
     (define-key map (kbd "C-l") #'cider-eval-list-at-point)
     (define-key map (kbd "C-v") #'cider-eval-sexp-at-point)
+    (define-key map (kbd "C-t") #'cider-tap-sexp-at-point)
     (define-key map (kbd "C-o") #'cider-eval-sexp-up-to-point)
     (define-key map (kbd "C-.") #'cider-read-and-eval-defun-at-point)
     (define-key map (kbd "C-z") #'cider-eval-defun-up-to-point)
diff --git a/cider-mode.el b/cider-mode.el
index d8c8f34ba4..5888d79086 100644
--- a/cider-mode.el
+++ b/cider-mode.el
@@ -320,10 +320,12 @@ If invoked with a prefix ARG eval the expression after 
inserting it."
     "--"
     ["Eval current list" cider-eval-list-at-point]
     ["Eval current sexp" cider-eval-sexp-at-point]
+    ["Eval and tap current sexp" cider-tap-sexp-at-point]
     ["Eval current sexp to point" cider-eval-sexp-up-to-point]
     ["Eval current sexp in context" cider-eval-sexp-at-point-in-context]
     "--"
     ["Eval last sexp" cider-eval-last-sexp]
+    ["Eval and tap last sexp" cider-tap-last-sexp]
     ["Eval last sexp in context" cider-eval-last-sexp-in-context]
     ["Eval last sexp and insert" cider-eval-print-last-sexp
      :keys "\\[universal-argument] \\[cider-eval-last-sexp]"]
diff --git a/doc/modules/ROOT/pages/usage/code_evaluation.adoc 
b/doc/modules/ROOT/pages/usage/code_evaluation.adoc
index be20bf0f57..b67929cbb2 100644
--- a/doc/modules/ROOT/pages/usage/code_evaluation.adoc
+++ b/doc/modules/ROOT/pages/usage/code_evaluation.adoc
@@ -382,6 +382,11 @@ Below is a listing of most keybindings for evaluation 
commands:
 kbd:[C-c C-e]
 | Evaluate the form preceding point and display the result in the echo area 
and/or in an buffer overlay (according to `cider-use-overlays`).  If invoked 
with a prefix argument, insert the result into the current buffer.
 
+| `cider-tap-last-sexp`
+| kbd:[C-c C-v q] +
+kbd:[C-c C-v C-q]
+| Like `cider-eval-last-sexp` but also taps the result.
+
 | `cider-eval-last-sexp-and-replace`
 | kbd:[C-c C-v w]
 | Evaluate the form preceding point and replace it with its result.
@@ -423,6 +428,11 @@ kbd:[C-c C-v C-v]
 kbd:[C-u C-c C-c]
 | Debug the top level form under point and walk through its evaluation
 
+| `cider-tap-sexp-at-point`
+| kbd:[C-c C-v t] +
+kbd:[C-c C-v C-t]
+| Evaluate and tap the form around point.
+
 | `cider-eval-defun-up-to-point`
 | kbd:[C-c C-v z]
 | Evaluate the preceding top-level form up to the point.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]