re-frame-10x icon indicating copy to clipboard operation
re-frame-10x copied to clipboard

Indentation not available for `fn-traced` forms

Open stumitchell opened this issue 5 years ago • 3 comments

The following code is not indented

(re-frame/reg-event-db
 ::let
 (fn-traced [db _]
   (let [a 10
         b (+ a 20)]
     (+ a b)
     db)))

image

stumitchell avatar Jun 09 '20 01:06 stumitchell

I'm 95% sure that that information isn't available in the macroexpansion, you only get the parsed s-expression data. I think you'd need to use a Clojure formatter to reformat this to something reasonable.

danielcompton avatar Jun 10 '20 01:06 danielcompton

@danielcompton Yes, understood. We created this issue to remind us that the reformatting is not working on this code. Perhaps because it is too simple. Anyway, more investigation needed.

Perhaps we should move to use a different (better?) code reformatter. For example, Calva uses cljfmt

mike-thompson-day8 avatar Jun 10 '20 01:06 mike-thompson-day8

I don't think cljfmt will break the lines for you given the data. I haven't investigated deeply, but possibly something like https://github.com/greglook/cljstyle or https://github.com/nedap/formatting-stack might be able to reform code from data.

danielcompton avatar Jun 10 '20 01:06 danielcompton

"Can't repro with the provided function. Zprint is working as intended on my local build. I checked on both 1.7.0 and 1.6.0.

It is interesting that you'd get this result, since we've been formatting this code with zprint since at least 2018. Zprint won't reproduce the exact linebreaks in your code, but it does format your example reasonably, spreading it over 4 lines.

Closing for now.

kimo-k avatar Jul 10 '23 12:07 kimo-k