<feed xmlns='http://www.w3.org/2005/Atom'>
<title>org-drill/tests/test-org-drill-entry-empty-p.el, branch main</title>
<subtitle>Spaced-repetition flashcards for Org Mode
</subtitle>
<id>https://git.cjennings.net/org-drill/atom?h=main</id>
<link rel='self' href='https://git.cjennings.net/org-drill/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/org-drill/'/>
<updated>2026-05-05T08:43:25+00:00</updated>
<entry>
<title>fix: include child subtree in entry-empty-p search bound (upstream #13)</title>
<updated>2026-05-05T08:43:25+00:00</updated>
<author>
<name>Craig Jennings</name>
<email>c@cjennings.net</email>
</author>
<published>2026-05-05T08:43:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.cjennings.net/org-drill/commit/?id=77eb4f046cc90d535ba30ec8a408f52cb85da63f'/>
<id>urn:sha1:77eb4f046cc90d535ba30ec8a408f52cb85da63f</id>
<content type='text'>
kqr (2019-07-22) reported that drill entries whose answer lives inside a child sub-heading were silently skipped. Their example: a question in the heading text and the answer under `** The Answer`. The function returned t (empty) for such entries, so they never got presented during drill sessions.

The cause is `(outline-next-heading)` in `org-drill-entry-empty-p`. That primitive lands on the first heading at any level, including children. So the search range was metadata-end up to the child's heading line, which excluded the child's body. Bodies that lived in child sub-headings never got searched.

I switched the bound to `(org-end-of-subtree t t)`, which covers the whole subtree of the current heading and degrades gracefully at the last heading in the buffer. The reporter suggested `outline-forward-same-level`, but that primitive errors at the last sibling, which would be its own regression. `org-end-of-subtree` is the canonical Emacs idiom for this kind of bound and handles end-of-buffer correctly.

I added `tests/test-org-drill-entry-empty-p.el` with 6 ERT tests across Normal, Boundary (kqr's exact fixture), and edge categories. The two regression tests fail at HEAD before the fix and pass after.

One semantic note worth flagging: any subtree content now counts as non-empty, including bare child headings with no body of their own. The bug report is silent on that case and I expect it to be rare in practice. If anyone reports the new behavior as a regression, the fix would be to filter heading lines out of the graphical-character search.
</content>
</entry>
</feed>
