emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals-release/org 84e5a4da54: org-element-cache-map: Fix edge


From: ELPA Syncer
Subject: [elpa] externals-release/org 84e5a4da54: org-element-cache-map: Fix edge case when FUNC removes DATA
Date: Thu, 8 Jun 2023 09:59:44 -0400 (EDT)

branch: externals-release/org
commit 84e5a4da54c1ef5c01f6d46edeb8f6db938a0e52
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    org-element-cache-map: Fix edge case when FUNC removes DATA
    
    * lisp/org-element.el (org-element-cache-map): Fix when DATA is
    obsolete after buffer modification.
    * testing/lisp/test-org.el (test-org/map-entries): Add test.
    
    Reported-by: Victor A. Stoichita <victor@svictor.net>
    Link: https://orgmode.org/list/87v8fzxbfo.fsf@svictor.net
---
 lisp/org-element.el      |  3 ++-
 testing/lisp/test-org.el | 25 ++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 517d45b022..df43ebcf0c 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -7734,7 +7734,8 @@ the cache."
                               ;; it to real beginning then despite
                               ;; START being larger.
                               (setq start nil)
-                              (move-start-to-next-match nil)
+                              (let ((data nil)) ; data may not be valid. 
ignore it.
+                                (move-start-to-next-match nil))
                               ;; The new element may now start before
                               ;; or at already processed position.
                               ;; Make sure that we continue from an
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 1b87b224e8..db9ad75726 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -2774,7 +2774,30 @@ SCHEDULED: <2014-03-04 tue.>"
                (beginning-of-line 2)
                (insert "test\n")
                (beginning-of-line -1)))
-            acc))))))
+            acc)))))
+  ;; Removing heading being processed.
+  (should
+   (equal
+    "Some text
+Some text
+Some more text
+Let’s stop here
+"
+    (org-test-with-temp-text
+        "* Heading 1
+Some text
+** Heading 1.1
+Some text
+* Heading 2
+Some more text
+** Heading 2.1
+Let’s stop here
+"
+      (org-map-entries
+       (lambda ()
+         (delete-region (point) (line-beginning-position 2))
+         (setq org-map-continue-from (point))))
+      (buffer-string)))))
 
 (ert-deftest test-org/edit-headline ()
   "Test `org-edit-headline' specifications."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]