Function: combobulate-ztree-remove

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

Signature

(combobulate-ztree-remove LOC)

Documentation

Remove the node at LOC.

Return the loc that would have preceded it in a depth-first walk.

Source Code

;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-ztree.el
  (combobulate-ztree-replace loc (combobulate-ztree-make-node loc (combobulate-ztree-node loc) (append (combobulate-ztree-children loc) `(,item)))))  ;; TODO: check performance

(defun combobulate-ztree-remove (loc)
  "Remove the node at LOC.
Return the loc that would have preceded it in a depth-first
walk."
  (combobulate-ztree--with-loc loc (context pnodes ppath l r)
    (if (not context)
        (error "Remove at top")
      (if (> (length l) 0)
          (let ((nloc (combobulate-ztree--with-meta (cons (car l)
                                               (combobulate-ztree--context-assoc context
                                                                      ':l (cdr l)
                                                                      ':changed? t))
                                         (combobulate-ztree--meta loc)))
                (child nil))
            (while (setq child (and (combobulate-ztree-branch-p nloc) (combobulate-ztree-children nloc)))
              (setq nloc (combobulate-ztree-rightmost child)))
            nloc)
        (combobulate-ztree--with-meta
         (cons (combobulate-ztree-make-node loc (car pnodes) r)
               (and ppath (combobulate-ztree--context-assoc context ':changed? t)))
         (combobulate-ztree--meta loc))))))