aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-05 05:10:52 -0500
committerCraig Jennings <c@cjennings.net>2026-05-05 05:10:52 -0500
commit8bbb6d30529abd5350884e822b308da917966e73 (patch)
treef3c9cb845a2e4780b11ea1bf94417214ba21f836
parent656faefc0e030ea476f9937116b727331cec607f (diff)
downloadorg-drill-8bbb6d30529abd5350884e822b308da917966e73.tar.gz
org-drill-8bbb6d30529abd5350884e822b308da917966e73.zip
fix: drop dead translate_number entry from card-type alist (upstream #43)
The card-type alist mapped translate_number to a function that no longer exists in the file. Cards with DRILL_CARD_TYPE: translate_number crashed with void-function during drill instead of being skipped. Reporter (issue #43, 2021) said they had old decks using the documented translate_number type and were getting the crash on restore. The function was apparently removed at some point without clearing the alist entry. Removed the alist entry so entry-f's no-presentation-fn branch fires and returns skip after messaging the user. Legacy decks now degrade gracefully instead of crashing the session. Tests in tests/test-org-drill-translate-number-regression.el lock the behavior in (entry-f returns skip on translate_number, alist no longer carries the entry).
-rw-r--r--org-drill.el3
-rw-r--r--tests/test-org-drill-translate-number-regression.el47
2 files changed, 48 insertions, 2 deletions
diff --git a/org-drill.el b/org-drill.el
index 599406f..f98bbfe 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -294,8 +294,7 @@ This is a buffer-local variable.")
("decline_noun"
org-drill-present-noun-declension
org-drill-show-answer-noun-declension)
- ("spanish_verb" org-drill-present-spanish-verb)
- ("translate_number" org-drill-present-translate-number))
+ ("spanish_verb" org-drill-present-spanish-verb))
"Alist associating card types with presentation functions.
Each entry in the alist takes the form:
diff --git a/tests/test-org-drill-translate-number-regression.el b/tests/test-org-drill-translate-number-regression.el
new file mode 100644
index 0000000..252f35b
--- /dev/null
+++ b/tests/test-org-drill-translate-number-regression.el
@@ -0,0 +1,47 @@
+;;; test-org-drill-translate-number-regression.el --- Regression test for issue #43 -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Upstream issue #43 (2021-08-31). The card-type alist mapped
+;; "translate_number" to `org-drill-present-translate-number', a function
+;; that no longer exists in the file. Cards with
+;; `:DRILL_CARD_TYPE: translate_number:' hit a void-function error during
+;; the drill loop instead of being skipped gracefully.
+
+;;; Code:
+
+(require 'ert)
+(require 'cl-lib)
+(require 'org)
+(require 'org-drill)
+
+;;;; Regression — issue #43
+
+(ert-deftest test-translate-number-card-type-handled-gracefully ()
+ "A card with `:DRILL_CARD_TYPE: translate_number:' is skipped with
+a user-visible message instead of crashing with void-function.
+
+Pre-fix: org-drill-card-type-alist still mapped translate_number to
+the missing org-drill-present-translate-number; entry-f's
+`(funcall presentation-fn session)' threw void-function.
+
+Post-fix: the alist entry is removed; entry-f's no-presentation-fn
+branch fires and returns 'skip after messaging the user."
+ (with-temp-buffer
+ (let ((org-startup-folded nil))
+ (insert "* Question :drill:\n:PROPERTIES:\n:DRILL_CARD_TYPE: translate_number\n:END:\nbody body body\n")
+ (org-mode)
+ (goto-char (point-min))
+ (let ((session (org-drill-session)))
+ (cl-letf (((symbol-function 'sit-for) #'ignore))
+ (let ((result (org-drill-entry-f session #'ignore)))
+ (should (eq 'skip result))))))))
+
+(ert-deftest test-translate-number-not-in-card-type-alist ()
+ "The translate_number → org-drill-present-translate-number entry is gone
+from the card-type alist. No code path can dispatch into the missing
+function any more."
+ (should-not (assoc "translate_number" org-drill-card-type-alist)))
+
+(provide 'test-org-drill-translate-number-regression)
+
+;;; test-org-drill-translate-number-regression.el ends here