To Leon's point above, that looks like:
12345678910111213
(require '[clojure.pprint :as pp])
(pp/with-pprint-dispatch pp/code-dispatch
(pp/pprint
(read-string "(defn foo [xs] (apply str (reverse (str (apply +
(for [y (filter (fn [x] (= x 1)) xs)] (inc y)))))))")))
=>
nil
(defn foo [xs]
(apply
str
(reverse
(str (apply + (for [y (filter (fn [x] (= x 1)) xs)] (inc y)))))))
On Thu, Apr 9, 2015 at 2:34 PM, Leon Grapenthin <[email protected]>
wrote:
> You can use
> https://clojure.github.io/clojure/clojure.pprint-api.html#clojure.pprint/with-pprint-dispatch
> with
> https://clojure.github.io/clojure/clojure.pprint-api.html#clojure.pprint/code-dispatch
> to achieve that.
>
> On Wednesday, April 8, 2015 at 8:14:02 PM UTC+2, Sven Richter wrote:
>>
>> Hi,
>>
>> @Tassilo Thank you. Your example works nicely the way I imagined it.
>>
>> However, I want to generate human readable code and I want line breaks
>> and nice formatting and things. I will also try a templating language.
>> lein-template uses moustache or something. I will see how that works out.
>>
>> Thanks everyone for your suggestions,
>> Sven
>>
>> Am Mittwoch, 8. April 2015 19:25:23 UTC+2 schrieb James Reeves:
>>>
>>> On 8 April 2015 at 14:20, Sven Richter <[email protected]> wrote:
>>>>
>>>> I want to create clojure source files with some code and a namespace
>>>> and everything else what is useful for some source code.
>>>> What I am looking for is a templating language for clojure code, is
>>>> there something like this already? What would be the most idiomatic way to
>>>> do that besides just writing strings into a file?
>>>>
>>>
>>> What's the purpose? If it's just to generate some Clojure code that will
>>> never be read by a human, then you can use Clojure's backtick syntax with
>>> the pr-str function. If it's to generate human-readable code, then you're
>>> probably best using a text templating language.
>>>
>>> You may also want to look at Leiningen templates or lein-generate.
>>>
>>> - James
>>>
>> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.