Skip to content

Commit

Permalink
Fix issues #33 and #34, focus and comment wrapping and inline comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkinnear committed Oct 27, 2017
1 parent 1d63dd1 commit 139e3ab
Show file tree
Hide file tree
Showing 17 changed files with 361 additions and 326 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
# Change Log
All notable changes to this project will be documented in this file.

## 0.4.4 - 2017-10-26

### Changed

* Added :color? boolean to options map, which will allow you to select
color (or not) regardless of whether or not you use czprint or zprint.

* Added `deftest` and `defexpect` as `:arg1-body` functions in the
`fn-map`.


### Fixed

* Added inline-comment support, on by default. Controlled by {:comment
{:inline? true}}. They will also be wrapped. Issue #33.

* Fixed problem with focus interacting badly with comment wrapping,
where a wrapped comment would change the path for later elements
if it wrapped. Now wrapping is performed after all focus operations
are completed.

## 0.4.3 - 2017-10-10

### Changed
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ before and after that single expression.
By default, zprint expects an s-expression and will format it. If
you specify `:parse-string-all? true` in an options map, then the
first argument must be a string, and zprint will parse the string
and format the output. It will accept multiple expression in the
and format the output. It will accept multiple expressions in the
string, and will parse and format each expression independently.
It will drop all whitespace between the expressions (and before the
first expression), and will by default separate each expression
Expand Down Expand Up @@ -1886,10 +1886,18 @@ Wrap a comment if it doesn't fit within the width. Works hard to preserve
the initial part of the line and word wraps the end. Does not pull
subsequent lines up on to a wrapped line.

#### :inline? <text style="color:#A4A4A4;"><small>true</small></text>

If the a comment is on the same line as some code, keep the comment
on that same line. The distance from the code is preserved (since we
don't really have any better idea yet). If the comment extends beyond the
width, it will be wrapped just like a comment which is on its own line.

#### :count? <text style="color:#A4A4A4;"><small>false</small></text>

Count the length of the comment when ensuring that things fit within the
width. Tends to mess up the code more than helping, in my view.
width. Doesn't play well with inline comments. With any kinds of comments,
this tends to mess up the code more than helping, in my view.

An example (using :parse-string? true to include the comment):

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-0.4.3)"
echo "Missing first required argument: zprint-filter-file (e.g. zprint-filter-0.4.4)"
echo "$helptext"
exit 1
fi
Expand Down
18 changes: 9 additions & 9 deletions doc/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ You can use a script released along with the zprint-filter uberjar
to create another script which will run the zprint-filter in a way
that it will startup in less than a second.

1. Download `zprint-filter-0.4.3` from [releases](https://github.com/kkinnear/zprint/releases/latest)
1. Download `zprint-filter-0.4.4` from [releases](https://github.com/kkinnear/zprint/releases/latest)

2. Download the install script `appcds` from [releases](https://github.com/kkinnear/zprint/releases/latest)

Expand All @@ -222,7 +222,7 @@ that it will startup in less than a second.
6. Run the install script:

```
./appcds zprint-filter-0.4.3 za
./appcds zprint-filter-0.4.4 za
```
It will run pretty quickly when it works, and will spit out
less than a page of status and statistics. When it completes,
Expand Down Expand Up @@ -256,13 +256,13 @@ Here are the steps to set this version up manually:
```
java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:off \
-XX:DumpLoadedClassList=zprint.filter.classlist \
-cp zprint-filter-0.4.3 \
-cp zprint-filter-0.4.4 \
zprint.main < helloworld.clj > /dev/null
```
or, for easier copying and pasting:

```
java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:off -XX:DumpLoadedClassList=zprint.filter.classlist -cp zprint-filter-0.4.3 zprint.main < helloworld.clj > /dev/null
java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:off -XX:DumpLoadedClassList=zprint.filter.classlist -cp zprint-filter-0.4.4 zprint.main < helloworld.clj > /dev/null
```

5. Build the cache now that you have the list of classes used -- type this
Expand All @@ -273,14 +273,14 @@ Here are the steps to set this version up manually:
java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:dump \
-XX:SharedClassListFile=zprint.filter.classlist \
-XX:SharedArchiveFile=`pwd`/zprint.filter.cache \
-cp `pwd`/zprint-filter-0.4.3 \
-cp `pwd`/zprint-filter-0.4.4 \
zprint.main < helloworld.clj
```

or, for easier copying and pasting:

```
java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:dump -XX:SharedClassListFile=zprint.filter.classlist -XX:SharedArchiveFile=`pwd`/zprint.filter.cache -cp `pwd`/zprint-filter-0.4.3 zprint.main < helloworld.clj
java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:dump -XX:SharedClassListFile=zprint.filter.classlist -XX:SharedArchiveFile=`pwd`/zprint.filter.cache -cp `pwd`/zprint-filter-0.4.4 zprint.main < helloworld.clj
```

This will output a bunch of statistics about building the cache.
Expand All @@ -291,12 +291,12 @@ Here are the steps to set this version up manually:
```
java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:on \
-XX:SharedArchiveFile=`pwd`/zprint.filter.cache \
-cp `pwd`/zprint-filter-0.4.3 zprint.main
-cp `pwd`/zprint-filter-0.4.4 zprint.main
```
or, for easier copying and pasting:

```
java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:on -XX:SharedArchiveFile=`pwd`/zprint.filter.cache -cp `pwd`/zprint-filter-0.4.3 zprint.main
java -XX:+UnlockCommercialFeatures -XX:+UseAppCDS -Xshare:on -XX:SharedArchiveFile=`pwd`/zprint.filter.cache -cp `pwd`/zprint-filter-0.4.4 zprint.main
```

7. Make that file executable:
Expand Down Expand Up @@ -358,7 +358,7 @@ and about 10% faster than the bootclasspath approach, described above.
containing the following single line:

```
java -Xbootclasspath/a:`pwd`/zprint-filter-0.4.3 zprint.main
java -Xbootclasspath/a:`pwd`/zprint-filter-0.4.4 zprint.main
```

Note that the switch you are using is: `-Xbootclasspath/a:`, and
Expand Down
9 changes: 5 additions & 4 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
;!zprint {:vector {:wrap? false}}
(defproject zprint "0.4.3"
(defproject zprint "0.4.4"
:description "Pretty print zippers and s-expressions"
:url "https://github.com/kkinnear/zprint"
:license {:name "MIT License",
:url "https://opensource.org/licenses/MIT",
:key "mit",
:year 2015}
:plugins [[lein-expectations "0.0.8"] [lein-zprint "0.3.3"]]
:profiles {:dev {:dependencies [[expectations "2.0.16"]
:profiles {:dev {:dependencies [#_[expectations "2.0.16"]
[expectations "2.2.0-rc1"]
[com.taoensso/tufte "1.1.1"]
[clojure-future-spec "1.9.0-alpha17"]
]},
Expand All @@ -17,14 +18,14 @@
:main zprint.main,
:dependencies [[clojure-future-spec "1.9.0-alpha17"]],
:omit-source true,
:uberjar-name "zprint-filter-0.4.3"}}
:uberjar-name "zprint-filter-0.4.4"}}
; Clojure 1.8 you can exclude all sources in the uberjar
:uberjar-exclusions [#"\.(clj|java|cljs)"]
; Clojure 1.9 requires the .clj files in the uberjar
; :uberjar-exclusions [#"\.(java|cljs)"]
:zprint {:old? false}
:dependencies
[#_[org.clojure/clojure "1.9.0-beta2"]
[#_[org.clojure/clojure "1.9.0-beta3"]
[org.clojure/clojure "1.8.0"]
[rewrite-cljs "0.4.4" :exclusions [[org.clojure/clojurescript]]]
[rewrite-clj "0.6.0" :exclusions [[com.cemerick/austin]]]
Expand Down
31 changes: 28 additions & 3 deletions src/zprint/config.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
;; # Program Version
;;

(defn about "Return version of this program." [] (str "zprint-0.4.3"))
(defn about "Return version of this program." [] (str "zprint-0.4.4"))

;;
;; # External Configuration
Expand Down Expand Up @@ -282,13 +282,15 @@
"condp" :arg2-pair,
"def" :arg1-body,
"defmacro" :arg1-body,
"defexpect" :arg1-body,
"defmethod" :arg2,
"defmulti" :arg1-body,
"defn" :arg1-body,
"defn-" :arg1-body,
"defproject" :arg2-pair,
"defprotocol" :arg1-force-nl,
"defrecord" :arg2-extend,
"deftest" :arg1-body,
"deftype" :arg2-extend,
"defui" :arg1-extend,
"do" :none-body,
Expand Down Expand Up @@ -358,6 +360,7 @@
:justify-tuning {:hang-flow 4, :hang-flow-limit 30},
:justify? false,
:nl-separator? false},
:color? true,
:color-map {:brace :red,
:bracket :purple,
:comment :green,
Expand All @@ -375,7 +378,7 @@
:string :red,
:uneval :magenta,
:user-fn :black},
:comment {:count? false, :wrap? true},
:comment {:count? false, :wrap? true, :inline? true},
:configured? false,
:dbg-ge nil,
:dbg-print? nil,
Expand Down Expand Up @@ -555,6 +558,26 @@
:width 80,
:zipper? false})

;; Returns nil for all of the colors
(def no-color-map
{:brace :red,
:bracket :none,
:comment :none,
:deref :none,
:fn :none,
:hash-brace :none,
:hash-paren :none,
:keyword :none,
:nil :none,
:none :none,
:number :none,
:paren :none,
:syntax-quote-paren :none,
:quote :none,
:string :none,
:uneval :none,
:user-fn :none})

;;
;; # Mutable Options storage
;;
Expand Down Expand Up @@ -713,7 +736,9 @@
; is :key-order now nil and :key-value is not?
(and (nil? (:key-order (:reader-cond updated-map)))
(not (nil? (:key-value (:reader-cond updated-map)))))
(dissoc-two [:reader-cond :key-value])))
(dissoc-two [:reader-cond :key-value])
(not (:color? updated-map)) (assoc :color-map no-color-map)
(not (:color? updated-map)) (assoc-in [:uneval :color-map] no-color-map)))

(defn reset-options!
"Replace options to be used on every call. You must have validated
Expand Down
Loading

0 comments on commit 139e3ab

Please sign in to comment.