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

Fix *print-right-margin* binding in wrap-pprint-fn #436

Merged
merged 1 commit into from
Aug 20, 2017

Conversation

vspinu
Copy link
Contributor

@vspinu vspinu commented Aug 20, 2017

None of the functionality currently relying on wrap-pprint-fn is pretty printing. The reason is that *print-right-margin* is always set to nil as @session is not binding it.

To reproduce

(throw (ex-info "blabla" {:some.ns/bablabla.bla "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                          :other.ns/bablabla.bla "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"}))

and you should see ex-info data printed in one long line within the stack trace.

@vspinu
Copy link
Contributor Author

vspinu commented Aug 20, 2017

A side question. Does anyone know how to reset nrepl handler? For some wrappers like wrap-pprint-fn most of the logic is inside the wrapper, so I need to restart cider session after each modification to that function.

@@ -66,7 +66,7 @@
(binding [*print-length* (or print-length (get @session #'*print-length*))
*print-level* (or print-level (get @session #'*print-level*))
*print-meta* (or print-meta (get @session #'*print-meta*))
*print-right-margin* (or print-right-margin (get @session #'*print-right-margin*))]
*print-right-margin* (or print-right-margin *print-right-margin*)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a remark here explaining the difference.

@bbatsov
Copy link
Member

bbatsov commented Aug 20, 2017

None of the functionality currently relying on wrap-pprint-fn is pretty printing. The reason is that print-right-margin is always set to nil as @session is not binding it.

Is this an nREPL bug then?

@vspinu
Copy link
Contributor Author

vspinu commented Aug 20, 2017

No, session is binding only a few essential things and current thread bindings returned by get-thread-bindings. *print-right-margin* is from pprint namespace.

Alternatively, bindings could be added when nrepl session is created but I don't think this should be the case here.

@bbatsov
Copy link
Member

bbatsov commented Aug 20, 2017

No, session is binding only a few essential things and current thread bindings returned by get-thread-bindings. print-right-margin is from pprint namespace.

Ah, I totally forgot about this.

Alternatively, bindings could be added when nrepl session is created but I don't think this should be the case here.

I think your current fix is all that's needed.

@bbatsov bbatsov merged commit 8765518 into clojure-emacs:master Aug 20, 2017
vspinu added a commit to vspinu/cider that referenced this pull request Aug 26, 2017
bbatsov pushed a commit to clojure-emacs/cider that referenced this pull request Aug 29, 2017
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

Successfully merging this pull request may close these issues.

2 participants