FIX check/fold thingy function

This commit is contained in:
Nathan Dwarshuis 2022-04-27 23:53:58 -04:00
parent 1b1f4d1353
commit c75f2304de
1 changed files with 7 additions and 7 deletions

View File

@ -581,19 +581,19 @@ used for optimization."
;; buffer status ;; buffer status
(defun org-x-dag-bs-check-children (bss msg nochild-def child-def fun) (defun org-x-dag-bs-check-children (bss msg nochild-def child-def stop-fun)
(declare (indent 4)) (declare (indent 4))
;; this is almost like fold or foldM but I want to stop if `fun' returns nil ;; this is almost like fold or foldM but I want to stop if `fun' returns nil
(cl-labels (cl-labels
;; hopefully the TCO native comp actually works :) ;; hopefully the TCO native comp actually works :)
((fold-while ((fold-while
(xs) (xs)
(cond (if (not xs) (either :right child-def)
((not xs) (either :right child-def)) (pcase (car xs)
((either-is-left-p (car xs)) (either :left "Child error")) (`(:right ,r) (if (funcall stop-fun r)
(t (if (funcall fun (car xs)) (either :left msg)
(fold-while (cdr xs)) (fold-while (cdr xs))))
(either :left msg)))))) (_ (either :left "Child error"))))))
(if (not bss) (either :right nochild-def) (if (not bss) (either :right nochild-def)
(fold-while bss)))) (fold-while bss))))