jira/patch welcome...
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this grou
Is there any way to make Clojure's pprint print the record tags for
records? It seems odd to me that Clojure's main printer has evolved
improved support for records over the years, but pprint still prints
records as a plain, untagged map.
--
You received this message because you are
the user who ventures into reading the edn file.
This is not for security, just to keep the edn file independent of
namespaces. The defrecord I'm printing has references to other defrecords,
which also have an abbreviated form for edn writing.
When print-dup is false, I just want pprint a
Cool library! But i just changed to fipp this morning. I think I will try
it much later. fipp is really fast that it succeeded clojure.pprint/write.
On Mon, Oct 24, 2016 at 4:36 PM Thomas Heller wrote:
> Try https://github.com/weavejester/cljfmt
>
> It is specifically written for clj code and no
Try https://github.com/weavejester/cljfmt
It is specifically written for clj code and not general pprinter.
/thomas
On Sunday, October 23, 2016 at 1:28:23 PM UTC+2, Jiyin Yiyong wrote:
>
> I'm using `write` function to generate code very heavily. But small part
> of the code are hard to read.
What does miser-width mean since you set it to 60?
On Mon, Oct 24, 2016 at 3:08 AM Alex Miller wrote:
> Try something like this:
>
> (require '[clojure.pprint :as pprint])
> (defn print-code [o]
> (binding [pprint/*print-right-margin* 100
> pprint
Try something like this:
(require '[clojure.pprint :as pprint])
(defn print-code [o]
(binding [pprint/*print-right-margin* 100
pprint/*print-miser-width* 60]
(pprint/with-pprint-dispatch pprint/code-dispatch
(pprint/pprint o
Or one of the "pretty printer&
I'm using `write` function to generate code very heavily. But small part of
the code are hard to read.
So I digged into the options and increased `right-margin` to make it a
little better. Here's the changes:
https://github.com/Cirru/sepal.clj/commit/e65e2d3cac8a5c5537716acd12cc475712ab6f66
htt
*Ultra: a Leiningen plugin for a superior development environment.*
Release 0.2.1 comes with two changes - one feature, one (major) bugfix.
*First, the feature: pprint-source*
Ultra now has a function for pretty-printing source at the REPL - like
`source`, but nice looking. At the moment it
Greg's is a nice and clean solution for the data visualization problem,
assuming you're only going to use partials.
I hacked together a solution to support functions with equality semantics,
if anyone is interested. It doesn't support anonymous functions or
closures, but doing that would requir
Simpler yet using metadata:
(ns example.ppfn)
(defn print-pf [pf]
(if-let [ppf (::ppf (meta pf))] ppf pf))
(defmacro partial* [& args]
`(let [m# (pr-str '(partial* ~@args))
pf# (with-meta (partial ~@args) {::ppf m#})]
(defmethod print-method (class pf#) [o# w#] (print-simple
(
havior.
I'm starting to think that I can just implement this with some macro magic
(i.e. fn*). I just need to figure out how to determine what symbols inside
an fn* body are arguments, and which are not (maybe using symbol
metadata?). After that, reify a class that is an AFunction but with
The code below accounts for partials of the same arity. However, there
might be a better way to do this with clojure.reflect:
(defn print-partial [a-fn]
(let [c (class a-fn)
fields (into {} (->> c .getDeclaredFields
(map #(vector (.getName %)
Got it. The macro, as is, will displace the print method for the same arity.
On Friday, April 25, 2014 2:50:34 PM UTC-7, Gary Trakhman wrote:
>
> Ah, I think I was mistaken in a detail, but generally correct. Try it
> with two partials of the same arity.
>
>
> https://github.com/clojure/clojure/
user> (def a (partial* + 1 2 3))
#'user/a
user> a
(partial + 1 2 3)
user> (def b (partial* + 1 2 5))
#'user/b
user> b
(partial + 1 2 5)
user> a
(partial + 1 2 5)
On Fri, Apr 25, 2014 at 5:51 PM, Greg D wrote:
> I guess I don't understand the problem, or what is meant by "all the
> return c
I guess I don't understand the problem, or what is meant by "all the return
classes of partial are the same class". A counter-example would be helpful.
Further transcript using the macro:
user=> (def p6 (partial* + 1 2 3))
#'user/p6
user=> (class p6)
clojure.core$partial$fn__4194
user=> (def p10
Ah, I think I was mistaken in a detail, but generally correct. Try it with
two partials of the same arity.
https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L2460
On Fri, Apr 25, 2014 at 5:47 PM, Greg D wrote:
> I guess I don't understand the problem, or what is meant by
I guess I don't understand the problem, or what is meant by "different
classes". A counter-example would be helpful.
Further transcript using the macro:
(def p6 (partial* + 1 2 3))
#'user/p6
user=> (class p6)
clojure.core$partial$fn__4194
user=> (def p10 (partial* + 1 2 3 4))
#'user/p10
user=> (
That's not going to work, all the return classes of partial are the same
class.
On Fri, Apr 25, 2014 at 5:26 PM, Greg D wrote:
> I don't know if this is considered good Clojure, but you could define a
> print-method within a macro to set up the normal string representation for
> the partial fun
I don't know if this is considered good Clojure, but you could define a
print-method within a macro to set up the normal string representation for
the partial function:
(defmacro partial* [fname arg0 & args]
`(let [pf# (partial ~fname ~arg0 ~@args)
cpf# (class pf#)]
(defmethod pr
On Friday, April 25, 2014 1:23:49 PM UTC-5, Matthew DeVore wrote:
>
> Thanks for pointing out the ticket, but based on the Description, it falls
> short of what I need. It doesn't have any additional information that I
> can't deduce from looking at the code, in other words, the value of the
>
Thanks for pointing out the ticket, but based on the Description, it falls
short of what I need. It doesn't have any additional information that I
can't deduce from looking at the code, in other words, the value of the
items in the closures. So while it makes toString prettier, it's not
informa
You might be interested in this ticket
(http://dev.clojure.org/jira/browse/CLJ-1278) of which this is perhaps one
special case.
I don't know that I necessarily would want the equality semantics; at least
in the case of impure functions the equality does not hold.
On Friday, April 25, 2014 11:
Hi,
There has been one thing bugging me for a long time that seems worth it to
fix, and I was wondering if anyone else has had the same problem. I have
enjoyed using Clojure's REPL and embracing a Clojure-style data model for
my app, where everything is a glorified map or vector and there are n
Most probably, your template is a lazy seq and pprint forces its
evaluation, which is why the error happens at the pprint point.
On 17 April 2013 08:33, Tassilo Horn wrote:
> larry google groups writes:
>
>> (println (pp/pprint template))
>
> Aside from the original probl
larry google groups writes:
> (println (pp/pprint template))
Aside from the original problem: pprint already prints to *out* and only
returns nil, so the code above first prints template, and then the
println will also print the nil returned from pprint.
Bye,
Tassilo
--
--
You recei
Oh, I see. I had just changed :admin-text to hold a keyword instead of
text. I should have seen that sooner.
But I am still confused why a keyword would cause pprint to throw an
exception. And why at that point in the code, and not sooner?
On Apr 16, 10:05 am, larry google groups
wrote
The function before the previously mentioned function is this:
(defn add-public-text-to-top-banner-and-return-as-new-template
[template item]
(println "entering add-public-text-to-top-banner-and-return-as-new-
template")
(println (pp/pprint template))
(enlive/transform template
On the first pprint expression in this function, I get an exception:
(defn add-main-image-for-this-item-and-return-as-new-template
[template item]
(println " start of add-main-image-for-this-item-and-return-as-new-
template")
(println (pp/pprint template))
(println "add-main
I have a function which at this point only amounts to a print line:
(defn add-rows-of-choices-for-a-given-type-and-return-new-template
[template item-type-as-string sequence-of-items]
(pp/pprint sequence-of-items)
;; (let [inner-template-of-rows-showing-options-for-this-type-of-item
Thanks for catching that - I didn't even notice that I was printing the binding
var itself… need coffee…
-FS.
On May 3, 2012, at 9:59 AM, Meikel Brandmeyer wrote:
> Hi,
>
> Am 03.05.2012 um 18:43 schrieb Frank Siebenlist:
>
>> user=> (pprint #'clojure.c
Hi again,
Am 03.05.2012 um 18:59 schrieb Meikel Brandmeyer:
> user=> (def f nil)
> #'user/f
> user=> (binding [*print-length* 32] (clojure.pprint/pprint f))
> nil
Of course I should have printed the Var.
user=> (binding [*print-length* 32] (clojure.pprint/pprint #&
Hi,
Am 03.05.2012 um 18:43 schrieb Frank Siebenlist:
> user=> (pprint #'clojure.core/*print-length*)
> #
> nil
> user=> (clj-ns-browser.utils/pprint-str #'clojure.core/*print-length*)
> "#\n"
> user=> (with-out-str (binding [*print-length* 32 *p
I'm using the following function to have pprint write into a string and limit
the output:
(defn pprint-str
"Return string with pprint of v, and limit output to prevent blowup."
[v]
(with-out-str (binding [*print-length* 32 *print-level* 6] (pprint v
Everything s
https://gist.github.com/1314616
On Tue, Oct 25, 2011 at 6:33 AM, Alasdair MacLeod
wrote:
> Hello,
>
> Are there any tutorials or examples of setting up pprint dispatch
> functions? I know the docs suggest looking at the source, but I find
> it a bit cryptic. In particular I wo
Hello,
Are there any tutorials or examples of setting up pprint dispatch
functions? I know the docs suggest looking at the source, but I find
it a bit cryptic. In particular I would like to see if it's possible
to dispatch on meta-data, record types or more arbitrary values in a
ma
Hmmm, looking back at the code, I see that I mis-remembered the fact
that lists and vectors were different. They both (along with maps)
will break rather than fill. Arrays and sets both fill rather than
break.
I'm not sure how much logic there is around this. It just fit my
intuition about how the
On Tue, Jul 19, 2011 at 12:03 AM, Tom Faulhaber wrote:
> Sean's remark is right for writing code, but not really relevant for
> pretty printed data structures. The pretty printer will either avoid
> "(foo a" followed by a line break or fill that line full. (By default,
> for lists it breaks the li
f85e/src/clj/clojure/pprint/dispatch.clj#L65
I have created a variant of simple dispatch that does the two
character indent (as per your example above). I through a little
project on github: https://github.com/tomfaulhaber/pprint-indent. The
README is basically a copy of your second example run in my
Okay. I see what you mean.
On Jul 16, 2011, at 8:39 PM, Sean Corfield wrote:
> On Sat, Jul 16, 2011 at 7:05 PM, Asim Jalis wrote:
>> The position of the braces might be a red herring here. I was mostly
>> interested in figuring out how to increase the indentation level from
>> 1 to something l
On Sat, Jul 16, 2011 at 7:05 PM, Asim Jalis wrote:
> The position of the braces might be a red herring here. I was mostly
> interested in figuring out how to increase the indentation level from
> 1 to something larger. Even an indentation step of 2 for each level
> would be easier on the eye than
:
> On Sat, Jul 16, 2011 at 12:46 PM, Asim Jalis wrote:
>> Is there an easy way to increase the indent of pprint data structures
>> from 1 to something like 2 or 4? I've been searching on Google and
>> going through the docs and don't see anything.
>>
>&
On Sat, Jul 16, 2011 at 12:46 PM, Asim Jalis wrote:
> Is there an easy way to increase the indent of pprint data structures
> from 1 to something like 2 or 4? I've been searching on Google and
> going through the docs and don't see anything.
>
> For example, I would like
Is there an easy way to increase the indent of pprint data structures
from 1 to something like 2 or 4? I've been searching on Google and
going through the docs and don't see anything.
For example, I would like the following command to produce something
closer to "output 2&quo
o them to make them behave like maps. How can I
> > get the clojure.pprint/pprint to pretty-print them like maps?
>
> A deftype can override toString like this:
>
> user=> (deftype Foo [n]
> java.lang.Object
> (toString [this] (str "Foo<" n ">&qu
On Wed, Jan 26, 2011 at 10:58 AM, Shantanu Kumar
wrote:
> Hi,
>
> I have created some 'deftype' objects and 'extend'ed
> clojure.lang.ILookup to them to make them behave like maps. How can I
> get the clojure.pprint/pprint to pretty-print them like maps?
A deft
Hi,
I have created some 'deftype' objects and 'extend'ed
clojure.lang.ILookup to them to make them behave like maps. How can I
get the clojure.pprint/pprint to pretty-print them like maps?
Regards,
Shantanu
--
You received this message because you are subscribed to the Go
trolled by dispatch functions that
in turn call functions in the underlying mechanism. There are four
examples you can look at to see how this works in Clojure: two
functions in clojure/contrib/pprint/dispatch.clj that implement the
standard "simple" dispatch and the specialized "code&quo
u if you're using the reader produced data
> for other stuff.
>
> On the other hand, it might be more useful to wrap the structure the
> you read in a container (or set of containers) that annotates it. A
> simple transform could then "extract" reader compatible versio
rap the structure the
you read in a container (or set of containers) that annotates it. A
simple transform could then "extract" reader compatible version if you
needed it.
> > One experiment I've been doing is to build an "Object Explorer" based
> > on pprint.
Hi Philip,
2009/7/1 philip.hazel...@gmail.com :
>
> On Jul 1, 9:52 am, Laurent PETIT wrote:
>> As far as IDE integration is concerned, i would not bother (at first)
>> about incremental thing. I rather intend to always parse the entire
>> edited file content (of course if this causes a performan
> consume the clojure data structures the reader passes to you ?
>
> pprint operates on clojure objects directly and doesn't really
> consider where they came from. It has no concept of parsing input at
> all. However, output is very flexible, being driven by user-definable
> di
On Jul 1, 9:52 am, Laurent PETIT wrote:
> As far as IDE integration is concerned, i would not bother (at first)
> about incremental thing. I rather intend to always parse the entire
> edited file content (of course if this causes a performance problem, I
> might rethink about it). For performance
Laurent,
Sounds like a good plan.
To answer your questions:
> I'll play with your code. Do you have a first pass over the clojure
> reader to attach other meta information as you go, or do you directly
> consume the clojure data structures the reader passes to you ?
pprint opera
Hi Tom,
Thanks for the answer. I already have some embryonic antlr grammar for
clojure, but I'm willing to give pprint a thourough try.
I'll play with your code. Do you have a first pass over the clojure
reader to attach other meta information as you go, or do you directly
consume t
Hi Laurent,
I think that pprint might be a good foundation for what you are doing,
but there are a couple of issues that need to be dealt with first.
First, pprint works directly on Clojure objects and not strings, so
the code will need to be read first.
Second, the Clojure reader is lossy
ndalone
command-line / whatever utility for mass source code reformatting ...
So what is my question ? :-)
Do you know if pprint lib now is (or will in a near future) be able to
handle this use case : that is not only formatting clojure code
returned by the reader, but also clojure code as str
57 matches
Mail list logo