Skip to content

Commit 78c66cd

Browse files
committed
Use *cider-read-eval* buffer for cider-read-and-eval error locations
- On errors in `cider-read-and-eval` don't jump to non-existent locations but create a buffer with relevant ns-form and evaled expression - Truly use `cider-minibuffer-history` in `cider-read-from-minibuffer`
1 parent ab782ba commit 78c66cd

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

cider-interaction.el

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
(require 'apropos)
5050

5151
(defconst cider-error-buffer "*cider-error*")
52+
(defconst cider-read-eval-buffer "*cider-read-eval*")
5253
(defconst cider-doc-buffer "*cider-doc*")
5354
(defconst cider-result-buffer "*cider-result*")
5455
(defconst cider-apropos-buffer "*cider-apropos*")
@@ -419,7 +420,6 @@ Returns to the buffer in which the command was invoked."
419420
(cider-repl-clear-buffer)
420421
(switch-to-buffer origin-buffer)))
421422

422-
;;; Minibuffer eval
423423
(defvar cider-minibuffer-history '()
424424
"History list of expressions read from the minibuffer.")
425425

@@ -442,12 +442,7 @@ reading input."
442442
(run-hooks 'eval-expression-minibuffer-setup-hook))
443443
(read-from-minibuffer prompt initial-value
444444
cider-minibuffer-map nil
445-
cider-minibuffer-history)))
446-
447-
(defun cider-read-and-eval ()
448-
"Read a sexp from the minibuffer and output its result to the echo area."
449-
(interactive)
450-
(cider-interactive-eval (cider-read-from-minibuffer "CIDER Eval: ")))
445+
'cider-minibuffer-history)))
451446

452447

453448
;;; Utilities
@@ -1334,6 +1329,19 @@ With a PREFIX argument, print the result in the current buffer."
13341329
(goto-char (match-beginning 0))
13351330
(cider-eval-defun-at-point))))
13361331

1332+
(defun cider-read-and-eval ()
1333+
"Read a sexp from the minibuffer and output its result to the echo area."
1334+
(interactive)
1335+
(let* ((form (cider-read-from-minibuffer "CIDER Eval: "))
1336+
(ns-form (if (cider-ns-form-p form) "" (cider-ns-form))))
1337+
(with-current-buffer (get-buffer-create cider-read-eval-buffer)
1338+
(erase-buffer)
1339+
(clojure-mode)
1340+
(insert ns-form "\n")
1341+
(let ((start-pos (point)))
1342+
(insert form)
1343+
(cider-interactive-eval form start-pos)))))
1344+
13371345

13381346
;; Connection and REPL
13391347

0 commit comments

Comments
 (0)