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 3838 [node]
3939 (when (clojure.core/vector? node)
4040 (let [[k & _] node]
41- (contains? #{:list :vector :set :map } k))))
41+ (contains? #{:list :vector :set :map :meta :meta* :reader-macro } k))))
4242
4343(defn- z-make-node
4444 [node ch]
5757 (->> zloc
5858 (iterate f)
5959 (take-while identity)
60+ (take-while (complement z/end?))
6061 (drop-while p?)
6162 (first )))
6263
147148 (-> zloc (z/append-child item))
148149 (-> zloc (z/append-child SPACE) (z/append-child item)))))
149150
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+
150161; ; ## Modify
151162
152163(defn replace
166177 ; ; TODO
167178 (z/remove zloc))
168179
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+
169186; ; ## Others
170187
171188(def node z /node )
You can’t perform that action at this time.
0 commit comments