Common utility functions for using rewrite-clj zippers and editing forms.
Common utility functions for using rewrite-clj zippers and editing forms.
(comment? zloc)
True if the node at this location is a comment.
True if the node at this location is a comment.
(discard-macro? zloc)
True if the node at this location is a discard reader macro.
True if the node at this location is a discard reader macro.
(eat-whitespace zloc)
Eat whitespace characters, leaving the zipper located at the next non-whitespace node.
Eat whitespace characters, leaving the zipper located at the next non-whitespace node.
(edit-scan zloc f)
Scan rightward from the given location, editing nodes by applying the given function. Returns the final zipper location.
Scan rightward from the given location, editing nodes by applying the given function. Returns the final zipper location.
(edit-walk zloc f)
Visit all nodes in zloc
by applying the given function. Returns the final
zipper location.
Visit all nodes in `zloc` by applying the given function. Returns the final zipper location.
(form-symbol zloc)
Return a name-only symbol for the leftmost node from this location.
Return a name-only symbol for the leftmost node from this location.
(form-symbol-full zloc)
Return the symbol in the leftmost node from this location.
Return the symbol in the leftmost node from this location.
(ignored-form? zloc)
True if the node at this location is an ignored form.
True if the node at this location is an ignored form.
(keyword? zloc)
True if the node at this location is a keyword.
True if the node at this location is a keyword.
(line-break zloc)
Ensure the node at this location breaks onto a new line. Returns the zipper at the location following the whitespace, if there is one.
Ensure the node at this location breaks onto a new line. Returns the zipper at the location following the whitespace, if there is one.
(line-join zloc)
Ensure the node at this location joins onto the same line. Returns the zipper at the location following the whitespace.
Ensure the node at this location joins onto the same line. Returns the zipper at the location following the whitespace.
(move-n zloc move n)
Repeatedly move in a direction n
times.
Repeatedly move in a direction `n` times.
(multiline? zloc)
True if the form at this location spans more than one line.
True if the form at this location spans more than one line.
(reader-conditional? zloc)
True if the node at this location is a reader conditional form.
True if the node at this location is a reader conditional form.
(reader-macro? zloc)
True if the node at this location is a reader macro expression.
True if the node at this location is a reader macro expression.
(replace-with-blank-lines zloc n)
Replace all whitespace at the location with n
blank lines.
Replace all whitespace at the location with `n` blank lines.
(root? zloc)
True if this location is the root node.
True if this location is the root node.
(safe-edit f zloc & args)
Wrap an editing function with error handling logic which will capture information about the surrounding form and the cause of the failure.
Wrap an editing function with error handling logic which will capture information about the surrounding form and the cause of the failure.
(skip-next zloc)
Like z/next*
, but skips the current location instead of visiting and
descending into it.
Like `z/next*`, but skips the current location instead of visiting and descending into it.
(skip-whitespace zloc)
Skip to the location of the next non-whitespace node.
Skip to the location of the next non-whitespace node.
(space? zloc)
True if the node at this location is whitespace and not a line break character.
True if the node at this location is whitespace and _not_ a line break character.
(string? zloc)
True if the node at this location is a string.
True if the node at this location is a string.
(syntax-quoted? zloc)
True if the location is inside a macro syntax quote.
True if the location is inside a macro syntax quote.
(token-value zloc)
Return the s-expression form of the token at this location.
Return the s-expression form of the token at this location.
(token? zloc)
True if the node at this location is a token.
True if the node at this location is a token.
(unwrap-meta zloc)
If this location is a metadata node, recursively unwrap it and return the location of the nested value form. Otherwise returns the location unchanged.
If this location is a metadata node, recursively unwrap it and return the location of the nested value form. Otherwise returns the location unchanged.
(whitespace-after? match? zloc)
True if the location is a whitespace node preceding a location matching
match?
.
True if the location is a whitespace node preceding a location matching `match?`.
(whitespace-before? match? zloc)
True if the location is a whitespace node preceding a location matching
match?
.
True if the location is a whitespace node preceding a location matching `match?`.
(whitespace-between? pre? post? zloc)
True if the location is whitespace between locations matching pre?
and
post?
, with nothing but whitespace between.
True if the location is whitespace between locations matching `pre?` and `post?`, with nothing but whitespace between.
(zprn zloc tag)
Print a zipper location for debugging purposes. Returns the location unchanged.
Print a zipper location for debugging purposes. Returns the location unchanged.
(zstr zloc)
Return the string representation of the nodes at the given location.
Return the string representation of the nodes at the given location.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close