kkinnear / zprint

Executables, uberjar, and library to beautifully format Clojure and Clojurescript source code and s-expressions.
MIT License
554 stars 47 forks source link

-> formatting #262

Closed NoahTheDuke closed 1 year ago

NoahTheDuke commented 2 years ago

https://github.com/kkinnear/zprint/blob/f9031d6762e3c7dc557baadc1e9d3a842944cb8c/src/zprint/config.cljc#L318-L323

Is there a reason -> is categorized as having a "body"? Given how it's used and how ->> is formatted, seems like it should be :noarg1 instead of :noarg1-body.

(->
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)

(->>
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
kkinnear commented 2 years ago

Hmmm. These are both "body" functions because the things in them are typically things that are executable statements of some sort instead of just "arguments". Not that I'm a big fan of the whole "indent differently because of arguments and body forms" thing, having done a lot of work in Lisp long before I met Clojure. All that notwithstanding, both of these forms are things that should be "body" forms as far as I can tell. If you don't think so, please elaborate on why. Thanks!

The difference between how -> and ->> are formatted appears to be a bug to me at this point. I can easily reproduce this, and I'll work on getting to the bottom of it. But I think that it is the ->> that is wrong given the current default configuration, not the ->.

Thanks for pointing this out!

kkinnear commented 2 years ago

Yes, the formatting for :force-nl-body was incorrectly handled in the code. It will be fixed in the next release (almost certainly 1.2.5). That is independent of whether or not these should (or should not be) "body" functions.

NoahTheDuke commented 2 years ago

Ah, excellent! Thank you.

kkinnear commented 1 year ago

This is fixed in 1.2.5