GNU bug report logs - #74523
31.0.50; `apply` elements screw up undo in region

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Mon, 25 Nov 2024 06:20:01 UTC

Severity: normal

Found in version 31.0.50

To reply to this bug, email your comments to 74523 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org:
bug#74523; Package emacs. (Mon, 25 Nov 2024 06:20:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
New bug report received and forwarded. Copy sent to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org. (Mon, 25 Nov 2024 06:20:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; `apply` elements screw up undo in region
Date: Mon, 25 Nov 2024 01:19:43 -0500
Package: Emacs
Version: 31.0.50


We currently don't support `apply` undo-elements very well (if at all)
in the undo-in-region feature.
Those elements used to be rare, but now that `comment-region` and other
users of `combine-change-calls` generate them, it's not as rare.

The following test fails because of that:

    (ert-deftest simple-tests--undo-apply ()
      (with-temp-buffer
        (modula-2-mode) ;; A simple mode with non-LF terminated comments.
        (buffer-enable-undo)
        (insert "foo\n\n")
        (let ((midbeg (point-marker))
              (_ (insert "midmid"))
              (midend (point-marker)))
          (insert "\n\nbar")
          (undo-boundary)
          (goto-char (+ midbeg 3))
          (insert "\n")
          (undo-boundary)
          (comment-region (point-min) midbeg)
          (undo-boundary)
          (comment-region midend (point-max))
          (undo-boundary)
          (progn
            (goto-char midbeg)
            (set-mark midend)
            (setq last-command 'something-else) ;Not `undo', so we start a new run.
            (undo '(4))
            (should (equal (buffer-substring midbeg midend) "midmid")))
          )))

- Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#74523; Package emacs. (Mon, 25 Nov 2024 15:20:02 GMT) Full text and rfc822 format available.

Message #8 received at 74523 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 74523 <at> debbugs.gnu.org
Subject: Re: bug#74523: 31.0.50; `apply` elements screw up undo in region
Date: Mon, 25 Nov 2024 10:19:36 -0500
> We currently don't support `apply` undo-elements very well (if at all)
> in the undo-in-region feature.
> Those elements used to be rare, but now that `comment-region` and other
> users of `combine-change-calls` generate them, it's not as rare.

I pushed a patch which fixes the test I sent, but `apply` elements are
still never included in undo-in-region.

Fixing that won't be easy in general: we have no way for
`undo-adjust-elt` to handle them correctly.


        Stefan





This bug report was last modified 202 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.