Skip to content

Commit de23b4d

Browse files
committed
[Fix #1139] Correct the handling of ns forms and forms with unevaluted ns
Ns forms should always be evaluated in the "user" namespace. We have introduced a regression in 0.9.0 after which they started being evaluated in their own namespace, which doesn't exist originally. This commit also fixes a problem with the auto-evaluation of ns forms, when a form from their ns gets evaluated before the ns form.
1 parent 11859d1 commit de23b4d

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## master (unreleased)
44

5+
### Bugs fixed
6+
7+
* [#1139](https://github.com/clojure-emacs/cider/issues/1139): Fix evaluation of ns forms and of forms with unevaluated namespaces.
8+
59
## 0.9.0 / 2015-06-16
610

711
### New features

cider-interaction.el

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,17 +1582,14 @@ evaluated (so that the ns containing FORM exists).
15821582
Clears any compilation highlights and kills the error window."
15831583
(cider--clear-compilation-highlights)
15841584
(cider--quit-error-window)
1585-
;; always eval ns forms in the user namespace
1586-
;; otherwise trying to eval ns form for the first time will produce an error
1587-
(let ((ns (if (cider-ns-form-p form)
1588-
"user"
1589-
(cider-current-ns)))
1590-
(cur-ns-form (cider-ns-form)))
1585+
(let ((cur-ns-form (cider-ns-form)))
15911586
(when (and cur-ns-form
15921587
(not (string= cur-ns-form cider--cached-ns-form))
1593-
(not (string= ns "user")))
1594-
(cider-eval-ns-form))
1595-
(setq cider--cached-ns-form cur-ns-form)))
1588+
(not (cider-ns-form-p form)))
1589+
;; this should probably be done synchronously
1590+
;; otherwise an errors in the ns form will go unnoticed
1591+
(cider-eval-ns-form)
1592+
(setq cider--cached-ns-form cur-ns-form))))
15961593

15971594
(defun cider-interactive-eval (form &optional callback)
15981595
"Evaluate FORM and dispatch the response to CALLBACK.
@@ -1603,7 +1600,9 @@ If CALLBACK is nil use `cider-interactive-eval-handler'."
16031600
(nrepl-request:eval
16041601
form
16051602
(or callback (cider-interactive-eval-handler))
1606-
(cider-current-ns)))
1603+
;; always eval ns forms in the user namespace
1604+
;; otherwise trying to eval ns form for the first time will produce an error
1605+
(if (cider-ns-form-p form) "user" (cider-current-ns))))
16071606

16081607
(defun cider-interactive-pprint-eval (form &optional callback right-margin)
16091608
"Evaluate FORM and dispatch the response to CALLBACK.
@@ -1614,7 +1613,9 @@ the printed result, and defaults to `fill-column'."
16141613
(nrepl-request:pprint-eval
16151614
form
16161615
(or callback (cider-interactive-eval-handler))
1617-
(cider-current-ns)
1616+
;; always eval ns forms in the user namespace
1617+
;; otherwise trying to eval ns form for the first time will produce an error
1618+
(if (cider-ns-form-p form) "user" (cider-current-ns))
16181619
nil
16191620
(or right-margin fill-column)))
16201621

0 commit comments

Comments
 (0)