Fork me on GitHub
#cider
<
2021-04-28
>
Alexis Vincent00:04:46

@bozhidar Any chance I can get you to weigh in on ^

Matti Uusitalo05:04:39

Some problem with eval defun functionality. In some namespaces I can’t properly do repl based development as CIDER doesn’t seem to “see” anything I have declared and loaded already. Evaling the buffer works fine, but as soon as I eval region or defun, it doesn’t see things in the same namespace. I turned nrepl logging on and I see for the working one

(-->
  id                             "28"
  op                             "eval"
  session                        "375f7ae0-c60a-417a-a9d8-cc4b9e442d65"
  time-stamp                     "2021-04-28 08:09:47.045094000"
  code                           "(defn oracle-db-config [config]
  (if
    (common.env/dev-mo..."
  column                         1
  file                           "/Users/matti.uusitalo/projektit/allu/valvira-allu-konversio/..."
  line                           28
  nrepl.middleware.print/print   "cider.nrepl.pprint/pr"
  nrepl.middleware.print/quota   1048576
  nrepl.middleware.print/stream? nil
  ns                             #("konversio.db" 0 12 (fontified t help-echo cider--help-echo cider-locals nil cider-block-dynamic-font-lock t face font-lock-type-face))
)
but for the ones not working I get
(-->
  id                             "30"
  op                             "eval"
  session                        "375f7ae0-c60a-417a-a9d8-cc4b9e442d65"
  time-stamp                     "2021-04-28 08:10:12.564574000"
  code                           "(defn next-lupanumero [target-db used-numbers licence-type]
  (loop [candidate nil]
    (if-not (or (nil? candidate) (used-numbers candidate))
      candidate
      (recur
       (format
        \"%s%06d\"
        licence-type
        (:nextval (db/query target-db (format \"SELECT nextval('rekisteri.licence-number-%s\" licence-type))))))))
"
  column                         1
  file                           "/Users/matti.uusitalo/projektit/allu/valvira-allu-konversio/..."
  line                           15
  nrepl.middleware.print/print   "cider.nrepl.pprint/pr"
  nrepl.middleware.print/quota   1048576
  nrepl.middleware.print/stream? nil
  ns                             "user"
)
So it looks like it doesn’t understand the namespace correctly, as the ‘ns’ identifier points to “user” in the non-working namespace. The files are both in the same project and folder. What could cause CIDER to get confused about the namespace like this?

Matti Uusitalo05:04:06

(cider-current-ns) seems to return the wrong namespace for the non working ones. It returns “user”

Matti Uusitalo05:04:48

I figured this out. I had a space before the ns declaration. Cider doesn’t find the namespace declaration in that case

Matti Uusitalo05:04:15

My apologies. I misinterpreted it to being cider-related. I was navigating the code in Emacs and didn’t realize i’d switched to a different package. I reported an issue about it to Cider repo yesterday. https://github.com/clojure-emacs/cider/issues/3009 I just close the issue then. Sorry for extra hassle.