emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] Bad interaction between org-add-log-setup and org-with-remote-undo [9.6.6 (release_9.6.6 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)]
@ 2023-08-03 21:25 Aaron Zeng
  2023-08-04  7:57 ` Ihor Radchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Aaron Zeng @ 2023-08-03 21:25 UTC (permalink / raw)
  To: emacs-orgmode

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/>)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-04  7:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03 21:25 [BUG] Bad interaction between org-add-log-setup and org-with-remote-undo [9.6.6 (release_9.6.6 @ /Applications/Emacs.app/Contents/Resources/lisp/org/)] Aaron Zeng
2023-08-04  7:57 ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).