Function: combobulate-ztree--preorder-next

combobulate-ztree--preorder-next is a natively compiled function defined in combobulate-ztree.el.

Signature

(combobulate-ztree--preorder-next LOC)

Documentation

Move to the next LOC in the hierarchy, depth-first in preorder.

When reaching the end, returns a distinguished loc detectable via combobulate-ztree-end-p. If already at the end, stays there.

Source Code

;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-ztree.el
;;;; Enumeration

(defun combobulate-ztree--preorder-next (loc)
  "Move to the next LOC in the hierarchy, depth-first in preorder.
When reaching the end, returns a distinguished loc detectable via
`combobulate-ztree-end-p'.  If already at the end, stays there."
  (if (equal :end (combobulate-ztree--context loc))
      loc
    (let ((cloc loc))
      (or
       (and (combobulate-ztree-branch-p cloc) (combobulate-ztree-down cloc))
       (combobulate-ztree-right cloc)
       (let ((p cloc)
             (pr nil))
         (while (and (combobulate-ztree-up p) (not (setq pr (combobulate-ztree-right (combobulate-ztree-up p)))))
           (setq p (combobulate-ztree-up p)))
         (or pr (cons (cons (combobulate-ztree-node p) :end) nil)))))))