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

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

[elpa] externals-release/org c340e799f8: org-element-cache-map: Always c


From: ELPA Syncer
Subject: [elpa] externals-release/org c340e799f8: org-element-cache-map: Always continue after point set by FUNC
Date: Mon, 30 Jan 2023 04:58:08 -0500 (EST)

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

    org-element-cache-map: Always continue after point set by FUNC
    
    * lisp/org-element.el (org-element-cache-map): Never map over element
    starting before the point manually moved (or set via
    `org-element-cache-map-continue-from') by FUNC.
    * testing/lisp/test-org.el (test-org/map-entries): Add tests.
    
    Reported-by: Matthieu Caneill <matt@brokenwa.re>
    Link: https://orgmode.org/list/Y9MKUzWWbErLFhmq@brokenwa.re
---
 lisp/org-element.el      | 10 +++++++++-
 testing/lisp/test-org.el | 22 +++++++++++++++++++++-
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 389acf8250..ab28811cee 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -7697,7 +7697,15 @@ the cache."
                               (when org-element-cache-map-continue-from
                                 (goto-char 
org-element-cache-map-continue-from))
                               (when (> (point) start)
-                                (move-start-to-next-match nil))
+                                (move-start-to-next-match nil)
+                                ;; (point) inside matching element.
+                                ;; Go further.
+                                (when (> (point) start)
+                                  (setq data (element-match-at-point))
+                                  (if (not data)
+                                      (cache-walk-abort)
+                                    (goto-char (next-element-start))
+                                    (move-start-to-next-match 
next-element-re))))
                               ;; Drop nil.
                               (unless (car result) (pop result)))
                             ;; If FUNC did not move the point and we
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index f999189aad..09801b5d3f 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -2740,7 +2740,27 @@ SCHEDULED: <2014-03-04 tue.>"
                    (setq org-map-continue-from
                          (org-element-property
                           :begin (org-element-at-point))))))
-              (buffer-string)))))
+              (buffer-string))))
+  (should
+   (= 1
+      (org-test-with-temp-text "* H1\n** H1.1\n** H1.2\n"
+        (let (acc)
+          (org-map-entries
+           (lambda ()
+             (push (org-element-property :title (org-element-at-point)) acc)
+             (setq org-map-continue-from
+                   (org-element-property :end (org-element-at-point)))))
+          (length acc)))))
+  (should
+   (= 2
+      (org-test-with-temp-text "* H1\n** H1.1\n** H1.2\n"
+        (let (acc)
+          (org-map-entries
+           (lambda ()
+             (push (org-element-property :title (org-element-at-point)) acc)
+             (setq org-map-continue-from
+                   (line-end-position 2))))
+          (length acc))))))
 
 (ert-deftest test-org/edit-headline ()
   "Test `org-edit-headline' specifications."



reply via email to

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