diff options
| author | Craig Jennings <c@cjennings.net> | 2025-11-12 14:42:35 -0600 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2025-11-12 14:42:35 -0600 |
| commit | 6c2b9dc58b93aa77319ed73025b1e432e8d74c7a (patch) | |
| tree | 1312ceeb344f0dcaf17a5536637607d20b5798ec | |
| parent | 6acc0d9d674f065f8d4278b333ab924c42cbdd88 (diff) | |
| download | org-drill-6c2b9dc58b93aa77319ed73025b1e432e8d74c7a.tar.gz org-drill-6c2b9dc58b93aa77319ed73025b1e432e8d74c7a.zip | |
org-drill: Implement custom drawer hiding function
Replace `org-cycle-hide-drawers` with a new `org-drill-hide-drawers`
function for more reliable drawer hiding in org-drill. This change
enhances the drill display by ensuring all drawers, including the
PROPERTIES drawer, are consistently hidden during presentations. The
custom function iterates through entries and hides the designated
regions, improving the user experience during interactive sessions.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | org-drill.el | 39 |
2 files changed, 28 insertions, 12 deletions
@@ -7,4 +7,5 @@ org-drill.html /robot/failure.txt /robot/messages.txt /robot/*-copy.org +/docs diff --git a/org-drill.el b/org-drill.el index 582cef1..44390d2 100644 --- a/org-drill.el +++ b/org-drill.el @@ -1833,6 +1833,21 @@ visual overlay, or with the string TEXT if it is supplied." (while (re-search-forward "^#.*$" nil t) (org-drill-hide-region (match-beginning 0) (match-end 0))))) +(defun org-drill-hide-drawers () + "Hide all drawers in the current entry, including PROPERTIES drawer. +This is more reliable than `org-cycle-hide-drawers' for drill display." + (save-excursion + (org-back-to-heading t) + (let ((end (save-excursion (org-end-of-subtree t t)))) + (while (re-search-forward org-drawer-regexp end t) + (let* ((drawer-start (match-beginning 0)) + (drawer-name (match-string 1)) + (drawer-end (save-excursion + (re-search-forward "^[ \t]*:END:[ \t]*$" end t) + (point)))) + (when drawer-end + (org-drill-hide-region drawer-start drawer-end))))))) + (defun org-drill-unhide-text () "Unhide text." (save-excursion @@ -2031,7 +2046,7 @@ Note: does not actually alter the item." (org-drill--show-latex-fragments) ; overlay all LaTeX fragments with images (ignore-errors (org-display-inline-images t)) - (org-cycle-hide-drawers 'all) + (org-drill-hide-drawers) (prog1 (org-drill-presentation-prompt session) (org-drill-hide-subheadings-if 'org-drill-entry-p)))))) @@ -2052,7 +2067,7 @@ RESCHEDULE-FN is the function to reschedule." (org-drill--show-latex-fragments) (ignore-errors (org-display-inline-images t)) - (org-cycle-hide-drawers 'all) + (org-drill-hide-drawers) (org-remove-latex-fragment-image-overlays) (save-excursion (org-mark-subtree) @@ -2072,7 +2087,7 @@ RESCHEDULE-FN is the function to reschedule." (org-drill--show-latex-fragments) ; overlay all LaTeX fragments with images (ignore-errors (org-display-inline-images t)) - (org-cycle-hide-drawers 'all) + (org-drill-hide-drawers) (prog1 (org-drill-presentation-prompt-for-string session nil) (org-drill-hide-subheadings-if 'org-drill-entry-p)))))) @@ -2094,7 +2109,7 @@ RESCHEDULE-FN is the function to reschedule." (org-drill--show-latex-fragments) (ignore-errors (org-display-inline-images t)) - (org-cycle-hide-drawers 'all) + (org-drill-hide-drawers) (prog1 (org-drill-presentation-prompt session) (org-drill-hide-subheadings-if 'org-drill-entry-p))))))) @@ -2110,7 +2125,7 @@ RESCHEDULE-FN is the function to reschedule." (org-drill--show-latex-fragments) (ignore-errors (org-display-inline-images t)) - (org-cycle-hide-drawers 'all) + (org-drill-hide-drawers) (prog1 (org-drill-presentation-prompt session) (org-drill-hide-subheadings-if 'org-drill-entry-p))))))) @@ -2193,7 +2208,7 @@ items if FORCE-SHOW-FIRST or FORCE-SHOW-LAST is non-nil)." (org-drill--show-latex-fragments) (ignore-errors (org-display-inline-images t)) - (org-cycle-hide-drawers 'all) + (org-drill-hide-drawers) (prog1 (org-drill-presentation-prompt session) (org-drill-hide-subheadings-if 'org-drill-entry-p) (org-drill-unhide-clozed-text)))))) @@ -2246,7 +2261,7 @@ the second to last, etc." (org-drill--show-latex-fragments) (ignore-errors (org-display-inline-images t)) - (org-cycle-hide-drawers 'all) + (org-drill-hide-drawers) (prog1 (org-drill-presentation-prompt session) (org-drill-hide-subheadings-if 'org-drill-entry-p) (org-drill-unhide-clozed-text)))))) @@ -2366,7 +2381,7 @@ If ANSWER is supplied, set the session slot `drill-answer' to its value." (org-drill-with-replaced-entry-text (concat "\n" question) (org-drill-hide-all-subheadings-except nil) - (org-cycle-hide-drawers 'all) + (org-drill-hide-drawers) (ignore-errors (org-display-inline-images t)) (prog1 (org-drill-presentation-prompt session) @@ -2407,7 +2422,7 @@ See `org-drill' for more details." (save-restriction (org-narrow-to-subtree) (org-show-subtree) - (org-cycle-hide-drawers 'all) + (org-drill-hide-drawers) (let ((presentation-fn (cdr (assoc card-type org-drill-card-type-alist)))) @@ -3359,7 +3374,7 @@ returns its return value." (mood (format "%s mood" mood)))) infinitive translation) - (org-cycle-hide-drawers 'all) + (org-drill-hide-drawers) (funcall reschedule-fn session)))) @@ -3453,7 +3468,7 @@ returns its return value." (org-drill-with-replaced-entry-heading (format "Declensions of %s (%s) ==> %s\n\n" noun noun-gender translation) - (org-cycle-hide-drawers 'all) + (org-drill-hide-drawers) (funcall reschedule-fn session)))) ;;; `spanish_verb' card type ================================================== @@ -3508,7 +3523,7 @@ returns its return value." "Spanish translation of this English verb.") ;;reveal-headings '("Infinitive" "Future Perfect Tense" "Notes") ))) - (org-cycle-hide-drawers 'all) + (org-drill-hide-drawers) (prog1 (org-drill-presentation-prompt session prompt) (org-drill-hide-subheadings-if 'org-drill-entry-p))))))) |
