On Sun, 27 Jun 2021 at 12:01, Bhavin Gandhi wrote: > > Till now I found that the function `org-add-log-setup' is getting > called twice. Why that's happening, I'm not sure yet. I think running > edebug will help here, I'm going to try that. >
I found the reason for this behavior with the help of edebug. `org-todo' calls `org-add-log-setup' to log the state change, and then it calls `org-auto-repeat-maybe'. The `org-auto-repeat-maybe' then calls the `org-add-log-setup' again, I think this is for logging something related to repeated entries. Before the change `c670379ad', `org-add-log-setup' used to add `org-add-log-note' to post-command-hook instead of calling it directly. If I have understood the post-command-hooks correctly, it used to keep only one entry of `org-add-log-note'. This is because `add-hook' function makes sure that there are no duplicate entries in the hooks. I'm not sure how this can be fixed, I'm going to read the `org-auto-repeat-maybe' to understand what all it is doing.