aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-05 04:53:05 -0500
committerCraig Jennings <c@cjennings.net>2026-05-05 04:53:05 -0500
commita68f995fa1dfbb891611a982587dc3f07f467451 (patch)
tree7236233f5bcc1848e5176dac1afa3f1f4ea6112b
parent6b04aa2d5397cebca99e133ecc0853c8ca36bd56 (diff)
downloadorg-drill-a68f995fa1dfbb891611a982587dc3f07f467451.tar.gz
org-drill-a68f995fa1dfbb891611a982587dc3f07f467451.zip
fix: guard zero-divisor in org-drill-final-report overdue percentage
The warning branch divided 100*overdue by (dormant+due) without guarding the denominator. When both counts are zero — degenerate scopes (cram with no items collected, pure-failure session on empty queues) — the call hit arith-error before the warning even rendered. Wrapped the divisor with (max 1 ...). In the zero case the percentage reads as 0% rather than crashing the session wrap-up. Resolves a long-standing pre-existing TODO entry.
-rw-r--r--org-drill.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/org-drill.el b/org-drill.el
index f59551b..599406f 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -2869,9 +2869,14 @@ order to make items appear more frequently over time."
(propertize "WARNING!" 'face 'org-warning)
(- 100 pass-percent)
(oref session overdue-entry-count)
+ ;; Guard the divisor — both counts are zero in degenerate
+ ;; scopes (e.g., cram mode with nothing collected, or a
+ ;; pure-failure session on empty queues), and the original
+ ;; `(/ ... 0)' raised arith-error before the warning could
+ ;; even render.
(round (* 100 (oref session overdue-entry-count))
- (+ (oref session dormant-entry-count)
- (oref session due-entry-count))))
+ (max 1 (+ (oref session dormant-entry-count)
+ (oref session due-entry-count)))))
))))
(defun org-drill-free-markers (session markers)