Skip to content

Commit c9200d6

Browse files
yuhan0bbatsov
authored andcommitted
Use eval overlay bounds in cider-eval-in-context
1 parent fef392b commit c9200d6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cider-eval.el

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,9 +1033,10 @@ by extracting all parent let bindings."
10331033
(setq res (concat (buffer-substring-no-properties beg end) ", " res)))))
10341034
(scan-error res)))))
10351035

1036-
(defun cider--eval-in-context (code &optional guess)
1037-
"Evaluate CODE in user-provided evaluation context."
1038-
(let* ((code (string-trim-right code))
1036+
(defun cider--eval-in-context (bounds &optional guess)
1037+
"Evaluate code at BOUNDS in user-provided evaluation context."
1038+
(let* ((code (string-trim-right
1039+
(buffer-substring-no-properties (car bounds) (cadr bounds))))
10391040
(eval-context
10401041
(minibuffer-with-setup-hook (when guess #'beginning-of-buffer)
10411042
(read-string "Evaluation context (let-style): "
@@ -1045,7 +1046,7 @@ by extracting all parent let bindings."
10451046
(setq-local cider-previous-eval-context eval-context)
10461047
(cider-interactive-eval code
10471048
nil
1048-
nil
1049+
bounds
10491050
(cider--nrepl-pr-request-map))))
10501051

10511052
(defun cider-eval-last-sexp-in-context (guess)
@@ -1056,7 +1057,7 @@ The context is remembered between command invocations.
10561057
When GUESS is non-nil, or called interactively with \\[universal-argument],
10571058
attempt to guess the context from parent let bindings."
10581059
(interactive "P")
1059-
(cider--eval-in-context (cider-last-sexp) guess))
1060+
(cider--eval-in-context (cider-last-sexp 'bounds) guess))
10601061

10611062
(defun cider-eval-sexp-at-point-in-context (guess)
10621063
"Evaluate the sexp around point in user-supplied context.
@@ -1067,7 +1068,7 @@ The context is remembered between command invocations.
10671068
When GUESS is non-nil, or called interactively with \\[universal-argument],
10681069
attempt to guess the context from parent let bindings."
10691070
(interactive "P")
1070-
(cider--eval-in-context (cider-sexp-at-point) guess))
1071+
(cider--eval-in-context (cider-sexp-at-point 'bounds) guess))
10711072

10721073
(defun cider-eval-defun-to-comment (&optional insert-before)
10731074
"Evaluate the \"top-level\" form and insert result as comment.

0 commit comments

Comments
 (0)