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
(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))
;; this is almost like fold or foldM but I want to stop if `fun' returns nil
(cl-labels
;; hopefully the TCO native comp actually works :)
((fold-while
(xs)
(cond
((not xs) (either :right child-def))
((either-is-left-p (car xs)) (either :left "Child error"))
(t (if (funcall fun (car xs))
(fold-while (cdr xs))
(either :left msg))))))
(if (not xs) (either :right child-def)
(pcase (car xs)
(`(:right ,r) (if (funcall stop-fun r)
(either :left msg)
(fold-while (cdr xs))))
(_ (either :left "Child error"))))))
(if (not bss) (either :right nochild-def)
(fold-while bss))))