Skip to content

Doom's performance optimizations break org-drill (in general: certain usages of org-map-entries) #7979

@RBckmnn

Description

@RBckmnn

I confirm that...

  • I have searched the issue tracker, documentation, FAQ, Discourse, and Google, in case this issue has already been reported/resolved.
  • I have read "How to Debug Issues", and will use it to provide as much information about this issue as possible.
  • The issue can be reproduced on the latest available commit of Doom.
  • 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")))

  1. 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

System Information

https://pastebin.com/VavSwE7T

Metadata

Metadata

Assignees

No one assigned

    Labels

    :lang orgPertains to Doom's :lang org moduleis:bugSomething isn't working as intendedre:interopHas to do with interop between packages

    Type

    Open to PRs

    No

    Priority

    None yet

    Projects

    Status
    Investigating

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions