From ced2b3335720d89fe354edf3e1e1631cac1280a3 Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Thu, 4 Nov 2021 22:54:58 +0800 Subject: [PATCH] org-element--parse-to: Fix return value at the and of first section * lisp/org-element.el (org-element--parse-to): Fix edge case when calling `org-element--parse-to' at contents end point of first section. We need to return outermost element ending before point in such scenario. Fixes https://list.orgmode.org/01bc6137-200d-8e2d-fdd7-6aad8382c619@posteo.eu/T/#u --- lisp/org-element.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/org-element.el b/lisp/org-element.el index a02d39204..9e917c31f 100644 --- a/lisp/org-element.el +++ b/lisp/org-element.el @@ -6415,7 +6415,7 @@ If you observe Emacs hangs frequently, please report this to Org mode mailing li ;; the headline section. (and (org-element--open-end-p element) (or (= (org-element-property :end element) (point-max)) - (and (> pos (org-element-property :contents-end element)) + (and (>= pos (org-element-property :contents-end element)) (memq (org-element-type element) '(org-data section headline))))))) (goto-char (or next cbeg)) (setq mode (if next mode (org-element--next-mode mode type t))