1

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 1

3

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/

4
  • How did you determine that org-after-todo-state-change-hook did not work?
    – NickD
    Commented Mar 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. Commented 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.
    – NickD
    Commented Mar 4, 2020 at 21:43
  • @NickD I can confirm that this still the case as of now.
    – Gordon Bai
    Commented Sep 5, 2021 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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