rep icon indicating copy to clipboard operation
rep copied to clipboard

pprint the result

Open genmeblog opened this issue 4 years ago • 2 comments

Is there the way to get formatted result?

Usually it's done with (set! nrepl.middleware.print/*print-fn* clojure.pprint/pprint).

I can prepend every call with this, but it's not too much usable.

$ rep "(set! nrepl.middleware.print/*print-fn* clojure.pprint/pprint)(def a 1)(def b 2)"
#function[clojure.pprint/pprint]

#'user/a

#'user/b

Or different variant - is there a way to get only result of the last call?

genmeblog avatar May 15 '20 21:05 genmeblog

First, you can get it to print only the last value by wrapping the expressions in a do.

You can format the output with the command-line zprint or something similar, if you can isolate the "value" from the "out" and "err" channels. I would rather add any features necessary for isolating those channels rather than add formatting into rep.

eraserhd avatar May 18 '20 13:05 eraserhd

Thanks. do option is not good solution for my use case. I use rep for dynamic document generation using knitr R package. However it came up that this is not a problem. The bigger issue is pretty print. I will check zprint - haven't realized that it had a standalone binary. Will check it if it fits my needs. My current solution is just call pprint function and removal of value from printed results.

Take a look how it works (knitr with rep): https://github.com/genmeblog/rmarkdown-clojure

genmeblog avatar May 18 '20 14:05 genmeblog