From 5c8d908a943470e3e4738c090cf8eaa1deee5a1f Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 26 May 2026 17:10:55 -0500 Subject: fix: scope cloze fontification to drill buffers via org-drill-mode org-drill-add-cloze-fontification ran on org-font-lock-set-keywords-hook, which fires in every org buffer, and pushed the cloze rule into org's global org-font-lock-extra-keywords. The cloze regexp is built from the [ and ] delimiters, so an org priority cookie like [#A] matched the cloze pattern and got fontified as a cloze in every org buffer, colliding with org's headline fontification and stripping the heading's org-level-N face. I replaced the global install with org-drill-mode, a buffer-local minor mode that adds the cloze keywords only to its own buffer via font-lock-add-keywords. org-drill-auto-enable-mode (default on) turns the mode on from org-mode-hook in buffers that hold drill cards, so existing drill files keep their cloze highlighting while plain org buffers stay clean. Highlighting still respects org-drill-use-visible-cloze-face-p. The cloze regexp itself is unchanged, so the single-line cloze constraint from #38 is preserved. --- tests/test-org-drill-small-branch-coverage.el | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'tests/test-org-drill-small-branch-coverage.el') diff --git a/tests/test-org-drill-small-branch-coverage.el b/tests/test-org-drill-small-branch-coverage.el index db1a2e9..21b67c6 100644 --- a/tests/test-org-drill-small-branch-coverage.el +++ b/tests/test-org-drill-small-branch-coverage.el @@ -105,24 +105,24 @@ read and re-activates it on the way out." (should hook-ran) (should key-read))) -;;;; org-drill-add-cloze-fontification +;;;; org-drill-mode cloze-face flag branches -(ert-deftest test-add-cloze-fontification-with-flag-extends-keywords () - "When `org-drill-use-visible-cloze-face-p' is t, the cloze keyword spec is -added to `org-font-lock-extra-keywords'." +(ert-deftest test-org-drill-mode-with-flag-installs-cloze-keywords () + "When `org-drill-use-visible-cloze-face-p' is t, enabling `org-drill-mode' +installs the cloze keyword spec buffer-locally." (with-temp-buffer - (let ((org-drill-use-visible-cloze-face-p t) - (org-font-lock-extra-keywords nil)) - (org-drill-add-cloze-fontification) - (should org-font-lock-extra-keywords)))) + (org-mode) + (let ((org-drill-use-visible-cloze-face-p t)) + (org-drill-mode 1) + (should org-drill--installed-cloze-keywords)))) -(ert-deftest test-add-cloze-fontification-without-flag-leaves-keywords-untouched () - "When the flag is nil, no entry is added to `org-font-lock-extra-keywords'." +(ert-deftest test-org-drill-mode-without-flag-installs-nothing () + "When the flag is nil, enabling `org-drill-mode' installs no cloze keywords." (with-temp-buffer - (let ((org-drill-use-visible-cloze-face-p nil) - (org-font-lock-extra-keywords nil)) - (org-drill-add-cloze-fontification) - (should (null org-font-lock-extra-keywords))))) + (org-mode) + (let ((org-drill-use-visible-cloze-face-p nil)) + (org-drill-mode 1) + (should (null org-drill--installed-cloze-keywords))))) (provide 'test-org-drill-small-branch-coverage) ;;; test-org-drill-small-branch-coverage.el ends here -- cgit v1.2.3