aboutsummaryrefslogtreecommitdiff
path: root/org-drill.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-05 04:29:28 -0500
committerCraig Jennings <c@cjennings.net>2026-05-05 04:29:28 -0500
commitb2cc4d1645b378043a971906b5ebc34d3c92b544 (patch)
treebbb8c0fa4eeca0f5fc4a3df76d8aac7337bc0a57 /org-drill.el
parent0cc022912ad65a67ee89bca11ac035b1018d5ec9 (diff)
downloadorg-drill-b2cc4d1645b378043a971906b5ebc34d3c92b544.tar.gz
org-drill-b2cc4d1645b378043a971906b5ebc34d3c92b544.zip
fix: guard org-drill-smart-reschedule cond against nil days-ahead
The function takes `days-ahead' as &optional, but the schedule cond called `(= 0 days-ahead)' and `(cl-minusp days-ahead)' before any type-guard, so passing nil crashed with a wrong-type-argument error. Today's two callers (the rating-confirmation flow and the org-drill-relearn-item helper) always pass a number, so this was latent — but a third caller relying on the documented &optional shape would hit it immediately. Switched the cond to require numberp before the value comparisons, and the default branch now falls back to the algorithm-computed next-interval when days-ahead is nil. That matches the intent implied by the optional signature and the docstring.
Diffstat (limited to 'org-drill.el')
-rw-r--r--org-drill.el15
1 files changed, 10 insertions, 5 deletions
diff --git a/org-drill.el b/org-drill.el
index dd210a2..fe99a3f 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -1429,15 +1429,20 @@ item will be scheduled exactly this many days into the future."
(if (eql 'sm5 org-drill-spaced-repetition-algorithm)
(setq org-drill-sm5-optimal-factor-matrix new-ofmatrix))
+ ;; Pick the schedule based on days-ahead. The optional arg may be
+ ;; nil (callers omit it to mean "use the algorithm-computed
+ ;; next-interval"). The original cond compared `(= 0 days-ahead)'
+ ;; before any type guard, which crashed on nil.
(cond
- ((= 0 days-ahead)
+ ((and (numberp days-ahead) (= 0 days-ahead))
(org-schedule '(4)))
- ((cl-minusp days-ahead)
+ ((and (numberp days-ahead) (cl-minusp days-ahead))
(org-schedule nil (current-time)))
(t
- (org-schedule nil (time-add (current-time)
- (days-to-time
- (round next-interval))))))))))
+ (let ((interval (if (numberp days-ahead) days-ahead next-interval)))
+ (org-schedule nil (time-add (current-time)
+ (days-to-time
+ (round interval)))))))))))
(defun org-drill-hypothetical-next-review-date (quality)
"Returns an integer representing the number of days into the future