New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timer spam when org file is opened by org-agenda #11
Comments
|
Thanks for the report. I can confirm that |
|
Please try my most recent commit and report back. I reuse the timer (to prevent garbage buildup) and give up after 5 tries per buffer. I don't know why org-indent starts but never finishes initializing in your buffers; probably the right thing is to prevent org(-modern)-indent from running in that context. |
My understanding (I'm no emacs/lisp expert): when the buffers are opened by org-agenda or org-refile, etc.. with There's only one agent/timer: when a new buffer is opened and needs to be initialized, if the agent is already running, it just pushes the buffer into the agentized list, otherwise it starts the agent/timer (with the repeating flag, so it will keep running until the list is empty). I don't think there's a better hook offered by org-indent, or that you could use advices since org-indent seems to complete initialization via three different paths in An alternative would be to model the initialization of
It works in the sense it stops trying, I have 450 buffers (I know it's unusual but except when loading the agenda the first time in the session, it doesn't hinder usage) and it gives up almost instantly (as fast as it can run 0.5s worth of timers concurrently).
org-indent delaying itself doesn't slow down emacs the way So I modified |
|
So it sounds like the max-5 fix helps but there are still slowdowns due to all the timers proliferating. One thing I still don't understand: do you want all 450 buffers fully org-(modern)-indent'ed? Or would you prefer org-indent to just leave those alone? If you don't care to actually look at those buffers, the right thing to do is to disable org-indent and org-modern-indent when buffers are loaded in this automated manner via org-agenda, except if/when you actually display them in a window. This is simlar to what, e.g., consult preview does. Why spend time initializing buffers for display which you will never actually look at? In terms of a more durable fix, since There in fact is a perfect spot in org-indent to call such a hook: ;; Job is complete: un-agentize buffer.
(unless interruptp
(setq org-indent-agentized-buffers
(delq buffer org-indent-agentized-buffers))
(run-hook-with-args 'org-indent-buffer-init-finished buffer)) ;; <-- addedDo you want to engage the org mailing list folks to see about adding such an abnormal hook to |
You're right that would be the better way (marginally: though non-zero, I don't think the cost is perceptible). I don't need them org-(+modern)-indented in the background as long as they do get org-(+modern)-indented as I activate them throughout the day. But I couldn't find yet a way to do it except in EDIT: seems like Agree also a hook would be better than a timer, not sure I'll be able to follow-through after raising it with org but I can try. |
|
Great. If the org folks agree it's a trivial update. |
|
Any traction on an |
|
yes, ok on principle, need patch. Will you do it (since you proposed the change in the first place) or shall I? |
|
Great, thanks for pushing this along. Please feel free to submit a patch. You'd need to add a |
|
It's in (see here). The hook variable |
|
Great, thanks for this. Can you give the |
|
Thanks. With that branch and:
|
|
OK thanks. Good point about leaving it active after init failure; pushed a fix; please give a try and see if that works well in your case. I don't know when org 9.7 will release (soon?), but given that your case is pretty rare I think the current setup is OK. |
|
All good for me. I'll withdraw my PR then. As for org's release, I can run the 9.7 pre-release or a custom branch with the hook patch so no issue for me. |
|
Great, thanks for bringing this to my attention. |
I'm not 100% sure that's what's going on but it seems that if an org file is opened in a certain way (typically in the case I observe, by org-agenda), org-indent doesn't finish 'preparing' the buffer and adding it to
org-indent-agentized-buffers(I suppose because the buffer hasn't been displayed yet) and so org-modern-indent's timer resets itself indefinitely until the buffer is interactively visited or some other condition that lead to org-indent adding the buffer toorg-indent-agentized-buffers.With a large amount of files in
org-agenda-files, this slows down emacs since #number-of-buffer timers are executing every 0.1s. I'm not sure if there's a setting I could use to force org-indent to complete (from what I understand,org-indent-agent-*-delaywouldn't help since they skip the buffer if it's not active.The text was updated successfully, but these errors were encountered: