remove
function
rewrite-clj.zip/remove
(remove [zloc])Return `zloc` with current node removed. Returned zipper location
is moved to the first non-whitespace node preceding removed node in a depth-first walk.
Removes whitespace appropriately.
- `[1 |2 3] => [|1 3]`
- `[1 |2] => [|1]`
- `[|1 2] => |[2]`
- `[|1] => |[]`
- `[ |1 ] => |[]`
- `[1 [2 3] |4] => [1 [2 |3]]`
- `[|1 [2 3] 4] => |[[2 3] 4]`
If the removed node is a rightmost sibling, both leading and trailing whitespace
is removed, otherwise only trailing whitespace is removed.
The result is that a following element (no matter whether it is on the same line
or not) will end up at same positon (line/column) as the removed one.
If a comment lies betwen the original node and the neighbour this will not hold true.
If the removed node is at end of input and is trailed by 1 or more newlines,
a single trailing newline will be preserved.
Use [[remove*]] to remove node without removing any surrounding whitespace.
Examples
No examples yet. Be the first to add one!