Subject: 26.0.50; cancel-change-group fails with "unrelated state" error if used after an undo

From: Andreas Politz <[email-masked]>
Date: Sat, 11 Mar 2017 19:01:28 +0100

Save the following in some file foo.el:

#+BEGIN_SRC emacs-lisp
(defun bug ()
  (interactive)
  (catch 'done
    (atomic-change-group
      (insert "bug")
      (throw 'done nil))))

(setq debug-on-error t)
(switch-to-buffer (get-buffer-create "*bug*"))
(setq unread-command-events
      (list
       ;; insert abc
       ?a ?b ?c
       ;; undo once
       ?\C-/
       ;; call bug
       ?\M-x ?b ?u ?g ?\C-j))
#+END_SRC

, then start Emacs like this:

$ emacs -Q -l foo.el

Debugger entered--Lisp error: (error "Undoing to some unrelated state")
  signal(error ("Undoing to some unrelated state"))
  error("Undoing to some unrelated state")
  cancel-change-group(((#<buffer *bug*> nil)))

--

-ap