Hi folks, It seems there is a bad interaction between org-add-log-setup and org-with-remote-undo, such that org-agenda-undo does not function correctly. For example,
1. Enable logging on reschedule, by setting `org-log-reschedule' to `time'. 2. Reschedule an already-scheduled TODO item through an agenda buffer, by pressing C-c C-s (org-schedule). 3. Press C-/ (org-agenda-undo) while still in the agenda buffer. This has the unfortunate consequence of undoing all of the changes in the agenda buffer but only a subset of the changes in the source buffer where the task was defined (namely, the "rescheduled" log entry is removed but the timestamp is not restored to the original time). I believe this is because org-with-remote-undo creates an undo boundary after executing the body of the macro, but org-add-log-setup makes changes to the buffer in post-command-hook, after the undo-boundary is created. This means that /two/ undoable changes in the source buffer now logically correspond to the same change in the agenda buffer, which org-agenda-undo does not handle correctly. Some commands do not have this issue, such as org-agenda-todo, which calls org-add-log-note instead of org-add-log-setup and therefore does not make use of post-command-hook. This seems to be intentional: ;; Make sure that log is recorded in current undo. (when (and org-log-setup (not (eq org-log-note-how 'note))) (org-add-log-note)) I wonder if org-add-log-setup should be removed and refactored away, or if org-with-remote-undo should not be creating an undo boundary (which sounds redundant with the automatic ones created by the command loop?). Emacs : GNU Emacs 29.1 (build 1, aarch64-apple-darwin21.6.0, NS appkit-2113.60 Version 12.6.6 (Build 21G646)) of 2023-07-30 Package: Org mode version 9.6.6 (release_9.6.6 @ /Applications/Emacs.app/Contents/Resources/lisp/org/ <http://emacs.app/Contents/Resources/lisp/org/>)