Skip to content

Commit 6540053

Browse files
committed
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_BROKEN@mx.google.com * testing/lisp/test-org-list.el (test-org-list/indent-item): Add test checking for the reported bug.
1 parent 53e6aa8 commit 6540053

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lisp/org-list.el

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,9 @@ Initial position of cursor is restored after the changes."
19531953
(goto-char (match-end 1))
19541954
(insert-before-markers new-bul)
19551955
(insert keep-space))))
1956+
;; Refresh potentially shifted match markers.
1957+
(goto-char item)
1958+
(looking-at org-list-full-item-re)
19561959
;; b. Replace checkbox.
19571960
(cond
19581961
((equal (match-string 3) new-box))

testing/lisp/test-org-list.el

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,16 @@
309309
(buffer-string))))
310310
(should
311311
(equal "
312+
- [ ] list item 1
313+
+ [ ] list item 2"
314+
(org-test-with-temp-text "
315+
- [ ] list item 1
316+
- [ ] list item 2<point>"
317+
(let ((org-list-demote-modify-bullet '(("-" . "+"))))
318+
(org-indent-item)
319+
(buffer-string)))))
320+
(should
321+
(equal "
312322
1. Item 1
313323
+ Item 2"
314324
(org-test-with-temp-text "

0 commit comments

Comments
 (0)