Fork me on GitHub
#cider
<
2020-02-02
>
jhacks17:02:42

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]

jhacks16:02:42

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.