Skip to content

Commit

Permalink
Final formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
kkinnear committed May 24, 2023
1 parent 59b1c12 commit 8f4217c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 49 deletions.
43 changes: 14 additions & 29 deletions src/zprint/comment.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@
(= tnloc :newline) (recur (left* nloc) spaces true)
(or (= tnloc :comment) (= tnloc :comment-inline))
; Two comments in a row don't have a newline showing
; between them, it is captured by the first comment.
; Sigh. Except now it isn't, as we split the newlines out.
; between them, it is captured by the first comment. Sigh.
; Except now it isn't, as we split the newlines out.
(do #_(prn "inlinecomment? found previous comment!")
; is it an inline comment?
(when (inlinecomment? nloc)
Expand Down Expand Up @@ -591,17 +591,7 @@
; and not yet in a group -- move on
(recur (inc idx) depth 0 0 0 0 out))
; we are already in a group, see if we should remain in it
(cond
#_#_(= what :whitespace)
(recur (inc idx)
depth
start-col
number-semis
current-spacing
0
out)

(or (= what :newline) (= what :indent))
(cond (or (= what :newline) (= what :indent))
(if (zero? nl-indent-count)
; This is our first newline or indent, we are still
; in the group.
Expand Down Expand Up @@ -1053,22 +1043,17 @@
#_(def fsw-in style-vec)
(let [start-col (style-loc-vec (or (:indent options) 0) style-vec)
style-vec (into [] style-vec)]


; This can cause bad interactions with :dbg stuff, since it calls zprint!
(dbg-s options
#{:smart-wrap :comment-group}
"fzprint-smart-wrap smart-wrap?"
smart-wrap?
"border:"
border
((:dzprint options) {} (map #(vector %1 %2 %3) (range) start-col style-vec))

)




; This can cause bad interactions with :dbg stuff, since it calls
; zprint!
(dbg-s options
#{:smart-wrap :comment-group}
"fzprint-smart-wrap smart-wrap?"
smart-wrap?
"border:"
border
((:dzprint options)
{}
(map #(vector %1 %2 %3) (range) start-col style-vec)))
(loop [idx 0
depth 0
style-vec style-vec]
Expand Down
14 changes: 5 additions & 9 deletions src/zprint/config.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -515,32 +515,28 @@
:smart-wrap? true,
:smart-wrap {:border 5,
:end+start-cg [; Line starts with single letter,
; but
; not a or I
; but not a or I
#"^(;+)(\s*[b-zA-HJ-Z]\s+)"
; Line starts with a * or -
#"^(;+)(\s*(?:\*|\-)\s+)"
; Line starts with single letter
; followed by .
#"^(;+)(\s*\w\.\s+)"
; Line starts with one or two
; digit
; number
; followed by period.
; digit number followed by
; period.
#"^(;+)(\s*[0-9]{1,2}\.?\s+)"
; Line starts with two upper case
; chars
#"^(;+)(\s*)[A-Z][A-Z]"],
:end+skip-cg [; Blank line
#"^;+\s*$"
; Line where left paren is first
; and
; right paren last
; and right paren last
; character in line.
#"^;+\s*\(.*\)$"
; Line containing only capitalized
; word
; followed by colon
; word followed by colon
#"^;+\s*[A-Z]\w+\:$"],
:max-variance 30,
:space-factor 3,
Expand Down
19 changes: 8 additions & 11 deletions src/zprint/zprint.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1688,11 +1688,10 @@
"Justifiction more than 2 things")
(if (some zcomment? pair)
[:flow
; The following always flows things of 3 or more
; if they have a comment in them. It doesn't
; cancel justification since this
; (probably?) can't be added by running zprint
; multiple times.
; The following always flows things of 3 or more if
; they have a comment in them. It doesn't cancel
; justification since this (probably?) can't be added
; by running zprint multiple times.
(concat-no-nil arg-1
(fzprint-flow-seq
caller
Expand Down Expand Up @@ -4668,8 +4667,7 @@
[caller l-str r-str
; The options map can get re-written down a bit below, so don't get
; anything with destructuring that might change with a rewritten
; options
; map!
; options map!
{:keys [fn-map user-fn-map one-line? fn-style no-arg1? fn-force-nl quote?],
:as options} ind zloc]
(dbg-s options
Expand Down Expand Up @@ -7921,8 +7919,7 @@
"comma?" comma?
"rightcnt:" (:rightcnt options))
; A possible one line representation of this map, but
; this is
; optimistic and needs to be validated.
; this is optimistic and needs to be validated.
pair-print-one-line
(fzprint-map-two-up
caller
Expand Down Expand Up @@ -7970,8 +7967,8 @@
[["," (zcolor-map options :comma) :whitespace 21]
[(str "\n" (blanks (+ indent ind))) :none :indent 32]]
[["," (zcolor-map options :comma) :whitespace 22]
; Fix issue #59 -- don't
; put blanks to indent before the next \n
; Fix issue #59 -- don't put blanks to indent
; before the next \n
["\n" :none :indent 33]
[(str "\n" (blanks (+ indent ind))) :none :indent 34]]
; comma? nil
Expand Down

0 comments on commit 8f4217c

Please sign in to comment.