File tree 3 files changed +25
-0
lines changed
3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 8
8
* Add support for nREPL 0.8's ` lookup ` op.
9
9
* Add support for nREPL 0.7's sideloading functionality (experimental).
10
10
* Add support for nREPL 0.8's ` ls-middleware ` op.
11
+ * Add feature to evaluate list around point.
11
12
* [ #2861 ] ( https://github.com/clojure-emacs/cider/pull/2861 ) : Add support for the Krell REPL.
12
13
13
14
### Changes
Original file line number Diff line number Diff line change @@ -806,6 +806,16 @@ buffer."
806
806
nil
807
807
(cider--nrepl-pr-request-map))))
808
808
809
+ (defun cider-eval-list-at-point (&optional output-to-current-buffer )
810
+ " Evaluate the list (eg. a function call, surrounded by parens) around point.
811
+ If invoked with OUTPUT-TO-CURRENT-BUFFER, output the result to current buffer.
812
+ Special cases such as deref-ing a function call's results is also executed,
813
+ like in @(fn-that-returns-an-atom x)"
814
+ (interactive " P" )
815
+ (save-excursion
816
+ (goto-char (cadr (cider-list-at-point 'bounds )))
817
+ (cider-eval-last-sexp output-to-current-buffer)))
818
+
809
819
(defun cider-eval-sexp-at-point (&optional output-to-current-buffer )
810
820
" Evaluate the expression around point.
811
821
If invoked with OUTPUT-TO-CURRENT-BUFFER, output the result to current buffer."
Original file line number Diff line number Diff line change @@ -170,6 +170,20 @@ instead."
170
170
(funcall (if bounds #'list #'buffer-substring-no-properties )
171
171
(car b) (cdr b))))
172
172
173
+ (defun cider-list-at-point (&optional bounds )
174
+ " Return the list (compound form) at point as a string, otherwise nil.
175
+ If BOUNDS is non-nil, return a list of its starting and ending position
176
+ instead."
177
+ (when-let* ((b (or (and (equal (char-after ) ?\( )
178
+ (member (char-before ) '(?\' ?\, ?\@ ))
179
+ ; ; hide stuff before ( to avoid quirks with '( etc.
180
+ (save-restriction
181
+ (narrow-to-region (point ) (point-max ))
182
+ (bounds-of-thing-at-point 'list )))
183
+ (bounds-of-thing-at-point 'list ))))
184
+ (funcall (if bounds #'list #'buffer-substring-no-properties )
185
+ (car b) (cdr b))))
186
+
173
187
(defun cider-last-sexp (&optional bounds )
174
188
" Return the sexp preceding the point.
175
189
If BOUNDS is non-nil, return a list of its starting and ending position
You can’t perform that action at this time.
0 commit comments