aboutsummaryrefslogtreecommitdiff
path: root/org-drill.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-05 05:14:09 -0500
committerCraig Jennings <c@cjennings.net>2026-05-05 05:14:09 -0500
commitaa3d724c6bdd3a16391ad95040184c118386d329 (patch)
treeaaa706e89f60eb3dbbe1eb524dcb7921556cdf48 /org-drill.el
parent88b7fb502c0317ac29b3c7f3eb3f4c0617c87c02 (diff)
downloadorg-drill-aa3d724c6bdd3a16391ad95040184c118386d329.tar.gz
org-drill-aa3d724c6bdd3a16391ad95040184c118386d329.zip
fix: hide-drawers ignores drawers with no :END:
drawer-end was captured as (save-excursion (re-search-forward ':END:' end t) (point)) which always returns a number — (point) is always defined. The subsequent (when drawer-end ...) guard was dead, so a malformed drawer (typo in :END:, mid-edit truncation) ended up with a junk overlay covering whatever range point happened to land in. Captured the search result itself and gate on it. Malformed drawers are now skipped silently; well-formed drawers still get their normal overlay.
Diffstat (limited to 'org-drill.el')
-rw-r--r--org-drill.el13
1 files changed, 10 insertions, 3 deletions
diff --git a/org-drill.el b/org-drill.el
index 5037d73..97ba891 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -1941,15 +1941,22 @@ visual overlay, or with the string TEXT if it is supplied."
(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."
+This is more reliable than `org-cycle-hide-drawers' for drill display.
+
+Drawer-end was previously captured as the value of `(point)' after
+the search — always a number, so the subsequent `(when drawer-end)'
+guard was dead. Capture the search result itself and gate on that,
+otherwise a malformed drawer (no `:END:') ends up with a junk
+overlay covering whatever range point happened to be at."
(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-end (save-excursion
- (re-search-forward "^[ \t]*:END:[ \t]*$" end t)
- (point))))
+ (when (re-search-forward
+ "^[ \t]*:END:[ \t]*$" end t)
+ (point)))))
(when drawer-end
(org-drill-hide-region drawer-start drawer-end)))))))