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

:map :key-order request: #281

Closed riotrah closed 1 year ago

riotrah commented 1 year ago

Hey again,

I love to be able to sort maps. However, sometimes I want the inverse of :map {:key-order ...} - I want to specify which keys come last.

I propose two options:

  1. another option like :key-order-inverse or something
  2. a slightly modified api altogether:
    1. support more flexible ordering a la storybook's approach here (or at least a certain subset of it)
      1. like so: [:first :second "*" :penultimate :last]
      2. Where "*" is some special token or symbol of your choosing, string or otherwise
    2. this way, depending on your special token of choice, we can maintain compatibility, and still keep one :key-order config option

What do you think?

kkinnear commented 1 year ago

This seems like a reasonable request, and I like your idea of an extended API that maintains compatibility a lot. Thanks for bringing that up! I'm currently pressing to get the latest release finished up and out, but I will definitely add this to the list for the next release. I seems like a good idea!

kkinnear commented 1 year ago

Implemented this in the just released 1.2.6. Instead of your good suggestion of "*" as a token to separate beginning from ending keys, I decided to use :| instead. I hope this feature works out for you.

Thanks for asking for this feature. It has not been clear to me how many people use zprint at the REPL. It is nice to know somebody does!