Fork me on GitHub

Hi @whatacold! I’ll have a peek and get back to you!


(Maybe interesting aside: Your sample reminded me of, which is not at all what you are looking for or asking about, but will test code snippits found in documentation)


So I had a peek @whatacold. The following might (?) be tripping you up: • z/right will return nil when there is no next sibling • z/end? will return true when at (not past) the last node ( It will also return true for a nil input. What do you think of this instead?

(loop [zloc zloc]
  (let [zloc (some-> zloc
                     (z/insert-right* (n/comment-node "; test"))
                     (z/insert-right* (n/newlines 1)))
        next-sib (z/right zloc)]
    (if next-sib
      (recur next-sib)
      (z/print-root zloc))))
(defn my-function [a]
  (* a 3))
;; test

(my-function 7)
;; test
Notes: • I switched to using node creation functions, a personal preference which I find more explicit for this use case. • Switched from insert-right to insert-right*. The * version does no extra automagic whitespace handling which is what you’d want when inserting whitespace/comment nodes, I think.

👍 3