It has been a good long while since the last release, in large part because some of what appear to be small changes required significant rearchitecting of some of the internals. Thank you for your patience!
New and Changed:
- Several people have requested differing treatment of "trailing right" characters. Those are characters that terminate a collection
)]}, which also fall on their own line, either because of:respect-nlor because of a comment. Some have requested that these characters be indented to the indent of the structure involved. Others have requested that (unless required by a comment) they be brought up to the previous line so that they are not "trailing right" characters anymore. Both capabilties are now supported, the first by:indent-trailing-right?and the second by:collapse-trailing-right?, for lists, vectors, maps and sets. See the reference manual for details. - New style
:docstring-nlwhich will render any embedded newlines in docstrings in structures as actual newlines, not\n. This is only useful if you are using zprint as a library to format actual runtime Clojure lists whose first element isdefn. - The ability to locate and process multiple files directly. If you add the
{:files {:glob "<filespec>"}}key-value pair to the options map that appears on the command line of one of the pre-built zprint binaries or the uberjar, it will process all of the specified files. An example that will process all of the.cljand.cljcfiles in the current directory and all subdirectories would be{:files {:glob "**{.clj,.cljc}"}}. Note that the string which is the value of the:globkey is just a string, not a string value of a Clojure data structure. The:fileskey can not appear on a command line which also includes file specifications for the shell -- you must either specify files with the shell, or with the:fileskey, but not both! See the reference manual for additional details. - Addtional control over lifting namespaces. Prior to this change
:map {:lift-ns? ...}was soley boolean. It can now either be boolean or an integer. If it is an integer, the namespace will be lifted only if the number of keys is greater than the value of:lift-ns?. Thus, a value of1would be a reasonable value in many situations, as lifting a namespace from a single key looks pretty odd, but lifting namespaces from more than one key usually does not. - Documented new style
:meta-guide, which appeared several releases ago. Also deprecated style:meta-alt-- use:meta-guideinstead. - The capability
:wrap-multi?is now supported for:list,:vector, and:set. It is false by default, but if true will allow a multi-line collection to be added to a line which already contains elements. If it is false, then every multi-line collection will "flow" and always start on the next line (which is what has always happened prior to this release). See the reference manual for some examples. - Formatting for tagged-literals was completely reimplemented. This corrected many problems (not least that they were ignored when they appeared in Clojure data structures formatted by zprint as a library) and brought the implementation and configuration into line with the rest of zprint. Unfortunately, this also caused a change to the interpretation of the
:indentfor tagged-literals. Previously, the default was:indent 0, which would place the literal one space to the right of the#if it formatted onto the line below the tag. That same placement remains the default, but the configuration to generate that output is now:indent 1, which is an unfortunate but necessary change.
Fixed:
- Use of a "guide", which powers a few styles, could produce a deletion of code if the guide was generated from the
option-fnin:vector. The styles at risk are:hiccup,:keyword-respect-nl,:odr, and:require-pair. If those styles encounter an empty vector,[], code may be deleted. Also, option configurations returned as the answer to an Issue may rarely include guides for :vector. - In extremely rare situations with both styles
:respect-nland:ns-justifycode could be corrupted because a newline would be missing. - Even though
:style :respect-nlwas in use, newlines at the beginning of maps, binding vectors, and sets would sometimes be ignored. - The construct
~ @stuffwas being formatted as though it were~@stuff, which is very different. - In the event that
{:list {:indent n}}was configured with n = size-of-the-first-element-of-a-list + 1, a newline was added after the first element of the list. - When using
:style :sort-requireif the:requirewasn't the first element in the collection, zprint would loop forever. - Some incorrect indentation in vectors and lists when wrapping collections containing collections were fixed.
:no-wrap-afterhas been around for a while. This lets you specify an element where you would prefer the next element be on the same line. It has been completely re-implemented and now works well in many more situations. When specified, it also implies:wrap-multi? truefor the next element. Note that the element you specify for:no-wrap-aftershould be short and not a collection.- Style
:sort-requirewill fail and throw an exception in cases where there is an empty:refer []clause. - When using
:require-justifyor any related styles that justify things innsmacros, elements in the:requirethat were not just vectors or lists could affect the justification while not actually participating in the justification after all. - When using
cljto create a REPL, and testing with(set! *warn-on-reflection* true), some addtional issues appeared which were not flagged when usinglein replto create the REPL. These have been fixed.