From 0057cc21e13769ec2f8971d49f4e832c6621a2ac Mon Sep 17 00:00:00 2001 From: Ihor Radchenko Date: Tue, 20 Sep 2022 19:18:16 +0800 Subject: [PATCH] Improve agenda performance * lisp/org-agenda.el (org-agenda-skip): Make use of ELEMENT argument when calling `org-in-src-block-p'. (org-agenda-get-sexps): Pass actual element at point to `org-agenda-skip'. * lisp/org.el (org-end-of-subtree): Avoid unnecessary call to `org-back-to-heading-or-point-min' when ELEMENT is provided. --- lisp/org-agenda.el | 4 ++-- lisp/org.el | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 4ab6d35aa2..1d8b871d89 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -4226,7 +4226,7 @@ Optional argument ELEMENT contains element at point." (and (setq to (or (org-agenda-skip-eval org-agenda-skip-function-global) (org-agenda-skip-eval org-agenda-skip-function))) (goto-char to)) - (org-in-src-block-p t)) + (org-in-src-block-p t element)) (throw :skip t)))) (defun org-agenda-skip-eval (form) @@ -5910,7 +5910,7 @@ displayed in agenda view." (goto-char (point-min)) (while (re-search-forward regexp nil t) (catch :skip - (org-agenda-skip (org-element-lineage (org-element-at-point) '(headline inlinetask) 'with-self)) + (org-agenda-skip (org-element-at-point)) (setq beg (match-beginning 0)) (goto-char (1- (match-end 0))) (setq b (point)) diff --git a/lisp/org.el b/lisp/org.el index a509215198..daa0b6d956 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -20365,7 +20365,9 @@ If there is no such heading, return nil." ;; Furthermore, when used inside Org, finding the end of a large subtree ;; with many children and grandchildren etc, this can be much faster ;; than the outline version. - (org-back-to-heading-or-point-min invisible-ok) + (if element + (setq element (org-element-lineage element '(headline inlinetask) 'include-self)) + (org-back-to-heading-or-point-min invisible-ok)) (unless (and (org-element--cache-active-p) (let ((cached (or element (org-element-at-point nil t)))) (and cached