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

Colorized source #15

Closed
venantius opened this issue Feb 5, 2015 · 6 comments
Closed

Colorized source #15

venantius opened this issue Feb 5, 2015 · 6 comments
Assignees
Milestone

Comments

@venantius
Copy link
Owner

At the moment the source function just does a general pretty-print, giving us the following:

screen shot 2015-02-04 at 4 19 05 pm

This should be patched to provide a syntax-highlighted printing of the source in question.

@venantius
Copy link
Owner Author

As a status update on this feature - as of Ultra 0.2.1 this function now exists as ultra.repl/pprint-source.

screen shot 2015-02-21 at 7 16 32 pm

I was initially reluctant to replace clojure.repl/source with this, as the syntax highlighting requires the use of (read-string), which can be used to execute unsafe code.

However, since pprint-source would require you to already have the given code in your classpath, I'm having second thoughts. Might have to obtain a second opinion. @keithballinger, do you have any thoughts on this?

@venantius venantius self-assigned this Mar 3, 2015
@venantius venantius modified the milestone: Ultra 0.3.4 Mar 4, 2015
@venantius
Copy link
Owner Author

Looks like I can get what I want here out of using clojure/tools.reader, which has a safe read-string implementation that I can use to swap in to replace the default read-string of clojure.core

@venantius
Copy link
Owner Author

Also I should use with-out-str for this s.t. we don't get the extra nil printed at the end.

@venantius venantius added the REPL label Mar 15, 2015
@venantius
Copy link
Owner Author

I'm still not super happy with how this function currently handles macros. I think I've figured out a way around it but I haven't actually tested it yet.

@venantius
Copy link
Owner Author

I'm going to leave this alone for a while. I've poked at it many times now and I think that while it's okay as it currently sits, the only "true" solution takes a radically different approach and instead delivers syntax highlighting rather than pretty-printing through fipp/puget/whidbey et al. This has two advantages: first, it avoids the (potentially unsafe) use of read-string, and second it keeps the output relatively clean (i.e., doesn't macroexpand the source in question).

@venantius venantius modified the milestone: Ultra 0.3.4 Jul 7, 2015
@venantius venantius added this to the Ultra 0.4.0 milestone Aug 1, 2015
venantius added a commit that referenced this issue Aug 1, 2015
This commit leverages my latest creation, Glow, which has yet to be
formally released. Suffice it to say that it modifies
`clojure.repl/source` to actually rely on a syntax highlighting engine
rather than Fipp/Whidbey/Puget, which print highlighted Clojure data
structures.

Actually figuring out how to bind the contents of ultra.repl/source to
clojure.repl/source was something of a pain in the neck, and I'm not
totally sure this will end up being the final approach, but it works
well enough for me.

Resolves #15
@venantius
Copy link
Owner Author

screen shot 2015-08-01 at 12 14 02 pm

If you don't think this looks dope as hell I claim you are smoking the crack rocks.

@venantius venantius mentioned this issue Aug 27, 2015
venantius added a commit that referenced this issue Nov 1, 2015
This commit leverages my latest creation, Glow, which has yet to be
formally released. Suffice it to say that it modifies
`clojure.repl/source` to actually rely on a syntax highlighting engine
rather than Fipp/Whidbey/Puget, which print highlighted Clojure data
structures.

Actually figuring out how to bind the contents of ultra.repl/source to
clojure.repl/source was something of a pain in the neck, and I'm not
totally sure this will end up being the final approach, but it works
well enough for me.

Resolves #15
venantius added a commit that referenced this issue Nov 3, 2015
This commit leverages my latest creation, Glow, which has yet to be
formally released. Suffice it to say that it modifies
`clojure.repl/source` to actually rely on a syntax highlighting engine
rather than Fipp/Whidbey/Puget, which print highlighted Clojure data
structures.

Actually figuring out how to bind the contents of ultra.repl/source to
clojure.repl/source was something of a pain in the neck, and I'm not
totally sure this will end up being the final approach, but it works
well enough for me.

Resolves #15
@venantius venantius mentioned this issue Nov 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant