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-multicloze-hiding.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/test-org-drill-multicloze-hiding.el') diff --git a/tests/test-org-drill-multicloze-hiding.el b/tests/test-org-drill-multicloze-hiding.el index f67e083..b225008 100644 --- a/tests/test-org-drill-multicloze-hiding.el +++ b/tests/test-org-drill-multicloze-hiding.el @@ -158,6 +158,24 @@ Verified by checking the resulting overlay's bounds match the (org-drill-present-multicloze-hide-nth (org-drill-session) -1)) (should (= 1 overlays-during-prompt)))) +;;;; org-drill--count-cloze-matches (extracted scan helper) + +(ert-deftest test-org-drill-count-cloze-matches-counts-body-clozes () + "Counts each cloze region between the body bounds." + (with-cloze-card "* Question :drill: +[A] [B] [C] [D] +" + (let ((bounds (org-drill--cloze-body-bounds))) + (should (= 4 (org-drill--count-cloze-matches (car bounds) (cdr bounds))))))) + +(ert-deftest test-org-drill-count-cloze-matches-zero-when-no-cloze () + "A body with no cloze syntax counts zero." + (with-cloze-card "* Question :drill: +No cloze syntax here. +" + (let ((bounds (org-drill--cloze-body-bounds))) + (should (= 0 (org-drill--count-cloze-matches (car bounds) (cdr bounds))))))) + (provide 'test-org-drill-multicloze-hiding) ;;; test-org-drill-multicloze-hiding.el ends here -- cgit v1.2.3