Skip to content

Commit 5b5615e

Browse files
committed
[Fix #1088] Kill source-tracking evalution
This hack was a bad idea to begin with (and more importantly - it's no longer compatible with ClojureScript). This has to be fixed with either a custom nREPL middleware or in the built-in `eval` op. More details are available in the linked ticket.
1 parent 40b6964 commit 5b5615e

File tree

3 files changed

+9
-59
lines changed

3 files changed

+9
-59
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@
7070
* [#1031](https://github.com/clojure-emacs/cider/pull/1031): Interactive functions prompt with
7171
symbol at point as a default value.
7272
* Remapped `cider-grimoire` to <kbd>C-c C-d r</kbd> & <kbd>C-c C-d C-r</kbd>
73-
to avoid conflicts with <kbd>C-g</kbd>.
73+
to avoid conflicts with <kbd>C-g</kbd>.
74+
* [#1088](https://github.com/clojure-emacs/cider/issues/1088): Kill the
75+
source-tracking evaluation hack as it wasn't compatible with ClojureScript.
7476

7577
### Bugs fixed
7678

cider-debug.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ a number of keys will be prompted to the user."
144144
;; Once the code has been instrumented, it can be sent as a
145145
;; regular evaluation. Any debug messages will be received by the
146146
;; callback specified in `cider--debug-init-connection'.
147-
(cider-interactive-source-tracking-eval
148-
instrumented position
147+
(cider-interactive-eval
148+
instrumented
149149
(nrepl-make-response-handler (current-buffer)
150150
(lambda (_buffer value)
151151
(let ((cider-interactive-eval-result-prefix prefix))
152152
(cider--display-interactive-eval-result value)))
153-
;; Below is the default for `cider-interactive-source-tracking-eval'.
153+
;; Below is the default for `cider-interactive-eval'.
154154
(lambda (_buffer out)
155155
(cider-emit-interactive-eval-output out))
156156
(lambda (_buffer err)

cider-interaction.el

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,57 +1567,6 @@ otherwise fall back to \"user\"."
15671567
(defvar-local cider--cached-ns-form nil
15681568
"Cached ns form in the current buffer.")
15691569

1570-
(defun cider--ns-form-for-dummy-file (form)
1571-
"Construct a `(ns ...)` form for `cider--dummy-file-contents'.
1572-
1573-
If FORM is a ns form itself, or there is no current ns form, returns an
1574-
empty string. If the current ns form has not yet been evaluated, returns
1575-
the current ns form. Otherwise, returns the current ns form with
1576-
all :reload and :reload-all directives removed."
1577-
(let ((current-ns-form (cider-ns-form)))
1578-
(cond
1579-
((cider-ns-form-p form) "")
1580-
((null current-ns-form) "")
1581-
((null cider--cached-ns-form) current-ns-form)
1582-
;; previously, we were sending a truncated version of
1583-
;; the current ns form if it was equal to the cached ns
1584-
;; form, but this causes problems with ClojureScript,
1585-
;; where evaluating ns forms is not additive - see #1026
1586-
(:default (replace-regexp-in-string ":reload\\(-all\\)?\\>"
1587-
""
1588-
current-ns-form)))))
1589-
1590-
(defun cider--dummy-file-contents (form start-pos)
1591-
"Wrap FORM to make it suitable for `cider-request:load-file'.
1592-
START-POS is a starting position of the form in the original context."
1593-
(let* ((ns-form (cider--ns-form-for-dummy-file form))
1594-
(ns-form-lines (length (split-string ns-form "\n")))
1595-
(start-pos (or start-pos 1))
1596-
(start-line (line-number-at-pos start-pos))
1597-
(start-column (save-excursion (goto-char start-pos) (current-column))))
1598-
(concat
1599-
ns-form
1600-
(make-string (max 0 (- start-line ns-form-lines)) ?\n)
1601-
(make-string start-column ? )
1602-
form)))
1603-
1604-
(defun cider-interactive-source-tracking-eval (form &optional start-pos callback)
1605-
"Evaluate FORM and dispatch the response to CALLBACK.
1606-
START-POS is a starting position of the form in the original context.
1607-
Unlike `cider-interactive-eval' this command will set proper metadata for var
1608-
definitions. If CALLBACK
1609-
is nil use `cider-interactive-eval-handler'."
1610-
(cider--clear-compilation-highlights)
1611-
(cider--quit-error-window)
1612-
(setq cider--cached-ns-form (cider-ns-form))
1613-
(let ((filename (or (buffer-file-name)
1614-
(buffer-name))))
1615-
(cider-request:load-file
1616-
(cider--dummy-file-contents form start-pos)
1617-
(funcall cider-to-nrepl-filename-function (cider--server-filename filename))
1618-
(file-name-nondirectory filename)
1619-
(or callback (cider-interactive-eval-handler)))))
1620-
16211570
(defun cider--prep-interactive-eval (form)
16221571
"Prepares the environment for an interactive eval of FORM.
16231572
@@ -1668,7 +1617,7 @@ the printed result, and defaults to `fill-column'."
16681617
"Evaluate the region between START and END."
16691618
(interactive "r")
16701619
(let ((code (buffer-substring-no-properties start end)))
1671-
(cider-interactive-source-tracking-eval code start)))
1620+
(cider-interactive-eval code)))
16721621

16731622
(defun cider-eval-last-sexp (&optional prefix)
16741623
"Evaluate the expression preceding point.
@@ -1724,9 +1673,8 @@ the command `cider-debug-defun-at-point'."
17241673
(if debug-it
17251674
(progn (require 'cider-debug)
17261675
(cider-debug-defun-at-point))
1727-
(cider-interactive-source-tracking-eval
1728-
(cider-defun-at-point)
1729-
(cider-defun-at-point-start-pos))))
1676+
(cider-interactive-eval
1677+
(cider-defun-at-point))))
17301678

17311679
(defun cider-pprint-eval-defun-at-point ()
17321680
"Evaluate the top-level form at point and pprint its value in a popup buffer."

0 commit comments

Comments
 (0)