branch: externals/org commit 654005394b68cc1bf4ba8ff5791333fc3f080826 Author: Ihor Radchenko <yanta...@gmail.com> Commit: Ihor Radchenko <yanta...@gmail.com>
org-list-struct-apply-struct: Do not rely on `match-data' after edits * lisp/org-list.el (org-list-struct-apply-struct): Refresh `org-list-full-item-re' match data if we edit the bullet. Fixes https://orgmode.org/list/62cbc0f3.1c69fb81.13d5e.e250smtpin_added_bro...@mx.google.com * testing/lisp/test-org-list.el (test-org-list/indent-item): Add test checking for the reported bug. --- lisp/org-list.el | 3 +++ testing/lisp/test-org-list.el | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/lisp/org-list.el b/lisp/org-list.el index e2c3fad7c5..0f0aaefdc3 100644 --- a/lisp/org-list.el +++ b/lisp/org-list.el @@ -1953,6 +1953,9 @@ Initial position of cursor is restored after the changes." (goto-char (match-end 1)) (insert-before-markers new-bul) (insert keep-space)))) + ;; Refresh potentially shifted match markers. + (goto-char item) + (looking-at org-list-full-item-re) ;; b. Replace checkbox. (cond ((equal (match-string 3) new-box)) diff --git a/testing/lisp/test-org-list.el b/testing/lisp/test-org-list.el index da1841e73e..cab2937126 100644 --- a/testing/lisp/test-org-list.el +++ b/testing/lisp/test-org-list.el @@ -309,6 +309,16 @@ (buffer-string)))) (should (equal " +- [ ] list item 1 + + [ ] list item 2" + (org-test-with-temp-text " +- [ ] list item 1 +- [ ] list item 2<point>" + (let ((org-list-demote-modify-bullet '(("-" . "+")))) + (org-indent-item) + (buffer-string))))) + (should + (equal " 1. Item 1 + Item 2" (org-test-with-temp-text "