Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Change Log
All notable changes to this project will be documented in this file.

## 1.2.5 - 2022-08-03

### Added

### Changed

### Fixed

## 1.2.4 - 2022-08-02

### Added
Expand Down
2 changes: 1 addition & 1 deletion appcds
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ helptext="Usage: ./appcds zprint-filter output-command-name"

if [[ -z "$1" ]]
then
echo "Missing first required argument: zprint-filter-file (e.g. zprint-filter-1.2.4)"
echo "Missing first required argument: zprint-filter-file (e.g. zprint-filter-1.2.5)"
echo "$helptext"
exit 1
fi
Expand Down
74 changes: 49 additions & 25 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -1,25 +1,49 @@
{:paths ["src"]
:deps {org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}
:tasks {test:bb {:extra-paths ["test"]
:extra-deps {com.github.seancorfield/expectations
{:mvn/version "2.0.143"}
io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "b3fd0d2"}
org.clojure/tools.namespace {:git/url "https://github.com/babashka/tools.namespace"
:git/sha "3625153ee66dfcec2ba600851b5b2cbdab8fae6c"}
cljc.java-time {:mvn/version "0.1.11"}}
:requires ([cognitect.test-runner :as tr])
:task (apply tr/-main
"-d" "test"
"-n" "zprint.core-test"
"-n" "zprint.config-test"
"-n" "zprint.zprint-test"
"-n" "zprint.finish-test"
"-n" "zprint.guide-test"
"-n" "zprint.main-test"
"-n" "zprint.range-test"
"-n" "zprint.rewrite-test"
"-n" "zprint.spec-test"
"-n" "zprint.zutil-test"
*command-line-args*)}}}
{:deps {org.babashka/spec.alpha
{:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78",
:git/url "https://github.com/babashka/spec.alpha"}},
:paths ["src"],
:tasks
{test:bb {:extra-deps
{cljc.java-time/cljc.java-time {:mvn/version "0.1.11"},
com.github.seancorfield/expectations {:mvn/version "2.0.143"},
io.github.cognitect-labs/test-runner {:git/sha "b3fd0d2",
:git/tag "v0.5.0"},
org.clojure/tools.namespace
{:git/sha "3625153ee66dfcec2ba600851b5b2cbdab8fae6c",
:git/url "https://github.com/babashka/tools.namespace"}},
:extra-paths ["test"],
:requires ([cognitect.test-runner :as tr]),
:task (apply tr/-main
"-d"
"test" "-n"
"zprint.core-test" "-n"
"zprint.config-test" "-n"
"zprint.zprint-test" "-n"
"zprint.finish-test" "-n"
"zprint.guide-test" "-n"
"zprint.main-test" "-n"
"zprint.range-test" "-n"
"zprint.rewrite-test" "-n"
"zprint.spec-test" "-n"
"zprint.zutil-test" *command-line-args*)},
testconfig:bb
{:extra-deps {cljc.java-time/cljc.java-time {:mvn/version "0.1.11"},
com.github.seancorfield/expectations {:mvn/version
"2.0.143"},
io.github.cognitect-labs/test-runner {:git/sha "b3fd0d2",
:git/tag "v0.5.0"},

; pjstadig/humane-test-output {:mvn/version "0.11.0"
; :exclusions [org.clojure/tools.namespace]}},


lambdaisland/ansi {:mvn/version "0.2.37"}
org.clojure/tools.namespace
{:git/sha "3625153ee66dfcec2ba600851b5b2cbdab8fae6c",
:git/url "https://github.com/babashka/tools.namespace"}},
:extra-paths ["test"],
:requires ([cognitect.test-runner :as tr]),
:task
(tr/-main "-d" "test" "-n" "zprint.test-config")}}}


27 changes: 18 additions & 9 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,31 @@
:extra-paths ["src" "test" "cljs-test-runner-out/gen"],
:main-opts ["-m" "cljs-test-runner.main" "--doo-opts"
"dooopts.edn" "-x" "planck"]},
:cljtest {:extra-deps {com.github.seancorfield/expectations
{:mvn/version "2.0.143"}},
:cljtest {:extra-deps {com.github.seancorfield/expectations {:mvn/version
"2.0.143"}},
:extra-paths ["test"]},
:humane {:extra-deps {pjstadig/humane-test-output {:mvn/version "0.10.0"}}},
:runner {:extra-deps {com.cognitect/test-runner
{:git/url
"https://github.com/cognitect-labs/test-runner",
:sha "b6b3193fcc42659d7e46ecd1884a228993441182"}},
:main-opts ["-m" "cognitect.test-runner" "-d" "test"]},
;:runner {:extra-deps {com.cognitect/test-runner
; {:git/url
; "https://github.com/cognitect-labs/test-runner",
; :sha "b6b3193fcc42659d7e46ecd1884a228993441182"}},
; :main-opts ["-m" "cognitect.test-runner" "-d" "test"]},
:test {:exec-fn cognitect.test-runner.api/test,
:extra-deps {com.github.seancorfield/expectations {:mvn/version
"2.0.143"},
io.github.cognitect-labs/test-runner
{:sha "dfb30dd", #_"a85b3b0", :git/tag "v0.5.1"},
pjstadig/humane-test-output {:mvn/version "0.10.0"}},
:extra-paths ["test"],
:main-opts ["-m" "cognitect.test-runner"]},
:zprint {:main-opts ["-m" "zprint.main"]}},
:deps {#_#_org.clojure/clojure {:mvn/version "1.9.0"},
#_#_org.clojure/clojurescript {:mvn/version "1.9.946"},
#_#_org.clojure/clojure {:mvn/version "1.10.3"},
org.babashka/sci {:mvn/version "0.3.4"},
;; To use zprint with babashka, include the following dependency:
;; org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
;; :sha "0dec1f88cbde74a0470b454396f09a03adb4ae39"}
;; org.babashka/spec.alpha {:git/url
;; "https://github.com/babashka/spec.alpha"
;; :sha "0dec1f88cbde74a0470b454396f09a03adb4ae39"}
rewrite-clj/rewrite-clj {:mvn/version "1.1.45"}},
:paths ["src" "test" "cljs-test-runner-out/gen"]}
2 changes: 1 addition & 1 deletion doc/getting/appcds.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ zprint-filter in about a second.
## 5. Try it with `-v`
```
% zprint -v
zprint-1.2.4
zprint-1.2.5
```
This will also demonstrate the time it takes to start up the uberjar
with appcds.
Expand Down
4 changes: 2 additions & 2 deletions doc/getting/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ You may wish to name it something different so that any scripts that
you have will use the new version without requiring a change. We
will assume that you have renamed it `zprint`.
```
mv zprintl-1.2.4 zprint
mv zprintl-1.2.5 zprint
```

Note that you can always find the version of zprintl (no matter what
you called it), by giving it the -v switch:
```
./zprint -v
zprint-1.2.4
zprint-1.2.5
```

## 3. Put zprint into a directory in your path
Expand Down
2 changes: 1 addition & 1 deletion doc/getting/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ you have will use the new version without requiring a change. We
will assume that you have renamed it `zprint`.

```
mv zprintm-1.2.4 zprint
mv zprintm-1.2.5 zprint
```

Note that you might *not* want to name it `zprint`, since there is also
Expand Down
4 changes: 2 additions & 2 deletions doc/getting/uberjar.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ You may wish to name it something different so that any scripts that
you have will use the new version without requiring a change. We
will assume that you have renamed it `zprint-filter`.
```
mv zprint-filter-1.2.4 zprint-filter
mv zprint-filter-1.2.5 zprint-filter
```

Note that you can always find the version of zprint-filter (no matter what
you called it), by giving it the -v switch:
```
java -jar zprint-filter -v
zprint-1.2.4
zprint-1.2.5
```

## 3. Test it with `-e`
Expand Down
76 changes: 75 additions & 1 deletion doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1274,9 +1274,15 @@ are formatted by default. Note that the `:indent` for lists is not
changed by this function type. You may find it useful to set the
`:indent` for `:list` to 1 when using this function type.

```clojure {:fn-map {"my-fn" [:wrap {:list {:indent 1}}]}}
```clojure
{:fn-map {"my-fn" [:wrap {:list {:indent 1}}]}}
```

When using this function type, you may find it useful to use
`{:list {:no-wrap-after #{"stuff"}}}` where `stuff` is some element you
don't want to ever be the last element on a line. See `:list :no-wrap-after`
for more details.

#### :gt2-force-nl and :gt3-force-nl

These two function styles exist to be assigned to functions that should
Expand Down Expand Up @@ -3787,6 +3793,37 @@ formatting in some special cases where a `fn-type` is in use`.
It isn't meant to be a generally useful capabiity to, say,
format all lists with extra lines between them.

`:list` supports some of the same keys as does vector:

##### :no-wrap-after _nil_
##### :wrap? _true_
##### :wrap-coll? _true_
##### :wrap-after-multi? _true_

See the section on :vector for information on these keys. A simple example:

```
(czprint i252d {:parse-string? true})
(stuff example
vvvvvveeeeeeeerrrrrrryyyyy
looooooooooooonnnnggggg
paraaaaaaams
&
body)

(czprint i252d {:parse-string? true :list {:wrap? true}})
(stuff example vvvvvveeeeeeeerrrrrrryyyyy looooooooooooonnnnggggg paraaaaaaams &
body)

(czprint i252d {:parse-string? true :list {:wrap? true :no-wrap-after #{"&"}}})
(stuff example vvvvvveeeeeeeerrrrrrryyyyy looooooooooooonnnnggggg paraaaaaaams
& body)
```

Generally, `&` isn't something with special meaning in a list, but there
may be something else that you wish to not dangle as the last element on
a line when a list is being wrapped.

_____
## :map

Expand Down Expand Up @@ -4950,6 +4987,7 @@ _____
`:set` supports the same keys as does vector and a few more.

##### :indent _1_
##### :no-wrap-after _nil_
##### :wrap? _true_
##### :wrap-coll? _true_
##### :wrap-after-multi? _true_
Expand Down Expand Up @@ -6194,6 +6232,42 @@ printed?
"key" "value"}
10 11 12 13 14 15 16 17 18 19
```

#### :no-wrap-after _nil_

There are times when you might like two elements that appear in a
vector that is wrapping to not be separated by the line break. For
instance, this is not great:

```
(czprint i252a {:parse-string? true :width 79})
(defn example
[vvvvvveeeeeeeerrrrrrryyyyy looooooooooooooooooonnnnggggg paraaaaaaams &
body]
(+ 1 2 3))
```

You can prevent vectors from wrapping between `&` and whatever comes
immediately after by configuring `:no-wrap-after`, which is a set
that contains strings. For instance:

```
(czprint i252a {:parse-string? true :width 79 :vector {:no-wrap-after #{"&"}}})
(defn example
[vvvvvveeeeeeeerrrrrrryyyyy looooooooooooooooooonnnnggggg paraaaaaaams
& body]
(+ 1 2 3))
```

will solve this particular problem.

It would make sense to simply configure `{:vector {:no-wrap-after #{"&"}}}`
globally, since it probably wouldn't affect anything but
the argument vectors of functions, and in the event that `&` appeared
by itself in a vector, the worst that would happen is that the `&`
would end up on the next line if it was right at the end of the
previous line, which you might not even notice.

_____
## :vector-fn

Expand Down
24 changes: 12 additions & 12 deletions doc/using/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ The exit status is unchanged by any of these additional switches:
For example:

```
% ./zprintm-1.2.4 -lfsc src/zprint/*.cljc
% ./zprintm-1.2.5 -lfsc src/zprint/*.cljc
Processing file src/zprint/ansi.cljc
Processing file src/zprint/config.cljc
Formatting required in file src/zprint/config.cljc
Expand Down Expand Up @@ -113,7 +113,7 @@ Here is another example, using the same files, where the formatting
width is changed to 90:

```
% ./zprintm-1.2.4 '{:width 90}' -lfsc src/zprint/*.cljc
% ./zprintm-1.2.5 '{:width 90}' -lfsc src/zprint/*.cljc
Processing file src/zprint/ansi.cljc
Processing file src/zprint/config.cljc
Formatting required in file src/zprint/config.cljc
Expand Down Expand Up @@ -162,8 +162,8 @@ zprint -h
is your friend!

```
% ./zprintm-1.2.4 -h
zprint-1.2.4
% ./zprintm-1.2.5 -h
zprint-1.2.5

zprint <options-map> <input-file >output-file
zprint <switches> <input-file >output-file
Expand All @@ -173,9 +173,9 @@ zprint-1.2.4

Where zprint is any of:

zprintm-1.2.4
zprintl-1.2.4
java -jar zprint-filter-1.2.4
zprintm-1.2.5
zprintl-1.2.5
java -jar zprint-filter-1.2.5

<options-map> is a Clojure map containing zprint options. Must be first.
Note that since it contains spaces, it must be
Expand Down Expand Up @@ -279,10 +279,10 @@ $ cat > deps.edn <<< $'
{org.clojure/clojure
{:mvn/version "1.9.0"},
zprint {:mvn/version
"1.2.4"}},
"1.2.5"}},
:main-opts ["-m" "zprint.main"]}},
:deps {org.clojure/clojure {:mvn/version "1.9.0"},
zprint {:mvn/version "1.2.4"}}}'
zprint {:mvn/version "1.2.5"}}}'
$ clj -A:zprint < deps.edn
$ clj -m zprint.main <deps.edn
```
Expand All @@ -299,7 +299,7 @@ the high performance prebuilt binaries -- #1, above) the
startup much faster and run as fast once it has started.

## 4. Lein zprint
* Leiningen plugin: `[lein-zprint "1.2.4.1"]`
* Leiningen plugin: `[lein-zprint "1.2.5"]`
* Accepts configuration from `:zprint` key in project.clj
* Will (optionally) replace existing source files with reformatted versions
* Reads configuration from `~/.zprintrc`
Expand All @@ -312,7 +312,7 @@ lein zprint '{:width 90}' src/myproj/*.clj
Processing file: src/myproj/myfile.clj
Processing file: src/myproj/myotherfile.clj
```
__Get it__: put `[lein-zprint "1.2.4.1"]` in the vector that is the value of
__Get it__: put `[lein-zprint "1.2.5"]` in the vector that is the value of
the `:plugins` key in `project.clj`:

```clojure
Expand All @@ -321,7 +321,7 @@ the `:plugins` key in `project.clj`:
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:plugins [[lein-zprint "1.2.4.1"]]
:plugins [[lein-zprint "1.2.5"]]
:dependencies [[org.clojure/clojure "1.10.0"]]
:repl-options {:init-ns zpuse.core})
```
Expand Down
4 changes: 2 additions & 2 deletions doc/using/library.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ in the dependencies. For example:
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.0"]
[zprint "1.2.4"]]
[zprint "1.2.5"]]
:repl-options {:init-ns zpuse.core})
```
#### deps.edn
```clojure
{:deps {org.clojure/clojure {:mvn/version "1.9.0"},
zprint {:mvn/version "1.2.4"}}}
zprint {:mvn/version "1.2.5"}}}
```
## 2. Require zprint in your ns directive:
```clojure
Expand Down
Loading