Doom's performance optimizations break `org-drill` (in general: certain usages of `org-map-entries`)
- Dominant language
- Emacs Lisp
- Stars
- 22.7k
- Forks
- 3.1k
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 4
Description
### I confirm that...
- [X] I have searched the [issue tracker](https://github.com/doomemacs/doomemacs/issues), [documentation](https://docs.doomemacs.org), [FAQ](https://docs.doomemacs.org/-/faq), [Discourse](https://discourse.doomemacs.org), and [Google](https://google.com), in case this issue has already been reported/resolved.
- [X] I have read "[How to Debug Issues](https://doomemacs.org/d/how2debug)", and will use it to provide as much information about this issue as possible.
- [X] The issue can be reproduced on the **latest** available commit of Doom.
- [X] The issue can be reproduced on a stable release of Emacs, such as 27, 28, or 29. *(Unstable versions end in .50, .60, or .9x)*
### Expected behavior
I ran into this issue while using the `org-drill` package (but it seems to be a general problem). The package allows for spaced repetition practice of flash cards. A flash card corresponds to a heading in an org file. During a drill session a part of the content of such a heading is shown to the user and the user then has to indicate how well he remembered the part not displayed.
### Current behavior
I have noticed that `org-drill` behaved weirdly for quite some time now. The most common problems are that in a practice session `org-drill` sometimes shows headings in a collapsed manner (the contents of the heading should be expanded) or it shows parts of the org file that do not correspond to a heading at all. Please see below for my attempts to resolve the issue.
### Steps to reproduce
I have produced a minimal working example that exposes the underlying issue. To reproduce:
1. Download the added file, rename it to `file1.org`
2. Define the following function:
```
(defun foo ()
(interactive)
(org-map-entries
(lambda ()
(sit-for 0.5)
(org-id-get-create))
nil '("./file1.org")))
```
3. Open the file downloaded in 1. Make sure that both headlines in the file are collapsed and point is positioned at the beginning of the file. Then invoke the `foo` function.
The function should add an id property to every heading in the file but it does so only for the second heading in the file.
The root cause of this seems to be the `+org--restart-mode-h` function which runs because `org-map-entries` calls `org-agenda-prepare-buffers` in its implementations which kicks off Doom's performance optimizations for org. In fact, turning `+org--restart-mode-h` into a no-op seems to solve all the issues with `org-drill`.
[file1.txt](https://github.com/user-attachments/files/16482966/file1.txt)
### System Information
https://pastebin.com/VavSwE7T
Contributor guide
Assessment
This issue has not been assessed yet.