In both agenda mode or a regular org mode buffer, whenever I change the todo state, I want the buffer to be saved automatically.
1 Answer
Adding to org-trigger-hook
works:
(add-hook 'org-trigger-hook 'save-buffer)
Adding to org-after-todo-state-change-hook
hook does NOT work:
I was troubled to see the hook above did not work until I saw the following post on reddit: https://www.reddit.com/r/orgmode/comments/9sxe3w/save_file_after_toggling_todo_state/
-
How did you determine that
org-after-todo-state-change-hook
did not work?– NickDMar 4, 2020 at 2:17 -
@NickD simply checked if the file is still marked as modified after state change. i don't think the
save-buffer
is called. i'm not proficient enough to provide more detailed debug info on this. Mar 4, 2020 at 19:59 -
I'm pretty sure that the buffer is saved. There is something happening afterwards that marks the buffer modified again. org-trigger-hook is run at the very end of org-todo so it does not suffer from this. It would be nice to figure it out and report it as a bug. Thanks for the reply: I just wanted to make sure that my understanding is correct.– NickDMar 4, 2020 at 21:43
-