emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[BUG] Storing multiple log notes recursively only keeps the last note (w


From: Ihor Radchenko
Subject: [BUG] Storing multiple log notes recursively only keeps the last note (was: Tracking todo state changes AND automatically change to done when all children are done)
Date: Sun, 02 Oct 2022 14:10:57 +0800

Ihor Radchenko <yantar92@gmail.com> writes:

>> To reproduce this curious behavior, you only need this configuration:
>
> Confirmed.
>
> Something inside `org-todo' call in the hook triggers recursive-edit
> that, in turn, triggers premature call to post-command-hook containing
> note saving function.

I was wrong. Your bug has little to do with recursive edits.
It is related to the fact that log notes rely on global variables to
save the information about the note and record it in
`post-command-hook'.

What is happening is that `org-add-log-setup' is first called for the
child heading and then called for the parent heading in
`org-after-todo-statistics-hook'. The second call overwrites the global
note state.

Later, after Emacs finish executing the user command,
`org-store-log-note' is called, but it only sees the overwritten log
state - the one for the most recent call to `org-add-log-setup' (parent
heading). Thus only parent heading gets the actual note record.

We can solve the issue in multiple ways:
1. We may force recording the previous note (if any) at the beginning of
   `org-add-log-setup'.
2. We may alter `org-add-log-setup' to record the note using recursive
   edit. This way, every log note will be recorded immediately upon
   request.
3. We may maintain a log queue and record multiple logs one-by-one in
   post-command-hook.

I personally like option 2, but I am not sure about side effects.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92



reply via email to

[Prev in Thread] Current Thread [Next in Thread]