org-element-cache-map: Fix an edge case with org-element-cache-continue-from
* lisp/org-element.el (org-element-cache-map): Make sure that START is never set to -1. It may cause infinite loops in some scenarios. * testing/lisp/test-org.el (test-org/map-entries): Add a test catching the reported situation. Reported in https://list.orgmode.org/CADywB5JHAyPX99Vr02SvAqiMTD+7ss4VWVipOhKfm=iGirDPhA@mail.gmail.com/T/#t
This commit is contained in:
parent
515ce56d4e
commit
dc4b2772e3
|
@ -7580,14 +7580,15 @@ the cache."
|
||||||
;; inside an element. We want to move
|
;; inside an element. We want to move
|
||||||
;; it to real beginning then despite
|
;; it to real beginning then despite
|
||||||
;; START being larger.
|
;; START being larger.
|
||||||
(setq start -1)
|
(setq start nil)
|
||||||
(move-start-to-next-match nil)
|
(move-start-to-next-match nil)
|
||||||
;; The new element may now start before
|
;; The new element may now start before
|
||||||
;; or at already processed position.
|
;; or at already processed position.
|
||||||
;; Make sure that we continue from an
|
;; Make sure that we continue from an
|
||||||
;; element past already processed
|
;; element past already processed
|
||||||
;; place.
|
;; place.
|
||||||
(when (and (<= start (org-element-property :begin data))
|
(when (and start
|
||||||
|
(<= start (org-element-property :begin data))
|
||||||
(not org-element-cache-map-continue-from))
|
(not org-element-cache-map-continue-from))
|
||||||
(goto-char start)
|
(goto-char start)
|
||||||
(setq data (element-match-at-point))
|
(setq data (element-match-at-point))
|
||||||
|
|
|
@ -2414,6 +2414,19 @@ SCHEDULED: <2014-03-04 tue.>"
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(org-cut-subtree)
|
(org-cut-subtree)
|
||||||
(setq org-map-continue-from (point))))
|
(setq org-map-continue-from (point))))
|
||||||
|
(buffer-string))))
|
||||||
|
(should
|
||||||
|
(string= "* H1\n* H2\n* H3\n"
|
||||||
|
(org-test-with-temp-text "* H1\n* H2\n* H3\n* H4"
|
||||||
|
(org-map-entries
|
||||||
|
(lambda ()
|
||||||
|
(when (string= "H4"
|
||||||
|
(org-element-property
|
||||||
|
:raw-value (org-element-at-point)))
|
||||||
|
(org-cut-subtree)
|
||||||
|
(setq org-map-continue-from
|
||||||
|
(org-element-property
|
||||||
|
:begin (org-element-at-point))))))
|
||||||
(buffer-string)))))
|
(buffer-string)))))
|
||||||
|
|
||||||
(ert-deftest test-org/edit-headline ()
|
(ert-deftest test-org/edit-headline ()
|
||||||
|
|
Loading…
Reference in New Issue