File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 88* Add support for nREPL 0.8's ` lookup ` op.
99* Add support for nREPL 0.7's sideloading functionality (experimental).
1010* Add support for nREPL 0.8's ` ls-middleware ` op.
11+ * Add feature to evaluate list around point.
1112* [ #2861 ] ( https://github.com/clojure-emacs/cider/pull/2861 ) : Add support for the Krell REPL.
1213
1314### Changes
Original file line number Diff line number Diff line change @@ -806,6 +806,16 @@ buffer."
806806 nil
807807 (cider--nrepl-pr-request-map))))
808808
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+
809819(defun cider-eval-sexp-at-point (&optional output-to-current-buffer )
810820 " Evaluate the expression around point.
811821If 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."
170170 (funcall (if bounds #'list #'buffer-substring-no-properties )
171171 (car b) (cdr b))))
172172
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+
173187(defun cider-last-sexp (&optional bounds )
174188 " Return the sexp preceding the point.
175189If 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