Subject: bug#60467: closed (Re: bug#60467: 30.0.50; primitive-undo: Changes to be undone by function different from announced)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 13 Jan 2023 22:46:02 +0000

Your bug report

#60467: 30.0.50; primitive-undo: Changes to be undone by function different from announced

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
60467: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60467
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#60467: 30.0.50; primitive-undo: Changes to be undone by function different from announced
From: Stefan Monnier <[email-masked]>
To: Eli Zaretskii <[email-masked]>
Cc: [email-masked], [email-masked], [email-masked], [email-masked]
Date: Fri, 13 Jan 2023 17:45:06 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

> Fine with me, thanks.

OK, pushed.
I also pushed Gregory's new tests.  I think we can close this now.

        Stefan

Subject: 30.0.50; primitive-undo: Changes to be undone by function different from announced
From: Ihor Radchenko <[email-masked]>
To: [email-masked]
Date: Sun, 01 Jan 2023 13:40:08 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

Original report:
https://orgmode.org/list/[email-masked]

I am not sure if it is Emacs bug, but I have difficulty understanding
the origin of the following error:

1. Create /tmp/bug.org with the following contents

* h1
** h2

2. emacs -Q /tmp/bug.org
3. Move point to h2
4. M-x org-promote-subtree
5. M-x undo
6. Observe "Changes to be undone by function different from announced" error

The functions in question are below and I fail to see anything that may
be wrong there.

(defun org-promote-subtree ()
  "Promote the entire subtree.
See also `org-promote'."
  (interactive)
  (save-excursion
    (org-back-to-heading t)
    (combine-change-calls (point) (save-excursion (org-end-of-subtree t))
      (org-with-limited-levels (org-map-tree 'org-promote))))
  (org-fix-position-after-promote))

(defun org-promote ()
  "Promote the current heading higher up the tree."
  (org-with-wide-buffer
   (org-back-to-heading t)
   (let* ((after-change-functions (remq 'flyspell-after-change-function
					after-change-functions))
	  (level (save-match-data (funcall outline-level)))
	  (up-head (concat (make-string (org-get-valid-level level -1) ?*) " "))
	  (diff (abs (- level (length up-head) -1))))
     (cond
      ((and (= level 1) org-allow-promoting-top-level-subtree)
       (replace-match "# " nil t))
      ((= level 1)
       (user-error "Cannot promote to level 0.  UNDO to recover if necessary"))
      (t (replace-match (apply #'propertize up-head (text-properties-at (match-beginning 0))) t)))
     (unless (= level 1)
       (when org-auto-align-tags (org-align-tags))
       (when org-adapt-indentation (org-fixup-indentation (- diff))))
     (run-hooks 'org-after-promote-entry-hook))))  

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.35, cairo version 1.17.6) of 2022-12-26 built on localhost
Repository revision: cc29fab3a66c59e77d0ff67c0f3e2e34ec80a03c
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Gentoo Linux

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>