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 /org-drill.el | |
| parent | 37df84a462378636f6528970e95187c3a86f8f3e (diff) | |
| download | org-drill-main.tar.gz org-drill-main.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 'org-drill.el')
| -rw-r--r-- | org-drill.el | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/org-drill.el b/org-drill.el index 4a8262c..343009d 100644 --- a/org-drill.el +++ b/org-drill.el @@ -1986,6 +1986,26 @@ Consider reformulating the item to make it easier to remember.\n" prompt) prompt)) +(defcustom org-drill-show-outline-path-during-drill nil + "When non-nil, show the card's outline path in the drill prompt. +The ancestor headings are joined with \" > \" and bracketed, e.g. +\"[Spanish > Greetings]\", and prepended to the prompt so you can see +where the current card sits in the deck. Off by default." + :group 'org-drill-display + :type 'boolean) + +(put 'org-drill-show-outline-path-during-drill 'safe-local-variable 'booleanp) + +(defun org-drill--outline-path-string () + "Return the outline path of the entry at point, bracketed for the prompt. +Joins the ancestor headings with \" > \" and wraps them in brackets with a +trailing space, e.g. \"[Spanish > Greetings] \". Returns the empty string +when the entry has no ancestors or point is not on a heading." + (let ((path (ignore-errors (org-get-outline-path)))) + (if path + (concat "[" (mapconcat #'identity path " > ") "] ") + ""))) + (defun org-drill--make-minibuffer-prompt (session prompt) "Make a mini-buffer for the SESSION, with PROMPT." (let ((status (cl-first (org-drill-entry-status session))) @@ -2027,7 +2047,9 @@ Consider reformulating the item to make it easier to remember.\n" 'face `(:foreground ,org-drill-new-count-color) 'help-echo (concat "The number of new items that you " "have never reviewed.")) - prompt))) + (if org-drill-show-outline-path-during-drill + (concat (org-drill--outline-path-string) prompt) + prompt)))) (defun org-drill-presentation-prompt (session &optional prompt) "Create a card prompt with a timer and user-specified menu. |
