Rewrite-cljs Api Documentation

Version: 0.3.0

rewrite-clj.zip.removez

remove

(remove zloc)

Remove value at the given zipper location. Returns the first non-whitespace node that would have preceded it in a depth-first walk. Will remove 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 a node is located rightmost, both preceding and trailing spaces are removed, otherwise only trailing spaces are touched. This means that a following element (no matter whether on the same line or not) will end up in the same position (line/column) as the removed one, unless a comment lies between the original node and the neighbour.

remove-preceding-space

(remove-preceding-space zloc p?)

Remove all whitespace preceding a given node.

remove-preserve-newline

(remove-preserve-newline zloc)

Same as remove but preserves newlines

remove-trailing-space

(remove-trailing-space zloc p?)

Remove all whitespace following a given node.