0

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

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/

| improve this answer | |
  • How did you determine that org-after-todo-state-change-hook did not work? – NickD Mar 4 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. – Mingwei Zhang Mar 4 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. – NickD Mar 4 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.