Skip to content

Commit 3954f58

Browse files
authored
paredit: slurp fixes (#359)
Because of #256, slurp fns had to be rewritten. During rewriting: - address design flaw by deprecating existing `slurp` fns and adding replacement `slurp-`*`-into` fns (closes #339) - stop adding space char when preserving slurped newlines (closes #345) - review ambiguous `-slurp-`*-`fully` fn behaviour (closes #341) - when slurping, don't consider a node with `#_` uneval nodes empty (closes #338) - don't throw on rewrite-clj parseable but invalid clojure `{:a}` (closes #336) - slurping forward fully no longer throws when slurping into an empty seq that is last item in a seq (closes #335) - slurping backward at empty-seq at start of seq no longer throws (closes #334) - slurp forward now slurps when at empty-seq at end of seq (closes #333)
1 parent 78bb005 commit 3954f58

File tree

6 files changed

+536
-126
lines changed

6 files changed

+536
-126
lines changed

.clj-kondo/config.edn

+6-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@
2626
:unused-referred-var
2727
{:exclude {clojure.test.check [quick-check]}}
2828
:deprecated-var
29-
{:exclude {rewrite-clj.zip.base/->string
29+
{:exclude {rewrite-clj.paredit/slurp-forward {:namespaces [rewrite-clj.paredit-test]}
30+
rewrite-clj.paredit/slurp-forward-fully {:namespaces [rewrite-clj.paredit-test]}
31+
rewrite-clj.paredit/slurp-backward {:namespaces [rewrite-clj.paredit-test]}
32+
rewrite-clj.paredit/slurp-backward-fully {:namespaces [rewrite-clj.paredit-test]}
33+
34+
rewrite-clj.zip.base/->string
3035
{:namespaces [rewrite-clj.zip]}
3136
rewrite-clj.zip.base/->root-string
3237
{:namespaces [rewrite-clj.zip]}

CHANGELOG.adoc

+32
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,38 @@ A release with known breaking changes is marked with:
3737
{issue}350[#350] ({lread})
3838
** `kill-one-at-pos` word deletion in string/comment off-by-one error fixed
3939
{issue}343[#343] ({lread})
40+
** Address design flaw of `slurp` functions
41+
+
42+
|===
43+
| Deprecated | Replacement
44+
45+
| `slurp-forward`
46+
| `slurp-forward-into`
47+
48+
| `slurp-forward-fully`
49+
| `slurp-forward-fully-into`
50+
51+
| `slurp-backward`
52+
| `slurp-backward-into`
53+
54+
| `slurp-backward-fully`
55+
| `slurp-backward-fully-into`
56+
|===
57+
{issue}339[#339] ({lread})
58+
** stop adding space char when preserving slurped newlines
59+
{issue}345[#345] ({lread})
60+
** review ambiguous `-slurp-`*`-fully` fn behaviour
61+
{issue}341[#341] ({lread})
62+
** when slurping don't consider a node with `#_ uneval` nodes empty
63+
{issue}338[#338] ({lread})
64+
** when slurping don't throw on rewrite-clj parseable, but invalid clojure, i.e., `{:a}`
65+
{issue}336[#336] ({lread})
66+
** slurping forward fully no longer throws when slurping into an empty seq that is the last item in a seq
67+
{issue}335[#335] ({lread})
68+
** slurping backward at empty-seq at start of a seq no longer throws
69+
{issue}334[#334] ({lread})
70+
** slurping forward now slurps when at empty seq at end of a seq
71+
{issue}333[#333] ({lread})
4072

4173
=== v1.1.49 - 2024-11-18 [[v1.1.49]]
4274

deps.edn

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
;; we rely on clj-kondo for that
7272
:ignored-faults {:deprecations {rewrite-clj.regression-test true
7373
rewrite-clj.zip.whitespace-test true
74-
rewrite-clj.zip-test true}}}]}
74+
rewrite-clj.zip-test true
75+
rewrite-clj.paredit-test true}}}]}
7576

7677
;;
7778
;; Test support

src/rewrite_clj/custom_zipper/core.cljc

+5
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@
101101
[zloc]
102102
(map first (:left zloc)))
103103

104+
(defn-switchable rights
105+
"Returns a seq of the left siblings of current node in `zloc`."
106+
[zloc]
107+
(map first (:right zloc)))
108+
104109
(defn-switchable down
105110
"Returns zipper with the location at the leftmost child of current node in `zloc`, or
106111
nil if no children."

0 commit comments

Comments
 (0)