This namespace provides zipper operations for performing paredit type of operations on clojure/clojurescript forms.
You might find inspirational examples here: http://pub.gajendra.net/src/paredit-refcard.pdf
This namespace provides zipper operations for performing paredit type of operations on clojure/clojurescript forms. You might find inspirational examples here: http://pub.gajendra.net/src/paredit-refcard.pdf
(barf-backward zloc)
Push out the leftmost node of the current S-expression into outer left form
[1 2 [3 |4] 5] => [1 2 3 [|4] 5]
Push out the leftmost node of the current S-expression into outer left form - `[1 2 [3 |4] 5] => [1 2 3 [|4] 5]`
(barf-forward zloc)
Push out the rightmost node of the current S-expression into outer right form
[1 2 [|3 4] 5] => [1 2 [|3] 4 5]
Push out the rightmost node of the current S-expression into outer right form - `[1 2 [|3 4] 5] => [1 2 [|3] 4 5]`
(join zloc)
Join S-expression to the left and right of current loc. Also works for strings.
[[1 2] |[3 4]] => [[1 2 3 4]]
Join S-expression to the left and right of current loc. Also works for strings. - `[[1 2] |[3 4]] => [[1 2 3 4]]` - `["Hello " | "World"] => ["Hello World"]
(kill zloc)
Kill all sibling nodes to the right of the current node
Kill all sibling nodes to the right of the current node - [1 2| 3 4] => [1 2|]
(kill-at-pos zloc pos)
In string and comment aware kill
Perform kill for given position pos
Like kill
, but:
pos
should provide {:row :col }
which are relative to the start of the given form the zipper represents
zloc
must be positioned at a node previous (given depth first) to the node at given pos
In string and comment aware kill Perform kill for given position `pos` Like [[kill]], but: - if inside string kills to end of string and stops there - If inside comment kills to end of line (not including linebreak!) `pos` should provide `{:row :col }` which are relative to the start of the given form the zipper represents `zloc` must be positioned at a node previous (given depth first) to the node at given pos
(kill-one-at-pos zloc pos)
In string and comment aware kill for one node/word at given pos
(+ |100 100) => (+ |100)
(for |(bar do)) => (foo)
"|hello world" => "| world"
; |hello world => ; |world
In string and comment aware kill for one node/word at given pos - `(+ |100 100) => (+ |100)` - `(for |(bar do)) => (foo)` - `"|hello world" => "| world"` - ` ; |hello world => ; |world`
(move-to-prev zloc)
Move node at current location to the position of previous location given a depth first traversal
(+ 1 (+ 2 |3) 4) => (+ 1 (+ |3 2) 4)
(+ 1 (+ 2 3) |4) => (+ 1 (+ 2 3 |4))
returns zloc after move or given zloc if a move isn't possible
Move node at current location to the position of previous location given a depth first traversal - `(+ 1 (+ 2 |3) 4) => (+ 1 (+ |3 2) 4)` - `(+ 1 (+ 2 3) |4) => (+ 1 (+ 2 3 |4))` returns zloc after move or given zloc if a move isn't possible
(raise zloc)
Delete siblings and raise node at zloc one level up
[1 [2 |3 4]] => [1 |3]
Delete siblings and raise node at zloc one level up - `[1 [2 |3 4]] => [1 |3]`
(slurp-backward zloc)
Pull in prev left outer node (if none at first level, tries next etc) into current S-expression
[1 2 [|3] 4 5] => [1 [2 |3] 4 5]
Pull in prev left outer node (if none at first level, tries next etc) into current S-expression - `[1 2 [|3] 4 5] => [1 [2 |3] 4 5]`
(slurp-backward-fully zloc)
Pull in all left outer-nodes into current S-expression, but only the ones at the same level as the the first one.
[1 2 [|3] 4 5] => [[1 2 |3] 4 5]
Pull in all left outer-nodes into current S-expression, but only the ones at the same level as the the first one. - `[1 2 [|3] 4 5] => [[1 2 |3] 4 5]`
(slurp-forward zloc)
Pull in next right outer node (if none at first level, tries next etc) into current S-expression
[1 2 [|3] 4 5] => [1 2 [|3 4] 5]
Pull in next right outer node (if none at first level, tries next etc) into current S-expression - `[1 2 [|3] 4 5] => [1 2 [|3 4] 5]`
(slurp-forward-fully zloc)
Pull in all right outer-nodes into current S-expression, but only the ones at the same level as the the first one.
[1 2 [|3] 4 5] => [1 2 [|3 4 5]]
Pull in all right outer-nodes into current S-expression, but only the ones at the same level as the the first one. - `[1 2 [|3] 4 5] => [1 2 [|3 4 5]]`
(splice-killing-backward zloc)
Remove left siblings of current given node in S-Expression and unwrap remaining into enclosing S-expression
(foo (let ((x 5)) |(sqrt n)) bar) => (foo (sqrt n) bar)
Remove left siblings of current given node in S-Expression and unwrap remaining into enclosing S-expression - `(foo (let ((x 5)) |(sqrt n)) bar) => (foo (sqrt n) bar)`
(splice-killing-forward zloc)
Remove current given node and its right siblings in S-Expression and unwrap remaining into enclosing S-expression
(a (b c |d e) f) => (a b |c f)
Remove current given node and its right siblings in S-Expression and unwrap remaining into enclosing S-expression - `(a (b c |d e) f) => (a b |c f)`
(split zloc)
Split current s-sexpression in two at given node zloc
[1 2 |3 4 5] => [1 2 3] [4 5]
Split current s-sexpression in two at given node `zloc` - `[1 2 |3 4 5] => [1 2 3] [4 5]`
(split-at-pos zloc pos)
In string aware split
Perform split at given position pos
Like split, but:
pos
should provide {:row :col }
which are relative to the start of the given form the zipper represents
zloc
must be positioned at a node previous (given depth first) to the node at given pos
In string aware split Perform split at given position `pos` Like split, but: - if inside string splits string into two strings `pos` should provide `{:row :col }` which are relative to the start of the given form the zipper represents `zloc` must be positioned at a node previous (given depth first) to the node at given pos
(wrap-around zloc t)
Wrap current node with a given type t
(:vector, :list, :set, :map :fn)
|123 => [|123] ; given :vector
|[1 [2]] => [|[1 [2]]]
Wrap current node with a given type `t` (:vector, :list, :set, :map :fn) - `|123 => [|123] ; given :vector` - `|[1 [2]] => [|[1 [2]]]`
(wrap-fully-forward-slurp zloc t)
Create a new seq node of type t
left of zloc
then slurp fully into the new node
[1 |2 3 4] => [1 [|2 3 4]]
Create a new seq node of type `t` left of `zloc` then slurp fully into the new node - `[1 |2 3 4] => [1 [|2 3 4]]`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close