This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-02
Channels
- # announcements (1)
- # babashka (6)
- # beginners (53)
- # cider (2)
- # circleci (2)
- # clj-kondo (1)
- # cljdoc (1)
- # clojars (2)
- # clojure-berlin (1)
- # clojure-europe (23)
- # clojure-serbia (1)
- # clojure-spec (2)
- # clojure-uk (9)
- # clojurescript (12)
- # datomic (34)
- # emacs (1)
- # fulcro (46)
- # leiningen (15)
- # planck (3)
- # re-frame (46)
- # reitit (17)
- # remote-jobs (4)
- # shadow-cljs (17)
- # sql (3)
- # tools-deps (2)
Am I missing something or does *print-meta*
not work as intended in a cider repl? When *print-meta*
is true
, it only prints the metadata for vars. For example:
In a cider repl:
user> (set! *print-meta* true)
true
user> (with-meta [1 2 3] {:foo "bar"})
[1 2 3] ;; <--- MISSING METADATA
user> (def xs (with-meta [1 2 3] {:foo "bar"}))
^{:line 50, :column 7, :file "*cider-repl ~:localhost:59980(clj)*", :name xs, :ns #namespace[user]} #'user/xs
user> xs
[1 2 3] ;; <--- MISSING METADATA
user> #'xs
^{:line 50, :column 7, :file "*cider-repl ~:localhost:59980(clj)*", :name xs, :ns #namespace[user]} #'user/xs
In a bare $ lein repl
started from a shell, *print-meta*
works as expected:
user=> (set! *print-meta* true)
true
user=> (with-meta [1 2 3] {:foo "bar"})
^{:foo "bar"} [1 2 3]
user=> (def xs (with-meta [1 2 3] {:foo "bar"}))
^{:line 1, :column 1, :file "NO_SOURCE_PATH", :name xs, :ns #object[clojure.lang.Namespace 0x12bda6a "user"]} #'user/xs
user=> xs
^{:foo "bar"} [1 2 3]
After some digging, this issue appears to be due to a bug (https://clojure.atlassian.net/browse/CLJ-1445) in clojure.pprint/pprint
, which is the default pretty-printing function in CIDER.
According to https://docs.cider.mx/cider/usage/pretty_printing.html
> [Set cider-print-fn
to] nil
to defer to nREPL to choose the printing function. This will use the bound value of nrepl.middleware.print/*print-fn*
, which defaults to the equivalent of clojure.core/pr
.
After trying this setting in Emacs:
(setq cider-print-fn nil)
I got the same output as I did in the bare $ lein repl
, with proper printing
of the metadata.