From 5d0e2beb9c8b8a239c41dab2f3b44d1fe83bff0c Mon Sep 17 00:00:00 2001 From: Matthieu Caneill Date: Thu, 26 Jan 2023 23:51:05 +0100 Subject: [PATCH] org-element-cache-map: Fix handling of continue-from * lisp/org-element.el (org-element-cache-map): When the receiving function sets `org-element-cache-map-continue-from', value of START should be set accordingly. * lisp/org.el (org-scan-tags): Reset `org-map-continue-from' for every iteration, and set it to the end of the element when sub-elements should be skipped following `org-tags-match-list-sublevels'. TINYCHANGE --- lisp/org-element.el | 3 ++- lisp/org.el | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index a3d909290..0a1d31bee 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -7700,7 +7700,8 @@ the cache." ;; If FUNC moved point forward, update ;; START. (when org-element-cache-map-continue-from - (goto-char org-element-cache-map-continue-from)) + (goto-char org-element-cache-map-continue-from) + (setq start org-element-cache-map-continue-from)) (when (> (point) start) (move-start-to-next-match nil)) ;; Drop nil. diff --git a/lisp/org.el b/lisp/org.el index ac2acfefb..dc9b7da7f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -11010,6 +11010,7 @@ headlines matching this string." org-outline-regexp)))) (org-element-cache-map (lambda (el) + (setq org-map-continue-from nil) (goto-char (org-element-property :begin el)) (setq todo (org-element-property :todo-keyword el) level (org-element-property :level el) @@ -11084,7 +11085,6 @@ headlines matching this string." 'type (concat "tagsmatch" ts-date-type)) (push txt rtn)) ((functionp action) - (setq org-map-continue-from nil) (save-excursion (setq rtn1 (funcall action)) (push rtn1 rtn))) @@ -11092,7 +11092,8 @@ headlines matching this string." ;; if we are to skip sublevels, jump to end of subtree (unless org-tags-match-list-sublevels - (goto-char (1- (org-element-property :end el)))))) + (goto-char (1- (org-element-property :end el))) + (setq org-map-continue-from (org-element-property :end el))))) ;; Get the correct position from where to continue (when org-map-continue-from (setq org-element-cache-map-continue-from org-map-continue-from) -- 2.30.2