Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty-printing expressions yields nil *1, etc. #468

Closed
cemerick opened this issue Feb 4, 2014 · 3 comments
Closed

Pretty-printing expressions yields nil *1, etc. #468

cemerick opened this issue Feb 4, 2014 · 3 comments

Comments

@cemerick
Copy link
Contributor

cemerick commented Feb 4, 2014

My understanding is that cider implements pretty-printing in the REPL and elsewhere by wrapping the expression to be evaluated in an explicit clojure.pprint/pprint form (e.g. https://github.com/clojure-emacs/cider/blob/master/cider-repl.el#L554). Naturally, this leaves *1 holding nil, something I presume no one likes.

I'd like to suggest two options:

  1. Evaluate an interpolated expression like (let [x %s] (clojure.pprint/pprint x) x), which will leave *1 set properly. cider-repl-handler can then simply not do anything with :value, which will ensure that only one printed representation of the evaluated value is seen, e.g.:
(lambda (buffer value)
  (if (not cider-repl-use-pretty-printing)
    (cider-repl-emit-result buffer value t)))
  1. Alternatively (and perhaps as a more long-term solution), the standard pr-values middleware can be modified to provide a set!-able session-local configuration var so that clients/users can (a) set which function should generate the printed representation of :value, and (b) set which slot in the response message that representation should put in (since certain printed representations are likely not read-able, something that :value strings really should be).

I've tweaked my cider locally to do (1), and it works well. Would you like a patch for that?

Further, thoughts on the utility of (2) are welcome.

@bbatsov
Copy link
Member

bbatsov commented Feb 4, 2014

I'm aware of the current problem and I've been meaning to fix it for a while, but I've been pretty busy at work lately. I'd gladly accept a patch for (1).

Option (2) sounds great as well and something like your suggestion is definitely the way to go long-term. I'll have to think a bit more about the details, though.

cemerick added a commit to cemerick/nrepl.el that referenced this issue Feb 5, 2014
cemerick added a commit to cemerick/nrepl.el that referenced this issue Feb 5, 2014
@cemerick
Copy link
Contributor Author

cemerick commented Feb 5, 2014

PR sent for (1).

I'm happy to revisit this once (2) is done. That's the only (reasonable) way pretty-printing in ClojureScript REPLs is ever going to work AFAICT.

@bbatsov
Copy link
Member

bbatsov commented Feb 5, 2014

Btw, why can't pretty printing be implemented for ClojureScript? (I don't track its development)

@bbatsov bbatsov closed this as completed in ee0b0e0 Feb 5, 2014
bbatsov added a commit that referenced this issue Feb 5, 2014
Let *1 be set properly when pretty-printing, fixes gh-468
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants