File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 38
38
[node]
39
39
(when (clojure.core/vector? node)
40
40
(let [[k & _] node]
41
- (contains? #{:list :vector :set :map } k))))
41
+ (contains? #{:list :vector :set :map :meta :meta* :reader-macro } k))))
42
42
43
43
(defn- z-make-node
44
44
[node ch]
57
57
(->> zloc
58
58
(iterate f)
59
59
(take-while identity)
60
+ (take-while (complement z/end?))
60
61
(drop-while p?)
61
62
(first )))
62
63
147
148
(-> zloc (z/append-child item))
148
149
(-> zloc (z/append-child SPACE) (z/append-child item)))))
149
150
151
+ (defn prepend-space
152
+ " Prepend a whitespace node of the given width."
153
+ ([zloc] (prepend-space zloc 1 ))
154
+ ([zloc n] (z/insert-left zloc [:whitespace (apply str (repeat n \space))])))
155
+
156
+ (defn append-space
157
+ " Append a whitespace node of the given width."
158
+ ([zloc] (append-space zloc 1 ))
159
+ ([zloc n] (z/insert-right zloc [:whitespace (apply str (repeat n \space))])))
160
+
150
161
; ; ## Modify
151
162
152
163
(defn replace
166
177
; ; TODO
167
178
(z/remove zloc))
168
179
180
+ (defn splice
181
+ " Add the current node's children to the parent branch (in place of the current node)."
182
+ [zloc]
183
+ (let [ch (z/children zloc)]
184
+ (-> (reduce z/insert-right zloc (reverse ch)) z/remove z/right)))
185
+
169
186
; ; ## Others
170
187
171
188
(def node z /node )
You can’t perform that action at this time.
0 commit comments