diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-26 17:10:55 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-26 18:09:28 -0500 |
| commit | 5c8d908a943470e3e4738c090cf8eaa1deee5a1f (patch) | |
| tree | 2c5d4d7d390013b32768321389dce6419191715b /tests/test-org-drill-queue-and-misc.el | |
| parent | 1338b2ae757b7143fe4d211fc5a354c73cee526b (diff) | |
| download | org-drill-5c8d908a943470e3e4738c090cf8eaa1deee5a1f.tar.gz org-drill-5c8d908a943470e3e4738c090cf8eaa1deee5a1f.zip | |
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.
Diffstat (limited to 'tests/test-org-drill-queue-and-misc.el')
| -rw-r--r-- | tests/test-org-drill-queue-and-misc.el | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/test-org-drill-queue-and-misc.el b/tests/test-org-drill-queue-and-misc.el index d8cc3fa..81a7844 100644 --- a/tests/test-org-drill-queue-and-misc.el +++ b/tests/test-org-drill-queue-and-misc.el @@ -194,26 +194,27 @@ warned-about-id-creation slot flips to t and a fresh ID is returned." (org-drill-id-get-create-with-warning session) (should (oref session warned-about-id-creation)))))) -;;;; org-drill-add-cloze-fontification +;;;; org-drill-mode (cloze fontification) -(ert-deftest test-org-drill-add-cloze-fontification-sets-buffer-local-regex () - "Sets buffer-local `org-drill-cloze-regexp' built from the current delimiters." +(ert-deftest test-org-drill-mode-sets-buffer-local-regex () + "Enabling `org-drill-mode' sets buffer-local `org-drill-cloze-regexp' built +from the current delimiters." (with-temp-buffer (let ((org-startup-folded nil)) (org-mode) (let ((org-drill-left-cloze-delimiter "{{") (org-drill-right-cloze-delimiter "}}")) - (org-drill-add-cloze-fontification) + (org-drill-mode 1) (should (local-variable-p 'org-drill-cloze-regexp)) ;; The buffer-local regex matches the new delimiters. (should (string-match-p org-drill-cloze-regexp "test {{x}} more")) (should-not (string-match-p org-drill-cloze-regexp "test [x] more")))))) -(ert-deftest test-org-drill-add-cloze-fontification-sets-buffer-local-keywords () +(ert-deftest test-org-drill-mode-sets-buffer-local-keywords () (with-temp-buffer (let ((org-startup-folded nil)) (org-mode) - (org-drill-add-cloze-fontification) + (org-drill-mode 1) (should (local-variable-p 'org-drill-cloze-keywords)) (should (listp org-drill-cloze-keywords))))) |
