From aa3d724c6bdd3a16391ad95040184c118386d329 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 5 May 2026 05:14:09 -0500 Subject: fix: hide-drawers ignores drawers with no :END: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- org-drill.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'org-drill.el') 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))))))) -- cgit v1.2.3