diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-31 11:18:49 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-31 11:18:49 -0500 |
| commit | e201ba696ed27e407d934321a5f4c5874ea4fee5 (patch) | |
| tree | 19f2c14bf8ea125d79c4518c3af9ad714a841b5f /tests | |
| parent | 37df84a462378636f6528970e95187c3a86f8f3e (diff) | |
| download | org-drill-e201ba696ed27e407d934321a5f4c5874ea4fee5.tar.gz org-drill-e201ba696ed27e407d934321a5f4c5874ea4fee5.zip | |
A new defcustom org-drill-show-outline-path-during-drill (default off) prepends the card's ancestor path to the mini-buffer prompt, for example [Spanish > Greetings], so during a drill you can see where the current card sits in the deck. With it off the prompt is byte-for-byte unchanged.
I ported this from m.galimski's fork (commit c6d0c850) and gated it behind the defcustom rather than leaving it always on. The path comes from org-get-outline-path through a small org-drill--outline-path-string helper. Tests cover the helper (nested and top-level), the prompt with the switch on and off, and the default value.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-org-drill-prompt-and-misc.el | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/test-org-drill-prompt-and-misc.el b/tests/test-org-drill-prompt-and-misc.el index 968ad57..5b42f6b 100644 --- a/tests/test-org-drill-prompt-and-misc.el +++ b/tests/test-org-drill-prompt-and-misc.el @@ -140,6 +140,59 @@ (org-drill-progress-message 42 50) (should (string-match-p "42" got-message))))) +;;;; org-drill outline path in the drill prompt (m.galimski patch) + +(ert-deftest test-org-drill--outline-path-string-nested () + "A nested entry yields its ancestor path, bracketed and arrow-joined." + (with-temp-buffer + (insert "* Spanish\n** Greetings\n*** Hola :drill:\nhola = hello\n") + (org-mode) + (goto-char (point-min)) + (search-forward "Hola") + (should (equal (org-drill--outline-path-string) "[Spanish > Greetings] ")))) + +(ert-deftest test-org-drill--outline-path-string-top-level-empty () + "A top-level entry has no ancestors, so the path string is empty." + (with-temp-buffer + (insert "* Hola :drill:\nhola = hello\n") + (org-mode) + (goto-char (point-min)) + (should (equal (org-drill--outline-path-string) "")))) + +(ert-deftest test-org-drill--make-minibuffer-prompt-omits-path-by-default () + "With the defcustom off, the outline path is absent from the prompt." + (with-temp-buffer + (let ((org-startup-folded nil) + (org-drill-show-outline-path-during-drill nil)) + (insert "* Spanish\n** Greetings\n*** Hola :drill:\nhola = hello\n") + (org-mode) + (goto-char (point-min)) + (search-forward "Hola") + (with-fixed-now + (let* ((session (org-drill-session)) + (prompt (substring-no-properties + (org-drill--make-minibuffer-prompt session "test")))) + (should-not (string-match-p "Greetings" prompt))))))) + +(ert-deftest test-org-drill--make-minibuffer-prompt-shows-path-when-on () + "With the defcustom on, the prompt carries the bracketed outline path." + (with-temp-buffer + (let ((org-startup-folded nil) + (org-drill-show-outline-path-during-drill t)) + (insert "* Spanish\n** Greetings\n*** Hola :drill:\nhola = hello\n") + (org-mode) + (goto-char (point-min)) + (search-forward "Hola") + (with-fixed-now + (let* ((session (org-drill-session)) + (prompt (substring-no-properties + (org-drill--make-minibuffer-prompt session "test")))) + (should (string-match-p "\\[Spanish > Greetings\\]" prompt))))))) + +(ert-deftest test-org-drill-show-outline-path-defaults-off () + "The outline-path defcustom ships nil so the prompt is unchanged by default." + (should (eq nil (default-value 'org-drill-show-outline-path-during-drill)))) + (provide 'test-org-drill-prompt-and-misc) ;;; test-org-drill-prompt-and-misc.el ends here |
