aboutsummaryrefslogtreecommitdiff
path: root/org-drill.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-30 22:12:23 -0500
committerCraig Jennings <c@cjennings.net>2026-05-30 22:12:23 -0500
commit4fae47ee8c268a4f530f60996741a7871d096b13 (patch)
tree368bbe482c5f0dbf6d8ea16455bec7b1ba52dd16 /org-drill.el
parentc7da717d0bbe7fd3dc976c9519d135b0ea75b00e (diff)
downloadorg-drill-4fae47ee8c268a4f530f60996741a7871d096b13.tar.gz
org-drill-4fae47ee8c268a4f530f60996741a7871d096b13.zip
fix: detect #+FILETAGS decks so org-drill-mode auto-enables
org-drill-buffer-has-cards-p only scanned for a per-heading :drill:/:leitner: tag, so a deck tagged through #+FILETAGS: had no match and org-drill-mode never auto-enabled. Those files opened without cloze highlighting. I extended the predicate to also scan #+FILETAGS: lines, handling both the space-separated and colon-delimited syntaxes, with [: \t] boundaries so a value like drilldown can't false-match drill. The inherited-top-level-tag case already worked, since the ancestor heading line carries the literal tag and the per-heading scan catches it. Tests cover filetag-only decks (space, colon, leitner), the inherited-top-level lock, the substring boundary, and auto-enable on a filetag-only buffer.
Diffstat (limited to 'org-drill.el')
-rw-r--r--org-drill.el37
1 files changed, 27 insertions, 10 deletions
diff --git a/org-drill.el b/org-drill.el
index 2680113..2ad00f0 100644
--- a/org-drill.el
+++ b/org-drill.el
@@ -3782,19 +3782,36 @@ non-nil; otherwise the mode is a no-op for fontification."
(defun org-drill-buffer-has-cards-p ()
"Return non-nil if the current buffer contains a drill card — a heading
-tagged with `org-drill-question-tag' or `org-drill-leitner-tag'."
+tagged with `org-drill-question-tag' or `org-drill-leitner-tag'.
+
+The tag may sit on the heading itself, on an ancestor heading (the
+ancestor line carries the literal tag, so the per-heading scan still
+matches), or be applied file-wide via `#+FILETAGS:'. The file-tag case
+is checked separately because the tag never appears on a heading line
+there — the upstream bug where filetag-only decks failed to auto-enable
+`org-drill-mode'."
(save-excursion
(save-restriction
(widen)
- (goto-char (point-min))
- (let ((case-fold-search t))
- (re-search-forward
- (concat "^\\*+ .*:\\(?:"
- (regexp-quote org-drill-question-tag)
- "\\|"
- (regexp-quote org-drill-leitner-tag)
- "\\):")
- nil t)))))
+ (let ((case-fold-search t)
+ (tags (concat "\\(?:"
+ (regexp-quote org-drill-question-tag)
+ "\\|"
+ (regexp-quote org-drill-leitner-tag)
+ "\\)")))
+ (or
+ ;; Per-heading tag (also catches inheritance from a tagged ancestor).
+ (progn
+ (goto-char (point-min))
+ (re-search-forward (concat "^\\*+ .*:" tags ":") nil t))
+ ;; File-wide tag via #+FILETAGS:, in either the space-separated or
+ ;; colon-delimited syntax. The [: \t] boundaries keep a value like
+ ;; `drilldown' from matching `drill'.
+ (progn
+ (goto-char (point-min))
+ (re-search-forward
+ (concat "^#\\+FILETAGS:.*[: \t]" tags "\\(?:[: \t]\\|$\\)")
+ nil t)))))))
(defun org-drill-maybe-enable-mode ()
"Enable `org-drill-mode' when appropriate for the current buffer.