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-small-branch-coverage.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-small-branch-coverage.el')
| -rw-r--r-- | tests/test-org-drill-small-branch-coverage.el | 28 |
1 files changed, 14 insertions, 14 deletions
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 |
