Browse Source

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.
Ihor Radchenko 3 years ago
parent
commit
0057cc21e1
2 changed files with 5 additions and 3 deletions
  1. 2 2
      lisp/org-agenda.el
  2. 3 1
      lisp/org.el

+ 2 - 2
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))

+ 3 - 1
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