emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Aaron Zeng" <z@bcc32.com>
To: emacs-orgmode@gnu.org
Subject: [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/)]
Date: Thu, 03 Aug 2023 17:25:26 -0400	[thread overview]
Message-ID: <29065f4d-de2c-4790-8b68-c4f47bf0dcfe@app.fastmail.com> (raw)

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


             reply	other threads:[~2023-08-04  7:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 21:25 Aaron Zeng [this message]
2023-08-04  7:57 ` [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/)] Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=29065f4d-de2c-4790-8b68-c4f47bf0dcfe@app.fastmail.com \
    --to=z@bcc32.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).