Skip to content

Commit

Permalink
Improve agenda performance
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
yantar92 committed Sep 20, 2022
1 parent a526ea6 commit 0057cc2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lisp/org-agenda.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 3 additions & 1 deletion lisp/org.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0057cc2

Please sign in to comment.