From 7eece407772d7c5cfba93ba914439094f0d9fbf2 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 26 May 2026 19:58:21 -0500 Subject: refactor: dedupe presenters, group defcustoms, and fill in docstrings A cleanup pass over org-drill internals, squashed from the refactor/wave3-cleanup branch. No behavior change. Each step kept the existing tests green and added its own. I shared two duplicated helpers across the language card getters: org-drill--read-property-string and org-drill--face-from-alist. I factored the cloze body-scan out of the two multicloze presenters into org-drill--cloze-body-bounds, org-drill--count-cloze-matches, and org-drill--hide-cloze-by-index, so each presenter just picks which indices to hide. I pulled the presenter resolution and the four-way result classification out of org-drill-entry-f into org-drill--resolve-presenter and org-drill--classify-presentation-result, untangling the pivot of every drill iteration. I split the 37 defcustoms (and the three cloze faces) into four customize sub-groups (display, algorithm, session, leech) so customize-group org-drill is navigable. There's no leitner group because the Leitner settings are defvars. I documented the 22 defuns that had no docstring, rewrote the corrupted org-drill-presentation-prompt-in-mini-buffer docstring, and switched eleven docstrings to the imperative "Return" (issue #2). --- tests/test-org-drill-explain-and-language-cards.el | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/test-org-drill-explain-and-language-cards.el') diff --git a/tests/test-org-drill-explain-and-language-cards.el b/tests/test-org-drill-explain-and-language-cards.el index 301705d..9454a0d 100644 --- a/tests/test-org-drill-explain-and-language-cards.el +++ b/tests/test-org-drill-explain-and-language-cards.el @@ -171,6 +171,34 @@ on whether the buffer ends with a newline." (face (get-text-property 0 'face (nth 0 info)))) (should (equal "red" (plist-get face :foreground)))))) +;;;; org-drill--read-property-string + +(ert-deftest test-org-drill-read-property-string-strips-one-read () + "A Lisp-readable property string is read down to its datum." + (should (equal "hablar" (org-drill--read-property-string "\"hablar\"")))) + +(ert-deftest test-org-drill-read-property-string-nil-is-nil () + "A nil property (absent) returns nil rather than erroring." + (should (null (org-drill--read-property-string nil)))) + +;;;; org-drill--face-from-alist + +(ert-deftest test-org-drill-face-from-alist-hit-returns-colour () + "A key present in the alist returns its mapped colour." + (should (equal "tomato" + (org-drill--face-from-alist "present" org-drill-verb-tense-alist "x")))) + +(ert-deftest test-org-drill-face-from-alist-is-case-insensitive () + "Lookup ignores case, matching the assoc-string call sites." + (should (equal "tomato" + (org-drill--face-from-alist "PRESENT" org-drill-verb-tense-alist "x")))) + +(ert-deftest test-org-drill-face-from-alist-miss-returns-default () + "A key absent from the alist falls back to the supplied default." + (should (equal "fallback" + (org-drill--face-from-alist "no-such-tense" + org-drill-verb-tense-alist "fallback")))) + (provide 'test-org-drill-explain-and-language-cards) ;;; test-org-drill-explain-and-language-cards.el ends here -- cgit v1.2.3